2023-11-28 13:18:25 +00:00
|
|
|
import type { Shout } from '../../graphql/schema/core.gen'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2024-01-31 12:34:15 +00:00
|
|
|
import { createSignal, createEffect, For, Show } from 'solid-js'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-05-01 18:32:32 +00:00
|
|
|
import { ArticleCard } from './ArticleCard'
|
2022-10-28 21:21:47 +00:00
|
|
|
|
2024-01-31 12:34:15 +00:00
|
|
|
const columnSizes = ['col-md-12', 'col-md-8', 'col-md-16']
|
2022-09-09 11:53:35 +00:00
|
|
|
|
2023-07-26 20:40:14 +00:00
|
|
|
export const Row2 = (props: {
|
|
|
|
articles: Shout[]
|
|
|
|
isEqual?: boolean
|
|
|
|
nodate?: boolean
|
|
|
|
noAuthorLink?: boolean
|
2023-10-10 19:45:35 +00:00
|
|
|
noauthor?: boolean
|
2023-07-26 20:40:14 +00:00
|
|
|
}) => {
|
2024-01-31 12:34:15 +00:00
|
|
|
const [columnIndex, setColumnIndex] = createSignal(0)
|
2022-09-09 11:53:35 +00:00
|
|
|
|
2024-01-31 12:34:15 +00:00
|
|
|
// Update column index on component mount
|
|
|
|
createEffect(() => setColumnIndex(Math.floor(Math.random() * columnSizes.length)))
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
return (
|
2023-08-12 10:36:21 +00:00
|
|
|
<Show when={props.articles && props.articles.length > 0}>
|
|
|
|
<div class="floor">
|
|
|
|
<div class="wide-container">
|
|
|
|
<div class="row">
|
|
|
|
<For each={props.articles}>
|
2024-01-31 12:34:15 +00:00
|
|
|
{(article, _idx) => {
|
|
|
|
const className = columnSizes[props.isEqual ? 0 : columnIndex() % columnSizes.length]
|
|
|
|
const big = className === 'col-md-12' ? 'M' : 'L'
|
|
|
|
const desktopCoverSize = className === 'col-md-8' ? 'S' : big
|
2023-08-12 10:36:21 +00:00
|
|
|
return (
|
2023-11-18 14:10:02 +00:00
|
|
|
<div class={className}>
|
|
|
|
<ArticleCard
|
2024-01-31 12:34:15 +00:00
|
|
|
article={article}
|
2023-11-18 14:10:02 +00:00
|
|
|
settings={{
|
2024-01-31 12:34:15 +00:00
|
|
|
isWithCover: props.isEqual || className === 'col-md-16',
|
2023-11-18 14:10:02 +00:00
|
|
|
nodate: props.isEqual || props.nodate,
|
|
|
|
noAuthorLink: props.noAuthorLink,
|
|
|
|
noauthor: props.noauthor,
|
|
|
|
}}
|
|
|
|
desktopCoverSize={desktopCoverSize}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-08-12 10:36:21 +00:00
|
|
|
)
|
|
|
|
}}
|
|
|
|
</For>
|
|
|
|
</div>
|
2022-11-20 21:23:12 +00:00
|
|
|
</div>
|
2022-09-09 11:53:35 +00:00
|
|
|
</div>
|
2023-08-12 10:36:21 +00:00
|
|
|
</Show>
|
2022-09-09 11:53:35 +00:00
|
|
|
)
|
|
|
|
}
|