From 6e45851892f980cdcfad1a05fc80611981bde75b Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Thu, 5 Jun 2025 17:01:03 +0100 Subject: [PATCH] feat: carousel image display --- src/lib/assets/arrow_right.svg | 3 + src/lib/components/Carousel.svelte | 134 +++++++++++++++++++++++++++++ src/lib/components/Navbar.svelte | 1 + src/routes/space/[id]/+page.svelte | 18 ++-- 4 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 src/lib/assets/arrow_right.svg create mode 100644 src/lib/components/Carousel.svelte diff --git a/src/lib/assets/arrow_right.svg b/src/lib/assets/arrow_right.svg new file mode 100644 index 0000000..874ecb6 --- /dev/null +++ b/src/lib/assets/arrow_right.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/Carousel.svelte b/src/lib/components/Carousel.svelte new file mode 100644 index 0000000..b26229c --- /dev/null +++ b/src/lib/components/Carousel.svelte @@ -0,0 +1,134 @@ + + +
+ + {#if scrollPosition > clientWidth / 2} + + {/if} + {#if scrollPosition < scrollWidth - clientWidth * 1.5} + + {/if} + + {Math.round(scrollPosition / clientWidth) + 1} / {urls.length} + +
+ + diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index ff8bd72..7cb89ea 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -29,6 +29,7 @@ box-shadow: 0rem 0rem 0.5rem #182125; align-items: center; overflow: hidden; + z-index: 100; } .logo { diff --git a/src/routes/space/[id]/+page.svelte b/src/routes/space/[id]/+page.svelte index fde6d34..b8121e6 100644 --- a/src/routes/space/[id]/+page.svelte +++ b/src/routes/space/[id]/+page.svelte @@ -2,16 +2,19 @@ import Navbar from "$lib/components/Navbar.svelte"; import crossUrl from "$lib/assets/cross.svg"; import placeholder from "$lib/assets/study_space.png"; + import Carousel from "$lib/components/Carousel.svelte"; const { data } = $props(); const { space, supabase } = $derived(data); - const imgUrl = $derived( - space.study_space_images.length > 0 - ? supabase.storage - .from("files_bucket") - .getPublicUrl(space.study_space_images[0].image_path).data.publicUrl - : placeholder + const imgUrls = $derived( + space.study_space_images.length === 0 + ? [placeholder] + : space.study_space_images.map( + (img) => + supabase.storage.from("files_bucket").getPublicUrl(img.image_path).data + .publicUrl + ) ); @@ -22,7 +25,7 @@
- the study space +
{space.location}
@@ -61,6 +64,7 @@ margin: 0 auto; } .nameContainer { + z-index: 10; display: block; width: 100%; padding: 0.6rem;