2022-09-09 11:53:35 +00:00
|
|
|
import { For, Show } from 'solid-js'
|
|
|
|
import type { Topic } from '../../graphql/types.gen'
|
2022-09-22 09:37:49 +00:00
|
|
|
import { Icon } from './Icon'
|
2022-09-09 11:53:35 +00:00
|
|
|
import './Topics.scss'
|
|
|
|
import { t } from '../../utils/intl'
|
|
|
|
import { locale as langstore } from '../../stores/ui'
|
|
|
|
import { useStore } from '@nanostores/solid'
|
|
|
|
|
2022-09-22 09:37:49 +00:00
|
|
|
export const NavTopics = (props: { topics: Topic[] }) => {
|
2022-09-09 11:53:35 +00:00
|
|
|
const locale = useStore(langstore)
|
2022-09-22 09:37:49 +00:00
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
const tag = (t: Topic) => (/[ЁА-яё]/.test(t.title || '') && locale() !== 'ru' ? t.slug : t.title)
|
|
|
|
|
|
|
|
// TODO: something about subtopics
|
|
|
|
return (
|
|
|
|
<nav class="subnavigation wide-container text-2xl">
|
|
|
|
<ul class="topics">
|
2022-09-22 09:37:49 +00:00
|
|
|
<Show when={props.topics.length > 0}>
|
2022-09-09 11:53:35 +00:00
|
|
|
<For each={props.topics}>
|
|
|
|
{(t: Topic) => (
|
|
|
|
<li class="item">
|
|
|
|
<a href={`/topic/${t.slug}`}>
|
|
|
|
<span>#{tag(t)}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
<li class="item right">
|
|
|
|
<a href={`/topics`}>
|
|
|
|
<span>
|
|
|
|
<Icon name="arrow-right-black" style={{ height: '12px', display: 'inline-block' }} />
|
|
|
|
<small style={{ margin: '4px' }}>{t('All topics')} </small>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</Show>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
)
|
|
|
|
}
|