From 427cc6b5d8fed7c0667af39f17551239f50b7953 Mon Sep 17 00:00:00 2001 From: Vlad Chikalkin Date: Mon, 27 Jan 2025 17:28:28 +0300 Subject: [PATCH] Feature/back button (#17) * prepare for header back button: fix pages layout add header with back button * set header title * optimize layout * remove navigation context * make profile photo bigger * remove page-header from main pages * fix profile layout * profile: use ui/Card * fix app background * contacts: use ui/Card component --- apps/web/app/(main)/contacts/page.tsx | 17 +++--- apps/web/app/(main)/layout.tsx | 4 +- .../app/(main)/profile/[telegramId]/page.tsx | 8 +-- apps/web/app/layout.tsx | 2 +- .../navigation/header/back-button.tsx | 14 +++++ .../components/navigation/header/index.tsx | 14 +++++ .../navigation/header/page-title.tsx | 5 ++ apps/web/components/navigation/index.tsx | 1 + .../{navbar.tsx => navbar/index.tsx} | 2 +- .../navigation/{ => navbar}/nav-button.tsx | 0 apps/web/components/profile/profile-card.tsx | 61 ++++++++++++++----- packages/ui/src/components/ui/card.tsx | 2 +- packages/ui/src/globals.css | 2 + packages/ui/tailwind.config.ts | 1 + 14 files changed, 102 insertions(+), 31 deletions(-) create mode 100644 apps/web/components/navigation/header/back-button.tsx create mode 100644 apps/web/components/navigation/header/index.tsx create mode 100644 apps/web/components/navigation/header/page-title.tsx rename apps/web/components/navigation/{navbar.tsx => navbar/index.tsx} (88%) rename apps/web/components/navigation/{ => navbar}/nav-button.tsx (100%) diff --git a/apps/web/app/(main)/contacts/page.tsx b/apps/web/app/(main)/contacts/page.tsx index 6dfce36..2bd43e6 100644 --- a/apps/web/app/(main)/contacts/page.tsx +++ b/apps/web/app/(main)/contacts/page.tsx @@ -1,17 +1,20 @@ import { ContactsList } from '@/components/contacts/contacts-list'; import { ContactsFilter } from '@/components/contacts/dropdown-filter'; import { ContactsFilterProvider } from '@/context/contacts-filter'; +import { Card } from '@repo/ui/components/ui/card'; export default function ContactsPage() { return ( -
-

Контакты

- -
-
- -
+ +
+

Контакты

+ +
+
+ +
+
); } diff --git a/apps/web/app/(main)/layout.tsx b/apps/web/app/(main)/layout.tsx index 69fff63..b3c37f7 100644 --- a/apps/web/app/(main)/layout.tsx +++ b/apps/web/app/(main)/layout.tsx @@ -3,9 +3,9 @@ import { type PropsWithChildren } from 'react'; export default async function Layout({ children }: Readonly) { return ( -
+ <>
{children}
-
+ ); } diff --git a/apps/web/app/(main)/profile/[telegramId]/page.tsx b/apps/web/app/(main)/profile/[telegramId]/page.tsx index c28c768..c94b1b4 100644 --- a/apps/web/app/(main)/profile/[telegramId]/page.tsx +++ b/apps/web/app/(main)/profile/[telegramId]/page.tsx @@ -1,12 +1,9 @@ import { getProfile } from '@/actions/profile'; +import { PageHeader } from '@/components/navigation'; import { ProfileCard } from '@/components/profile/profile-card'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; -type Props = { - params: Promise<{ - telegramId: string; - }>; -}; +type Props = { params: Promise<{ telegramId: string }> }; export default async function ProfilePage(props: Readonly) { const parameters = await props.params; @@ -21,6 +18,7 @@ export default async function ProfilePage(props: Readonly) { return ( + ); diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 49adbfd..6c91944 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -16,7 +16,7 @@ export default async function RootLayout({ children }: Readonly - + diff --git a/apps/web/components/navigation/header/back-button.tsx b/apps/web/components/navigation/header/back-button.tsx new file mode 100644 index 0000000..6486c48 --- /dev/null +++ b/apps/web/components/navigation/header/back-button.tsx @@ -0,0 +1,14 @@ +'use client'; +import { ArrowLeft } from 'lucide-react'; +import { useRouter } from 'next/navigation'; + +export function BackButton() { + const router = useRouter(); + + return ( +
+ router.back()} /> + Назад +
+ ); +} diff --git a/apps/web/components/navigation/header/index.tsx b/apps/web/components/navigation/header/index.tsx new file mode 100644 index 0000000..1dbc698 --- /dev/null +++ b/apps/web/components/navigation/header/index.tsx @@ -0,0 +1,14 @@ +'use client'; +import { BackButton } from './back-button'; +import { PageTitle } from './page-title'; + +type Props = { title: string | undefined }; + +export function PageHeader(props: Readonly) { + return ( +
+ + +
+ ); +} diff --git a/apps/web/components/navigation/header/page-title.tsx b/apps/web/components/navigation/header/page-title.tsx new file mode 100644 index 0000000..967c468 --- /dev/null +++ b/apps/web/components/navigation/header/page-title.tsx @@ -0,0 +1,5 @@ +type Props = { readonly title: string | undefined }; + +export function PageTitle(props: Readonly) { + return {props?.title}; +} diff --git a/apps/web/components/navigation/index.tsx b/apps/web/components/navigation/index.tsx index f5899d0..bb1137c 100644 --- a/apps/web/components/navigation/index.tsx +++ b/apps/web/components/navigation/index.tsx @@ -1 +1,2 @@ +export * from './header'; export * from './navbar'; diff --git a/apps/web/components/navigation/navbar.tsx b/apps/web/components/navigation/navbar/index.tsx similarity index 88% rename from apps/web/components/navigation/navbar.tsx rename to apps/web/components/navigation/navbar/index.tsx index 3ef6747..997576e 100644 --- a/apps/web/components/navigation/navbar.tsx +++ b/apps/web/components/navigation/navbar/index.tsx @@ -3,7 +3,7 @@ import { BookOpen, Newspaper, PlusCircle, User, Users } from 'lucide-react'; export function BottomNav() { return ( -