From a3bd954f7fa0510fa34a64266a885bb0d754b7ba Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 27 Nov 2023 12:48:01 +0100 Subject: [PATCH] feat(header): add settings header, add settings view util --- src/components/header/header.tsx | 10 ++++++++-- src/lib/utils/view-utils.ts | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/header/header.tsx b/src/components/header/header.tsx index 4028ea5e..1dc306b6 100644 --- a/src/components/header/header.tsx +++ b/src/components/header/header.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { Link, useLocation, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useSubplebbit } from '@plebbit/plebbit-react-hooks'; -import { isAboutView, isHomeView, isPostView, isSubplebbitView, isSubmitView, isSubplebbitSubmitView } from '../../lib/utils/view-utils'; +import { isAboutView, isHomeView, isPostView, isSettingsView, isSubplebbitView, isSubmitView, isSubplebbitSubmitView } from '../../lib/utils/view-utils'; import useTheme from '../../hooks/use-theme'; import styles from './header.module.css'; import AccountBar from './account-bar'; @@ -19,13 +19,16 @@ const Header = () => { const sortLabels = [t('header_hot'), t('header_new'), t('header_active'), t('header_controversial'), t('header_top')]; const subplebbit = useSubplebbit({ subplebbitAddress: params.subplebbitAddress }); const { suggested, title, shortAddress } = subplebbit || {}; + const isAbout = isAboutView(location.pathname); const isHome = isHomeView(location.pathname); const isPost = isPostView(location.pathname, params); + const isSettings = isSettingsView(location.pathname); const isSubplebbit = isSubplebbitView(location.pathname, params); const isSubmit = isSubmitView(location.pathname); const isSubplebbitSubmit = isSubplebbitSubmitView(location.pathname, params); - const fewTabs = isPost || isSubmit || isSubplebbitSubmit; + + const fewTabs = isPost || isSubmit || isSubplebbitSubmit || isSettings; const logoSrc = isSubplebbit ? suggested?.avatarUrl : '/assets/logo/seedit.png'; const logoIsAvatar = isSubplebbit && suggested?.avatarUrl; @@ -62,6 +65,7 @@ const Header = () => { ); + let headerTabs; if (isPost) { @@ -84,6 +88,8 @@ const Header = () => { headerTitle = subplebbitTitle; } else if (isSubmit) { headerTitle = submitTitle; + } else if (isSettings) { + headerTitle = t('preferences'); } let aboutLink; diff --git a/src/lib/utils/view-utils.ts b/src/lib/utils/view-utils.ts index 4c40138b..bec2c4ad 100644 --- a/src/lib/utils/view-utils.ts +++ b/src/lib/utils/view-utils.ts @@ -24,6 +24,10 @@ export const isPostView = (pathname: string, params: ParamsType): boolean => { return params.subplebbitAddress && params.commentCid ? pathname.startsWith(`/p/${params.subplebbitAddress}/c/${params.commentCid}`) : false; }; +export const isSettingsView = (pathname: string): boolean => { + return pathname === '/settings'; +} + export const isSubmitView = (pathname: string): boolean => { return pathname === '/submit'; };