Skip to content

Commit cf2c13a

Browse files
Moves slides to array in props of carousel
1 parent a1b1af5 commit cf2c13a

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

src/components/HomepageCarousel.svelte

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
<script lang="ts">
22
import * as Carousel from "@/components/ui/carousel/index.ts";
3+
import { type CarouselAPI } from "@/components/ui/carousel/context.js";
4+
import { Button } from "@/components/ui/button";
35
import HomepageCarouselItem from "@/components/HomepageCarouselItem.svelte";
6+
interface Props {
7+
slides: {
8+
title: string;
9+
image: {
10+
path:string;
11+
alt?:string;
12+
};
13+
text: string;
14+
actionLabel: string;
15+
actionTo: string;
16+
}[];
17+
}
18+
let {slides}: Props = $props();
419
</script>
520

6-
<Carousel.Root class="w-full h-fit">
21+
<Carousel.Root opts={{
22+
loop: true,
23+
}} class="w-full h-fit">
724
<Carousel.Content class="bg-red-400">
8-
<HomepageCarouselItem src="/images/IMG_7311.JPG" />
9-
<Carousel.Item>B</Carousel.Item>
10-
<Carousel.Item>C</Carousel.Item>
25+
{#each slides as slide}
26+
<HomepageCarouselItem src={slide.image.path} alt={slide.image.alt} />
27+
{/each}
1128
</Carousel.Content>
1229
<div
1330
class="w-4/5 sm:w-72 bg-background absolute bottom-12 left-8 px-4 py-2"

src/globals.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
--border: 214.3 31.8% 91.4%;
4444
--input: 214.3 31.8% 91.4%;
4545

46-
--primary: 222.2 47.4% 11.2%;
47-
--primary-foreground: 210 40% 98%;
46+
--primary: 4 100% 57%; /* #FF3123 robocon red */
47+
--primary-foreground: 210 40% 98%; /* idk, to change */
4848

4949
--secondary: 210 40% 96.1%;
5050
--secondary-foreground: 222.2 47.4% 11.2%;
@@ -57,7 +57,7 @@
5757

5858
--ring: 222.2 84% 4.9%;
5959

60-
--radius: 0.5rem;
60+
--radius: 0.4rem;
6161
}
6262

6363
.dark {
@@ -99,4 +99,4 @@
9999
body {
100100
@apply bg-background text-foreground;
101101
}
102-
}
102+
}

src/pages/index.astro

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import HomepageCarousel from '@/components/HomepageCarousel.svelte';
1010
<Navbar/>
1111
</header>
1212
<main class="h-screen">
13-
<HomepageCarousel client:load/>
13+
<HomepageCarousel client:load slides={[
14+
{
15+
title:"Lorem Ipsum",
16+
image:{
17+
path:"/images/IMG_7815.JPG",
18+
},
19+
text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis erat in ante dignissim euismod id quis diam.",
20+
actionLabel:"Click",
21+
actionTo:"/"
22+
}
23+
]}/>
1424
</main>
1525
</Layout>

0 commit comments

Comments
 (0)