Skip to content

Commit 638d171

Browse files
committed
refactor: carousel improvements
1 parent 466b340 commit 638d171

2 files changed

Lines changed: 33 additions & 38 deletions

File tree

src/routes/[network]/(homepage)/components/articles.svelte

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,63 +18,56 @@
1818
const onPrevious = () => (index = (index - 1 + articles.length) % articles.length);
1919
</script>
2020

21-
<section
22-
id="articles"
23-
class="@container col-span-full grid *:col-span-full *:col-start-1 *:row-start-1"
24-
>
21+
<section id="articles" class="@container grid gap-y-6">
2522
{#each articles as article, i}
2623
{#key article.slug}
27-
<div
28-
class:sr-only={i !== index}
29-
class="grid min-h-72 grid-cols-2 items-center gap-8 rounded-2xl @3xl:grid-cols-[auto_1fr_1fr_auto] @3xl:gap-y-10"
30-
>
31-
<IconButton
32-
icon={ChevronLeft}
33-
size="large"
34-
class="text-muted col-start-1 row-start-3 @3xl:row-start-1"
35-
onclick={onPrevious}
36-
/>
24+
<div class:sr-only={i !== index} class="grid min-h-72 grid-cols-2 gap-8 rounded-2xl">
3725
<div class="col-span-full grid place-items-center @3xl:col-span-1">
3826
<a href={article.slug}>
3927
{#key article.thumbnail}
4028
<img
4129
src={article.thumbnail}
4230
alt={article.title}
43-
class="rounded-2xl"
31+
class="h-[288px] rounded-2xl object-cover"
4432
width="512"
4533
height="288"
4634
/>
4735
{/key}
4836
</a>
4937
</div>
50-
<div class="col-span-full grid place-items-center @3xl:col-span-1">
51-
<TextBlock title={article.title} text={article.description}>
38+
39+
<div class="col-span-full grid place-items-center @3xl:col-span-1 @3xl:justify-start">
40+
<TextBlock class="max-w-lg" title={article.title} text={article.description}>
5241
<Button variant="primary" href={article.slug}>
5342
{m.common_read_more()}
5443
</Button>
5544
</TextBlock>
5645
</div>
57-
<IconButton
58-
icon={ChevronRight}
59-
size="large"
60-
class="text-muted col-start-2 row-start-3 justify-self-end @3xl:col-start-4 @3xl:row-start-1"
61-
onclick={onNext}
62-
/>
63-
64-
<div
65-
class="col-span-full col-start-1 row-start-3 flex items-center justify-center gap-2 @3xl:row-start-2"
66-
>
67-
{#each articles as article, i}
68-
<button onclick={() => (index = i)}>
69-
<Circle
70-
id={article.slug}
71-
aria-selected={i === index}
72-
class="stroke-on-background aria-selected:fill-on-background size-2"
73-
/>
74-
</button>
75-
{/each}
76-
</div>
7746
</div>
7847
{/key}
7948
{/each}
49+
50+
<div class="flex items-center justify-center gap-2">
51+
<IconButton
52+
icon={ChevronLeft}
53+
size="large"
54+
class="text-muted col-start-1 row-start-3 @3xl:row-start-1"
55+
onclick={onPrevious}
56+
/>
57+
{#each articles as article, i}
58+
<button onclick={() => (index = i)}>
59+
<Circle
60+
id={article.slug}
61+
aria-selected={i === index}
62+
class="stroke-on-background aria-selected:fill-on-background size-2"
63+
/>
64+
</button>
65+
{/each}
66+
<IconButton
67+
icon={ChevronRight}
68+
size="large"
69+
class="text-muted col-start-2 row-start-3 justify-self-end @3xl:col-start-4 @3xl:row-start-1"
70+
onclick={onNext}
71+
/>
72+
</div>
8073
</section>

src/routes/[network]/(homepage)/components/text-block.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<script lang="ts">
22
import Button from '$lib/components/button/button.svelte';
33
import Stack from '$lib/components/layout/stack.svelte';
4+
import { cn } from '$lib/utils/style';
45
import type { Snippet } from 'svelte';
56
67
interface Props {
78
title: string;
89
text: string;
910
children?: Snippet;
1011
button?: { text: string; href: string };
12+
class?: string;
1113
}
1214
let props: Props = $props();
1315
</script>
1416

15-
<Stack class="max-w-md items-start">
17+
<Stack class={cn('max-w-md items-start', props.class)}>
1618
<h2 class="h3 leading-tight">{props.title}</h2>
1719
<p>{props.text}</p>
1820
{#if props.button && props.button.href}

0 commit comments

Comments
 (0)