From 019c4540d020d5139f4726e88a865000817318a5 Mon Sep 17 00:00:00 2001 From: Kosta <47947996+dobrodob@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:40:46 +0300 Subject: [PATCH] Fix/main menu (#216) * Subnavigation fixes * pass randomTopics as prop to header --------- Co-authored-by: kvakazyambra Co-authored-by: ilya-bkv --- src/components/Nav/Header/Header.tsx | 80 +++++++++++---------------- src/components/Nav/Topics.scss | 4 +- src/components/Nav/Topics.tsx | 23 +++----- src/components/Views/Home.tsx | 3 +- src/components/_shared/PageLayout.tsx | 5 +- src/pages/index.page.tsx | 2 +- src/styles/app.scss | 5 -- 7 files changed, 48 insertions(+), 74 deletions(-) diff --git a/src/components/Nav/Header/Header.tsx b/src/components/Nav/Header/Header.tsx index b16f8697..cf0d8e95 100644 --- a/src/components/Nav/Header/Header.tsx +++ b/src/components/Nav/Header/Header.tsx @@ -1,4 +1,4 @@ -import { Show, createSignal, createEffect, onMount, onCleanup } from 'solid-js' +import { For, Show, createSignal, createEffect, onMount, onCleanup } from 'solid-js' import { getPagePath, redirectPage } from '@nanostores/router' import { clsx } from 'clsx' @@ -9,6 +9,7 @@ import { ConfirmModal } from '../ConfirmModal' import { getShareUrl, SharePopup } from '../../Article/SharePopup' import { Snackbar } from '../Snackbar' import { Icon } from '../../_shared/Icon' +import type { Topic } from '../../../graphql/types.gen' import { useModalStore } from '../../../stores/ui' import { router, useRouter } from '../../../stores/router' @@ -17,6 +18,7 @@ import { getDescription } from '../../../utils/meta' import { useLocalize } from '../../../context/localize' import { useSession } from '../../../context/session' +import { useTopicsStore } from '../../../stores/zine/topics' import styles from './Header.module.scss' @@ -27,6 +29,7 @@ type Props = { articleBody?: string cover?: string scrollToComments?: (value: boolean) => void + randomTopics?: Topic[] } type HeaderSearchParams = { @@ -34,7 +37,7 @@ type HeaderSearchParams = { } export const Header = (props: Props) => { - const { t } = useLocalize() + const { t, lang } = useLocalize() const { modal } = useModalStore() @@ -56,6 +59,9 @@ export const Header = (props: Props) => { const toggleFixed = () => setFixed((oldFixed) => !oldFixed) + const tag = (topic: Topic) => + /[ЁА-яё]/.test(topic.title || '') && lang() !== 'ru' ? topic.slug : topic.title + let windowScrollTop = 0 createEffect(() => { @@ -296,34 +302,25 @@ export const Header = (props: Props) => { >