From fc64b503679cf94a2b6aab1cbb2e2c7910c1b647 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Mon, 17 Mar 2025 01:43:55 +0500 Subject: [PATCH 1/2] refactor: update navbar styling --- app/App.tsx | 2 +- app/components/Navbar/NavbarUpdate.tsx | 176 +++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 app/components/Navbar/NavbarUpdate.tsx diff --git a/app/App.tsx b/app/App.tsx index bb81fc1..e8c949c 100644 --- a/app/App.tsx +++ b/app/App.tsx @@ -1,7 +1,7 @@ "use client"; import { useUserStore } from "./store/auth"; import { usePreferencesStore } from "./store/preferences"; -import { Navbar } from "./components/Navbar/Navbar"; +import { Navbar } from "./components/Navbar/NavbarUpdate"; import { Inter } from "next/font/google"; import { useEffect, useState } from "react"; import { Button, Modal } from "flowbite-react"; diff --git a/app/components/Navbar/NavbarUpdate.tsx b/app/components/Navbar/NavbarUpdate.tsx new file mode 100644 index 0000000..98b8dcd --- /dev/null +++ b/app/components/Navbar/NavbarUpdate.tsx @@ -0,0 +1,176 @@ +"use client"; + +import Link from "next/link"; +import Image from "next/image"; +import { useUserStore } from "#/store/auth"; +import { usePathname } from "next/navigation"; +import { useState } from "react"; +import { SettingsModal } from "#/components/SettingsModal/SettingsModal"; + +export const Navbar = () => { + const pathname = usePathname(); + const userStore = useUserStore(); + const [isSettingModalOpen, setIsSettingModalOpen] = useState(false); + + const menuItems = [ + { + id: 1, + title: "Домашняя", + href: "/", + hrefInCategory: "/home", + icon: { + default: "material-symbols--home-outline", + active: "material-symbols--home", + }, + isAuthRequired: false, + isShownOnMobile: true, + }, + { + id: 2, + title: "Поиск", + href: "/search", + icon: { + default: "material-symbols--search", + active: "material-symbols--search", + }, + isAuthRequired: false, + isShownOnMobile: true, + }, + { + id: 3, + title: "Закладки", + href: "/bookmarks", + icon: { + default: "material-symbols--bookmarks-outline", + active: "material-symbols--bookmarks", + }, + isAuthRequired: true, + isShownOnMobile: true, + }, + { + id: 4, + title: "Избранное", + href: "/favorites", + icon: { + default: "material-symbols--favorite-outline", + active: "material-symbols--favorite", + }, + isAuthRequired: true, + isShownOnMobile: false, + }, + { + id: 5, + title: "Коллекции", + href: "/collections", + icon: { + default: "material-symbols--collections-bookmark-outline", + active: "material-symbols--collections-bookmark", + }, + isAuthRequired: true, + isShownOnMobile: false, + }, + { + id: 6, + title: "История", + href: "/history", + icon: { + default: "material-symbols--history", + active: "material-symbols--history", + }, + isAuthRequired: true, + isShownOnMobile: false, + }, + ]; + + return ( + <> +
+
+
+ {menuItems.map((item) => { + return ( + + + {item.title} + + ); + })} +
+
+ {!userStore.isAuth ? + + + Войти + + : <> + + + + {userStore.user.login} + + + + + + {userStore.user.login} + + + + } + + {userStore.isAuth && ( + + )} +
+
+
+ + + ); +}; From 5270c50c7ba56b66962e836ce8273d49f863de09 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Mon, 17 Mar 2025 02:34:06 +0500 Subject: [PATCH 2/2] feat: add navbar title show options --- app/components/Navbar/NavbarUpdate.tsx | 30 ++++++++++---- .../SettingsModal/SettingsModal.tsx | 39 +++++++++++++++++-- app/pages/MobileMenuPage.tsx | 6 +-- app/store/preferences.ts | 2 + 4 files changed, 62 insertions(+), 15 deletions(-) diff --git a/app/components/Navbar/NavbarUpdate.tsx b/app/components/Navbar/NavbarUpdate.tsx index 98b8dcd..9ee4d76 100644 --- a/app/components/Navbar/NavbarUpdate.tsx +++ b/app/components/Navbar/NavbarUpdate.tsx @@ -6,11 +6,13 @@ import { useUserStore } from "#/store/auth"; import { usePathname } from "next/navigation"; import { useState } from "react"; import { SettingsModal } from "#/components/SettingsModal/SettingsModal"; +import { usePreferencesStore } from "#/store/preferences"; export const Navbar = () => { const pathname = usePathname(); const userStore = useUserStore(); const [isSettingModalOpen, setIsSettingModalOpen] = useState(false); + const preferenceStore = usePreferencesStore(); const menuItems = [ { @@ -101,7 +103,11 @@ export const Navbar = () => { - {item.title} + + {item.title} + ); })} @@ -115,12 +121,16 @@ export const Navbar = () => { className={`flex items-center flex-col lg:flex-row gap-1 ${pathname == "/login" ? "font-bold" : "font-medium"}`} > - Войти + + Войти + : <> { width={24} height={24} /> - + {userStore.user.login} { width={24} height={24} /> - + {userStore.user.login} } {userStore.isAuth && ( )} diff --git a/app/components/SettingsModal/SettingsModal.tsx b/app/components/SettingsModal/SettingsModal.tsx index 6b1f976..39ae318 100644 --- a/app/components/SettingsModal/SettingsModal.tsx +++ b/app/components/SettingsModal/SettingsModal.tsx @@ -27,6 +27,13 @@ const BookmarksCategory = { abandoned: "Заброшено", }; +const NavbarTitles = { + always: "Всегда", + links: "Только ссылки", + selected: "Только выбранные", + never: "Никогда", +} + export const SettingsModal = (props: { isOpen: boolean; setIsOpen: any }) => { const preferenceStore = usePreferencesStore(); @@ -89,7 +96,7 @@ export const SettingsModal = (props: { isOpen: boolean; setIsOpen: any }) => { checked={preferenceStore.params.skipToCategory.enabled} /> - {preferenceStore.params.skipToCategory.enabled ? ( + {preferenceStore.params.skipToCategory.enabled ? <>

@@ -154,9 +161,33 @@ export const SettingsModal = (props: { isOpen: boolean; setIsOpen: any }) => {

- ) : ( - "" - )} + : ""} +
+

+ Показывать название пункта в навигации +

+ + {Object.keys(NavbarTitles).map((key: "always" | "links" | "selected" | "never") => { + return ( + + preferenceStore.setFlags({ + showNavbarTitles: key, + }) + } + > + {NavbarTitles[key]} + + ); + })} + +

diff --git a/app/pages/MobileMenuPage.tsx b/app/pages/MobileMenuPage.tsx index 450e42b..a075e2a 100644 --- a/app/pages/MobileMenuPage.tsx +++ b/app/pages/MobileMenuPage.tsx @@ -81,7 +81,7 @@ export const MenuPage = () => {
- +
{
- +
{
- +
()( saveWatchHistory: true, showChangelog: true, enableAnalytics: true, + showNavbarTitles: "always", }, params: { isFirstLaunch: true,