From 5270c50c7ba56b66962e836ce8273d49f863de09 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Mon, 17 Mar 2025 02:34:06 +0500 Subject: [PATCH] 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,