webapp/src/components/Feed/Group.tsx

84 lines
2.7 KiB
TypeScript
Raw Normal View History

2022-10-07 19:35:53 +00:00
import type { JSX } from 'solid-js/jsx-runtime'
2022-09-09 11:53:35 +00:00
import { For, Show } from 'solid-js/web'
import type { Shout } from '../../graphql/types.gen'
import { ArticleCard } from './Card'
import './Group.scss'
interface GroupProps {
articles: Shout[]
2022-10-07 19:35:53 +00:00
header?: JSX.Element
2022-09-09 11:53:35 +00:00
}
export default (props: GroupProps) => {
if (!props.articles) props.articles = []
return (
2022-10-19 14:26:49 +00:00
<div class="floor floor--important floor--group">
2022-09-09 11:53:35 +00:00
<Show when={props.articles.length > 4}>
<div class="wide-container row">
<div class="group__header col-12">{props.header}</div>
<div class="col-lg-6">
2022-10-19 14:26:49 +00:00
<ArticleCard
article={props.articles[0]}
settings={{ nosubtitle: false, noicon: true, isFloorImportant: true, isBigTitle: true }}
/>
2022-09-09 11:53:35 +00:00
</div>
<div class="col-lg-6">
<div class="row">
<Show when={props.articles.length < 4}>
<For each={props.articles.slice(1, props.articles.length)}>
{(a) => (
<div class="row">
<div class="col-md-8">
2022-10-19 14:26:49 +00:00
<ArticleCard
article={a}
settings={{ nosubtitle: false, noicon: true, isBigTitle: true }}
/>
2022-09-09 11:53:35 +00:00
</div>
</div>
)}
</For>
</Show>
<Show when={props.articles.length >= 4}>
<div class="col-md-6">
<For each={props.articles.slice(1, 3)}>
2022-10-19 14:26:49 +00:00
{(a) => (
<ArticleCard
article={a}
settings={{
noicon: true,
noimage: true,
isBigTitle: true,
isCompact: true,
isFloorImportant: true
}}
/>
)}
2022-09-09 11:53:35 +00:00
</For>
</div>
<div class="col-md-6">
<For each={props.articles.slice(3, 5)}>
2022-10-19 14:26:49 +00:00
{(a) => (
<ArticleCard
article={a}
settings={{
noicon: true,
noimage: true,
isBigTitle: true,
isCompact: true,
isFloorImportant: true
}}
/>
)}
2022-09-09 11:53:35 +00:00
</For>
</div>
</Show>
</div>
</div>
</div>
</Show>
</div>
)
}