2022-09-09 11:53:35 +00:00
|
|
|
// TODO: additional entities list column + article
|
|
|
|
|
|
|
|
import { For, Show } from 'solid-js/web'
|
|
|
|
import { ArticleCard } from './Card'
|
|
|
|
import { AuthorCard } from '../Author/Card'
|
|
|
|
import { TopicCard } from '../Topic/Card'
|
2022-10-19 14:26:49 +00:00
|
|
|
import style from './Beside.module.scss'
|
2022-09-09 11:53:35 +00:00
|
|
|
import type { Author, Shout, Topic, User } from '../../graphql/types.gen'
|
2022-09-22 09:37:49 +00:00
|
|
|
import { Icon } from '../Nav/Icon'
|
2022-09-09 11:53:35 +00:00
|
|
|
import { t } from '../../utils/intl'
|
|
|
|
|
|
|
|
interface BesideProps {
|
2022-09-29 14:40:11 +00:00
|
|
|
title?: string
|
2022-10-07 19:35:53 +00:00
|
|
|
values: (Shout | User | Topic | Author)[]
|
2022-09-09 11:53:35 +00:00
|
|
|
beside: Shout
|
|
|
|
wrapper: 'topic' | 'author' | 'article' | 'top-article'
|
|
|
|
isTopicCompact?: boolean
|
2022-10-19 14:26:49 +00:00
|
|
|
isTopicInRow?: boolean
|
2022-09-09 11:53:35 +00:00
|
|
|
topicShortDescription?: boolean
|
|
|
|
topicsBySlug?: { [slug: string]: Topic }
|
2022-10-19 14:26:49 +00:00
|
|
|
iconButton?: boolean
|
2022-09-09 11:53:35 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 21:21:47 +00:00
|
|
|
export const Beside = (props: BesideProps) => {
|
2022-09-09 11:53:35 +00:00
|
|
|
return (
|
|
|
|
<Show when={!!props.beside?.slug && props.values?.length > 0}>
|
|
|
|
<div class="floor floor--9">
|
|
|
|
<div class="wide-container row">
|
|
|
|
<Show when={!!props.values}>
|
|
|
|
<div class="col-md-4">
|
|
|
|
<Show when={!!props.title}>
|
2022-10-19 14:26:49 +00:00
|
|
|
<div class={style.besideColumnTitle}>
|
2022-09-09 11:53:35 +00:00
|
|
|
<h4>{props.title}</h4>
|
|
|
|
|
|
|
|
<Show when={props.wrapper === 'author'}>
|
|
|
|
<a href="/user/list">
|
|
|
|
{t('All authors')}
|
|
|
|
<Icon name="arrow-right" />
|
|
|
|
</a>
|
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
</Show>
|
2022-10-19 14:26:49 +00:00
|
|
|
<ul class={style.besideColumn}>
|
2022-09-09 11:53:35 +00:00
|
|
|
<For each={[...props.values]}>
|
|
|
|
{(value: Partial<Shout | User | Topic>) => (
|
2022-10-19 14:26:49 +00:00
|
|
|
<li classList={{ [style.top]: props.wrapper.startsWith('top-') }}>
|
2022-09-09 11:53:35 +00:00
|
|
|
<Show when={props.wrapper === 'topic'}>
|
|
|
|
<TopicCard
|
|
|
|
topic={value as Topic}
|
|
|
|
compact={props.isTopicCompact}
|
|
|
|
shortDescription={props.topicShortDescription}
|
2022-10-19 14:26:49 +00:00
|
|
|
isTopicInRow={props.isTopicInRow}
|
|
|
|
iconButton={props.iconButton}
|
2022-09-09 11:53:35 +00:00
|
|
|
/>
|
|
|
|
</Show>
|
|
|
|
<Show when={props.wrapper === 'author'}>
|
|
|
|
<AuthorCard author={value as Author} compact={true} hasLink={true} />
|
|
|
|
</Show>
|
|
|
|
<Show when={props.wrapper === 'article' && value?.slug}>
|
|
|
|
<ArticleCard article={value as Shout} settings={{ noimage: true }} />
|
|
|
|
</Show>
|
|
|
|
<Show when={props.wrapper === 'top-article' && value?.slug}>
|
|
|
|
<ArticleCard
|
|
|
|
article={value as Shout}
|
2022-10-19 14:26:49 +00:00
|
|
|
settings={{ noimage: true, noauthor: true, nodate: true, isShort: true }}
|
2022-09-09 11:53:35 +00:00
|
|
|
/>
|
|
|
|
</Show>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
<div class="col-md-8">
|
2022-10-19 14:26:49 +00:00
|
|
|
<ArticleCard article={props.beside} settings={{ isBigTitle: true }} />
|
2022-09-09 11:53:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
)
|
|
|
|
}
|