Fix/main menu (#216)
* Subnavigation fixes * pass randomTopics as prop to header --------- Co-authored-by: kvakazyambra <kvakazyambra@gmail.com> Co-authored-by: ilya-bkv <i.yablokov@ccmp.me>
This commit is contained in:
parent
0e68d3db92
commit
019c4540d0
|
@ -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 { getPagePath, redirectPage } from '@nanostores/router'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import { ConfirmModal } from '../ConfirmModal'
|
||||||
import { getShareUrl, SharePopup } from '../../Article/SharePopup'
|
import { getShareUrl, SharePopup } from '../../Article/SharePopup'
|
||||||
import { Snackbar } from '../Snackbar'
|
import { Snackbar } from '../Snackbar'
|
||||||
import { Icon } from '../../_shared/Icon'
|
import { Icon } from '../../_shared/Icon'
|
||||||
|
import type { Topic } from '../../../graphql/types.gen'
|
||||||
|
|
||||||
import { useModalStore } from '../../../stores/ui'
|
import { useModalStore } from '../../../stores/ui'
|
||||||
import { router, useRouter } from '../../../stores/router'
|
import { router, useRouter } from '../../../stores/router'
|
||||||
|
@ -17,6 +18,7 @@ import { getDescription } from '../../../utils/meta'
|
||||||
|
|
||||||
import { useLocalize } from '../../../context/localize'
|
import { useLocalize } from '../../../context/localize'
|
||||||
import { useSession } from '../../../context/session'
|
import { useSession } from '../../../context/session'
|
||||||
|
import { useTopicsStore } from '../../../stores/zine/topics'
|
||||||
|
|
||||||
import styles from './Header.module.scss'
|
import styles from './Header.module.scss'
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ type Props = {
|
||||||
articleBody?: string
|
articleBody?: string
|
||||||
cover?: string
|
cover?: string
|
||||||
scrollToComments?: (value: boolean) => void
|
scrollToComments?: (value: boolean) => void
|
||||||
|
randomTopics?: Topic[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeaderSearchParams = {
|
type HeaderSearchParams = {
|
||||||
|
@ -34,7 +37,7 @@ type HeaderSearchParams = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Header = (props: Props) => {
|
export const Header = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t, lang } = useLocalize()
|
||||||
|
|
||||||
const { modal } = useModalStore()
|
const { modal } = useModalStore()
|
||||||
|
|
||||||
|
@ -56,6 +59,9 @@ export const Header = (props: Props) => {
|
||||||
|
|
||||||
const toggleFixed = () => setFixed((oldFixed) => !oldFixed)
|
const toggleFixed = () => setFixed((oldFixed) => !oldFixed)
|
||||||
|
|
||||||
|
const tag = (topic: Topic) =>
|
||||||
|
/[ЁА-яё]/.test(topic.title || '') && lang() !== 'ru' ? topic.slug : topic.title
|
||||||
|
|
||||||
let windowScrollTop = 0
|
let windowScrollTop = 0
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
@ -296,34 +302,25 @@ export const Header = (props: Props) => {
|
||||||
>
|
>
|
||||||
<ul class="nodash">
|
<ul class="nodash">
|
||||||
<li>
|
<li>
|
||||||
<a href="/expo/image">Искусство</a>
|
<a href="/topic/interview">#Интервью</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">Подкасты</a>
|
<a href="/topic/reportage">#Репортажи</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">Спецпроекты</a>
|
<a href="/topic/empiric">#Личный опыт</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">#Интервью</a>
|
<a href="/topic/society">#Общество</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">#Репортажи</a>
|
<a href="/topic/culture">#Культура</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">#Личный опыт</a>
|
<a href="/topic/theory">#Теории</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="">#Общество</a>
|
<a href="/topic/poetry">#Поэзия</a>
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Культура</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Теории</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Поэзия</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li class={styles.rightItem}>
|
<li class={styles.rightItem}>
|
||||||
<a href="/topics">
|
<a href="/topics">
|
||||||
|
@ -341,36 +338,23 @@ export const Header = (props: Props) => {
|
||||||
onMouseOut={hideSubnavigation}
|
onMouseOut={hideSubnavigation}
|
||||||
>
|
>
|
||||||
<ul class="nodash">
|
<ul class="nodash">
|
||||||
<li>
|
<Show when={props.randomTopics && props.randomTopics.length > 0}>
|
||||||
<a href="">#Интервью</a>
|
<For each={props.randomTopics}>
|
||||||
</li>
|
{(topic) => (
|
||||||
<li>
|
<li class="item">
|
||||||
<a href="">#Репортажи</a>
|
<a href={`/topic/${topic.slug}`}>
|
||||||
</li>
|
<span>#{tag(topic)}</span>
|
||||||
<li>
|
</a>
|
||||||
<a href="">#Личный опыт</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Общество</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Культура</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Теории</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Поэзия</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="">#Теории</a>
|
|
||||||
</li>
|
</li>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
<li class={styles.rightItem}>
|
<li class={styles.rightItem}>
|
||||||
<a href="/topics">
|
<a href="/topics">
|
||||||
{t('All topics')}
|
{t('All topics')}
|
||||||
<Icon name="arrow-right-black" class={clsx(styles.icon, styles.rightItemIcon)} />
|
<Icon name="arrow-right-black" class={clsx(styles.icon, styles.rightItemIcon)} />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
</Show>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
.subnavigation {
|
.subnavigation {
|
||||||
@include font-size(1.4rem);
|
@include font-size(1.4rem);
|
||||||
|
|
||||||
height: 6rem;
|
height: 6rem;
|
||||||
line-height: 6rem;
|
line-height: 6rem;
|
||||||
margin-bottom: 5rem !important;
|
margin-bottom: 5rem !important;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
|
||||||
@include media-breakpoint-down(sm) {
|
@include media-breakpoint-down(sm) {
|
||||||
padding: 0 divide($container-padding-x, 2);
|
padding: 0 divide($container-padding-x, 2);
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
margin-right: 2rem;
|
margin-right: 2.4rem;
|
||||||
|
|
||||||
&.right {
|
&.right {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
|
|
@ -9,34 +9,25 @@ export const NavTopics = () => {
|
||||||
<nav class="subnavigation wide-container text-2xl">
|
<nav class="subnavigation wide-container text-2xl">
|
||||||
<ul class="topics">
|
<ul class="topics">
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="/expo/image">Искусство</a>
|
<a href="/topic/interview">#Интервью</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">Подкасты</a>
|
<a href="/topic/reportage">#Репортажи</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">Спецпроекты</a>
|
<a href="/topic/empiric">#Личный опыт</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">#Интервью</a>
|
<a href="/topic/society">#Общество</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">#Репортажи</a>
|
<a href="/topic/culture">#Культура</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">#Личный опыт</a>
|
<a href="/topic/theory">#Теории</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<a href="">#Общество</a>
|
<a href="/topic/poetry">#Поэзия</a>
|
||||||
</li>
|
|
||||||
<li class="item">
|
|
||||||
<a href="">#Культура</a>
|
|
||||||
</li>
|
|
||||||
<li class="item">
|
|
||||||
<a href="">#Теории</a>
|
|
||||||
</li>
|
|
||||||
<li class="item">
|
|
||||||
<a href="">#Поэзия</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="item right">
|
<li class="item right">
|
||||||
<a href={`/topics`}>
|
<a href={`/topics`}>
|
||||||
|
|
|
@ -46,7 +46,8 @@ export const HomeView = (props: HomeProps) => {
|
||||||
} = useArticlesStore({
|
} = useArticlesStore({
|
||||||
shouts: props.shouts
|
shouts: props.shouts
|
||||||
})
|
})
|
||||||
const { randomTopics, topTopics } = useTopicsStore({
|
|
||||||
|
const { topTopics } = useTopicsStore({
|
||||||
randomTopics: props.randomTopics
|
randomTopics: props.randomTopics
|
||||||
})
|
})
|
||||||
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
|
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { clsx } from 'clsx'
|
||||||
import '../../styles/app.scss'
|
import '../../styles/app.scss'
|
||||||
import styles from './PageLayout.module.scss'
|
import styles from './PageLayout.module.scss'
|
||||||
import { Meta } from '@solidjs/meta'
|
import { Meta } from '@solidjs/meta'
|
||||||
|
import { Topic } from '../../graphql/types.gen'
|
||||||
|
|
||||||
type PageLayoutProps = {
|
type PageLayoutProps = {
|
||||||
headerTitle?: string
|
headerTitle?: string
|
||||||
|
@ -19,6 +20,7 @@ type PageLayoutProps = {
|
||||||
class?: string
|
class?: string
|
||||||
withPadding?: boolean
|
withPadding?: boolean
|
||||||
scrollToComments?: (value: boolean) => void
|
scrollToComments?: (value: boolean) => void
|
||||||
|
randomTopics?: Topic[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PageLayout = (props: PageLayoutProps) => {
|
export const PageLayout = (props: PageLayoutProps) => {
|
||||||
|
@ -30,7 +32,7 @@ export const PageLayout = (props: PageLayoutProps) => {
|
||||||
props.scrollToComments(scrollToComments())
|
props.scrollToComments(scrollToComments())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// const { randomTopics } = useTopicsStore()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Meta name="viewport" content="width=device-width, initial-scale=1" />
|
<Meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
@ -41,6 +43,7 @@ export const PageLayout = (props: PageLayoutProps) => {
|
||||||
cover={props.articleBody}
|
cover={props.articleBody}
|
||||||
isHeaderFixed={isHeaderFixed}
|
isHeaderFixed={isHeaderFixed}
|
||||||
scrollToComments={(value) => setScrollToComments(value)}
|
scrollToComments={(value) => setScrollToComments(value)}
|
||||||
|
randomTopics={props.randomTopics}
|
||||||
/>
|
/>
|
||||||
<main
|
<main
|
||||||
class={clsx('main-content', {
|
class={clsx('main-content', {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export const HomePage = (props: PageProps) => {
|
||||||
onCleanup(() => resetSortedArticles())
|
onCleanup(() => resetSortedArticles())
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout withPadding={true}>
|
<PageLayout randomTopics={props.randomTopics} withPadding={true}>
|
||||||
<ReactionsProvider>
|
<ReactionsProvider>
|
||||||
<Title>{t('Discours')}</Title>
|
<Title>{t('Discours')}</Title>
|
||||||
<Show when={isLoaded()} fallback={<Loading />}>
|
<Show when={isLoaded()} fallback={<Loading />}>
|
||||||
|
|
|
@ -633,11 +633,6 @@ figure {
|
||||||
border-bottom: 2px solid #000;
|
border-bottom: 2px solid #000;
|
||||||
color: #000;
|
color: #000;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
pointer-events: none;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user