diff --git a/platforms/metagram/src/lib/dummyData.ts b/platforms/metagram/src/lib/dummyData.ts index 653f42ea..c05a2f02 100644 --- a/platforms/metagram/src/lib/dummyData.ts +++ b/platforms/metagram/src/lib/dummyData.ts @@ -4,7 +4,12 @@ export const dummyPosts = Array.from({ length: 100 }, (_, i) => ({ id: i + 1, avatar: 'https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250', username: `user${i + 1}`, - imgUri: 'https://picsum.photos/800', + imgUri: [ + 'https://picsum.photos/800', + 'https://picsum.photos/200', + 'https://picsum.photos/800', + 'https://picsum.photos/200' + ], postAlt: 'Sample', text: `This is post number ${i + 1}. Loving how these shots came out! 📸`, time: `${i + 1} hours ago`, diff --git a/platforms/metagram/src/lib/fragments/Post/Post.stories.ts b/platforms/metagram/src/lib/fragments/Post/Post.stories.ts index d112e836..c48995ef 100644 --- a/platforms/metagram/src/lib/fragments/Post/Post.stories.ts +++ b/platforms/metagram/src/lib/fragments/Post/Post.stories.ts @@ -15,7 +15,10 @@ export const Primary = { args: { avatar: 'https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250', username: 'blurryface', - imgUri: 'https://graphicsfamily.com/wp-content/uploads/edd/2023/01/Free-Photographer-Social-Media-Post-Design-Template-870x870.jpg', + imgUris: [ + 'https://graphicsfamily.com/wp-content/uploads/edd/2023/01/Free-Photographer-Social-Media-Post-Design-Template-870x870.jpg', + 'https://picsum.photos/200' + ], postAlt: 'Sample', text: 'Took some pictures today! Really love how this one in particular turned out! ', time: '2 hours ago', diff --git a/platforms/metagram/src/lib/fragments/Post/Post.svelte b/platforms/metagram/src/lib/fragments/Post/Post.svelte index 72e9c81a..2e034deb 100644 --- a/platforms/metagram/src/lib/fragments/Post/Post.svelte +++ b/platforms/metagram/src/lib/fragments/Post/Post.svelte @@ -2,6 +2,8 @@ import { Avatar } from '$lib/ui'; import { cn } from '$lib/utils'; import { + ArrowLeftIcon, + ArrowRightIcon, Message02Icon, MoreVerticalIcon, RecordIcon, @@ -13,7 +15,7 @@ interface IPostProps extends HTMLAttributes { avatar: string; username: string; - imgUri: string; + imgUris: string[]; postAlt?: string; text: string; count: { @@ -31,7 +33,7 @@ const { avatar, username, - imgUri, + imgUris, text, postAlt, count, @@ -39,6 +41,27 @@ time, ...restProps }: IPostProps = $props(); + + let galleryRef: HTMLDivElement; + let currentIndex = $state(0); + + function scrollLeft() { + if (!galleryRef) return; + galleryRef.scrollBy({ left: -galleryRef.clientWidth, behavior: 'smooth' }); + } + + function scrollRight() { + if (!galleryRef) return; + galleryRef.scrollBy({ left: galleryRef.clientWidth, behavior: 'smooth' }); + } + + function handleScroll() { + if (!galleryRef) return; + const scrollLeft = galleryRef.scrollLeft; + const galleryWidth = galleryRef.clientWidth; + const newIndex = Math.round(scrollLeft / galleryWidth); + currentIndex = newIndex; + }
@@ -52,12 +75,53 @@ -
- {postAlt +
+ {#if imgUris.length > 1} + + {/if} +
+ {#each imgUris as img} +
+ {postAlt +
+ {/each} +
+ {#if imgUris.length > 1} +
+ {#if imgUris.length > 1} +
+ {#each imgUris as _, i} +
+ {/each} +
+ {/if} +
+ {/if} + {#if imgUris.length > 1} + + {/if}

{text}

{time}

diff --git a/platforms/metagram/src/lib/types.ts b/platforms/metagram/src/lib/types.ts index 1cd87950..b289f7d2 100644 --- a/platforms/metagram/src/lib/types.ts +++ b/platforms/metagram/src/lib/types.ts @@ -21,7 +21,7 @@ export type PostData = { id: number; avatar: string; username: string; - imgUri: string; + imgUri: string[]; postAlt: string; text: string; time: string; diff --git a/platforms/metagram/src/routes/(protected)/home/+page.svelte b/platforms/metagram/src/routes/(protected)/home/+page.svelte index 227e2035..dea6637e 100644 --- a/platforms/metagram/src/routes/(protected)/home/+page.svelte +++ b/platforms/metagram/src/routes/(protected)/home/+page.svelte @@ -89,7 +89,7 @@