webapp/src/components/Feed/Beside.tsx

117 lines
4.4 KiB
TypeScript
Raw Normal View History

2022-09-09 11:53:35 +00:00
// TODO: additional entities list column + article
2022-10-31 16:40:55 +00:00
import { For, Show } from 'solid-js'
2023-05-01 18:32:32 +00:00
import { ArticleCard } from './ArticleCard'
import { AuthorCard } from '../Author/AuthorCard'
2022-09-09 11:53:35 +00:00
import { TopicCard } from '../Topic/Card'
2022-11-16 21:08:04 +00:00
import styles from './Beside.module.scss'
2022-09-09 11:53:35 +00:00
import type { Author, Shout, Topic, User } from '../../graphql/types.gen'
2022-11-14 17:41:05 +00:00
import { Icon } from '../_shared/Icon'
2023-02-17 09:21:02 +00:00
2022-11-16 21:08:04 +00:00
import { clsx } from 'clsx'
2023-02-17 09:21:02 +00:00
import { useLocalize } from '../../context/localize'
2022-09-09 11:53:35 +00:00
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
2023-01-24 22:15:29 +00:00
nodate?: boolean
2022-09-09 11:53:35 +00:00
}
export const Beside = (props: BesideProps) => {
2023-02-17 09:21:02 +00:00
const { t } = useLocalize()
2022-09-09 11:53:35 +00:00
return (
<Show when={!!props.beside?.slug && props.values?.length > 0}>
<div class="floor floor--9">
2022-11-20 21:23:12 +00:00
<div class="wide-container">
<div class="row justify-content-between">
2022-11-20 21:23:12 +00:00
<Show when={!!props.values}>
2023-06-02 22:01:34 +00:00
<div
class={clsx(
'col-md-8',
styles[
`besideRatingColumn${props.wrapper.charAt(0).toUpperCase() + props.wrapper.slice(1)}`
]
)}
>
2022-11-20 21:23:12 +00:00
<Show when={!!props.title}>
<div class={styles.besideColumnTitle}>
<h4>{props.title}</h4>
2022-09-09 11:53:35 +00:00
2022-11-20 21:23:12 +00:00
<Show when={props.wrapper === 'author'}>
<a href="/authors">
{t('All authors')}
2022-12-04 15:10:27 +00:00
<Icon name="arrow-right" class={styles.icon} />
2022-11-20 21:23:12 +00:00
</a>
</Show>
2022-11-16 21:08:04 +00:00
2022-11-20 21:23:12 +00:00
<Show when={props.wrapper === 'topic'}>
<a href="/topics">
{t('All topics')}
2022-12-04 15:10:27 +00:00
<Icon name="arrow-right" class={styles.icon} />
2022-11-20 21:23:12 +00:00
</a>
</Show>
</div>
</Show>
<ul class={styles.besideColumn}>
<For each={[...props.values]}>
{(value: Partial<Shout | User | Topic>) => (
<li classList={{ [styles.top]: props.wrapper.startsWith('top-') }}>
<Show when={props.wrapper === 'topic'}>
<TopicCard
topic={value as Topic}
compact={props.isTopicCompact}
shortDescription={props.topicShortDescription}
isTopicInRow={props.isTopicInRow}
iconButton={props.iconButton}
showPublications={true}
2023-06-05 20:46:55 +00:00
isCardMode={true}
2022-11-20 21:23:12 +00:00
/>
</Show>
<Show when={props.wrapper === 'author'}>
<AuthorCard
author={value as Author}
hideWriteButton={true}
2022-11-20 21:23:12 +00:00
hasLink={true}
truncateBio={true}
2023-06-02 22:01:34 +00:00
isTextButton={true}
class={styles.author}
2022-11-20 21:23:12 +00:00
/>
</Show>
<Show when={props.wrapper === 'article' && value?.slug}>
2023-01-24 22:15:29 +00:00
<ArticleCard
article={value as Shout}
settings={{ noimage: true, nodate: props.nodate }}
/>
2022-11-20 21:23:12 +00:00
</Show>
<Show when={props.wrapper === 'top-article' && value?.slug}>
<ArticleCard
article={value as Shout}
settings={{ noimage: true, noauthor: true, nodate: true, isShort: true }}
/>
</Show>
</li>
)}
</For>
</ul>
</div>
</Show>
2023-07-18 21:50:27 +00:00
<div class={clsx('col-md-16', styles.shoutCardContainer)}>
2023-01-24 22:15:29 +00:00
<ArticleCard
article={props.beside}
settings={{ isBigTitle: true, isBeside: true, nodate: props.nodate }}
/>
2022-09-09 11:53:35 +00:00
</div>
</div>
</div>
</div>
</Show>
)
}