diff --git a/src/components/Author/Userpic/Userpic.module.scss b/src/components/Author/Userpic/Userpic.module.scss index 7e3d1edd..ea1ffa0e 100644 --- a/src/components/Author/Userpic/Userpic.module.scss +++ b/src/components/Author/Userpic/Userpic.module.scss @@ -98,7 +98,3 @@ max-width: 16px; } } - -.cursorPointer { - cursor: pointer; -} diff --git a/src/components/Author/Userpic/Userpic.tsx b/src/components/Author/Userpic/Userpic.tsx index 077109a5..ef0f1fdb 100644 --- a/src/components/Author/Userpic/Userpic.tsx +++ b/src/components/Author/Userpic/Userpic.tsx @@ -32,7 +32,7 @@ export const Userpic = (props: Props) => { [styles.big]: props.isBig, [styles.authorsList]: props.isAuthorsList, [styles.feedMode]: props.isFeedMode, - [styles.cursorPointer]: props.onClick + ['cursorPointer']: props.onClick })} onClick={props.onClick} > diff --git a/src/components/Nav/Header/Header.tsx b/src/components/Nav/Header/Header.tsx index e58c08ef..4c320036 100644 --- a/src/components/Nav/Header/Header.tsx +++ b/src/components/Nav/Header/Header.tsx @@ -22,6 +22,7 @@ import { useSession } from '../../../context/session' import styles from './Header.module.scss' import { apiClient } from '../../../utils/apiClient' import { RANDOM_TOPICS_COUNT } from '../../Views/Home' +import { Link } from './Link' type Props = { title?: string @@ -135,7 +136,7 @@ export const Header = (props: Props) => { clearTimeout(timer) } - const hideSubnavigation = (ev, time = 500) => { + const hideSubnavigation = (event, time = 500) => { timer = setTimeout(() => { toggleSubnavigation(false) }, time) @@ -193,44 +194,32 @@ export const Header = (props: Props) => { {t('zine')} -
  • - toggleSubnavigation(true, setIsFeedVisible)} - onMouseOut={hideSubnavigation} - href={getPagePath(router, 'feed')} - > - {t('feed')} - -
  • -
  • - toggleSubnavigation(true, setIsTopicsVisible)} - onMouseOut={hideSubnavigation} - href={getPagePath(router, 'topics')} - > - {t('topics')} - -
  • -
  • - hideSubnavigation(ev, 0)} - onMouseOut={(ev) => hideSubnavigation(ev, 0)} - href={getPagePath(router, 'authors')} - > - {t('community')} - -
  • -
  • - toggleSubnavigation(true, setIsKnowledgeBaseVisible)} - onMouseOut={hideSubnavigation} - > - {t('Knowledge base')} - -
  • + toggleSubnavigation(true, setIsFeedVisible)} + onMouseOut={() => hideSubnavigation} + routeName="feed" + active={isFeedVisible()} + body={t('feed')} + /> + toggleSubnavigation(true, setIsTopicsVisible)} + onMouseOut={() => hideSubnavigation} + routeName="topics" + active={isFeedVisible()} + body={t('topics')} + /> + hideSubnavigation(event, 0)} + onMouseOut={(event) => hideSubnavigation(event, 0)} + routeName="authors" + body={t('authors')} + /> + toggleSubnavigation(true, setIsKnowledgeBaseVisible)} + onMouseOut={() => hideSubnavigation} + body={t('Knowledge base')} + active={isKnowledgeBaseVisible()} + />
    diff --git a/src/components/Nav/Header/Link.tsx b/src/components/Nav/Header/Link.tsx new file mode 100644 index 00000000..f07dad09 --- /dev/null +++ b/src/components/Nav/Header/Link.tsx @@ -0,0 +1,34 @@ +import styles from './Header.module.scss' +import { router, ROUTES, useRouter } from '../../../stores/router' +import { clsx } from 'clsx' +import { ConditionalWrapper } from '../../_shared/ConditionalWrapper' +import { getPagePath } from '@nanostores/router' + +type Props = { + onMouseOver: (event?: MouseEvent, time?: number) => void + onMouseOut: (event?: MouseEvent, time?: number) => void + routeName?: keyof typeof ROUTES + body: string + active?: boolean +} + +export const Link = (props: Props) => { + const { page } = useRouter() + const isSelected = page().route === props.routeName + return ( +
  • + {children}} + > + + {props.body} + + +
  • + ) +} diff --git a/src/styles/app.scss b/src/styles/app.scss index d6743a6b..3b31a1fb 100644 --- a/src/styles/app.scss +++ b/src/styles/app.scss @@ -987,3 +987,7 @@ iframe { font-weight: bold; line-height: 1.5; } + +.cursorPointer { + cursor: pointer; +}