-
Notifications
You must be signed in to change notification settings - Fork 4
feat: added uploaded post view component. #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e8d8528
0483816
8879916
4e83783
0793780
a83fd24
e7f9d0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { ComponentProps } from "svelte"; | ||
import UploadedPostView from "./UploadedPostView.svelte"; | ||
|
||
export default { | ||
title: "UI/UploadedPostView", | ||
component: UploadedPostView, | ||
tags: ["autodocs"], | ||
render: (args: { | ||
Component: UploadedPostView; | ||
props: ComponentProps<typeof UploadedPostView>; | ||
}) => ({ | ||
Component: UploadedPostView, | ||
props: args, | ||
}), | ||
}; | ||
|
||
const IMAGES = [ | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
{ | ||
url: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
alt: "Sample Image 1", | ||
}, | ||
]; | ||
|
||
export const Primary = { | ||
args: { | ||
images: IMAGES, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||||||||||||||||||||||
<script lang="ts"> | ||||||||||||||||||||||||||||||||||||
import { Cross } from '$lib/icons'; | ||||||||||||||||||||||||||||||||||||
import { cn } from '$lib/utils'; | ||||||||||||||||||||||||||||||||||||
import type { HTMLAttributes } from 'svelte/elements'; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
interface IImage { | ||||||||||||||||||||||||||||||||||||
url: string; | ||||||||||||||||||||||||||||||||||||
alt: string; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
interface IUploadedPostViewProps extends HTMLAttributes<HTMLImageElement> { | ||||||||||||||||||||||||||||||||||||
images: IImage[]; | ||||||||||||||||||||||||||||||||||||
width?: string; | ||||||||||||||||||||||||||||||||||||
height?: string; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
let { | ||||||||||||||||||||||||||||||||||||
images, | ||||||||||||||||||||||||||||||||||||
width = 'w-full', | ||||||||||||||||||||||||||||||||||||
height = 'h-full', | ||||||||||||||||||||||||||||||||||||
...restProps | ||||||||||||||||||||||||||||||||||||
}: IUploadedPostViewProps = $props(); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
const crossHandler = (i: number) => { | ||||||||||||||||||||||||||||||||||||
images = images.filter((_, index) => index !== i); | ||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||
Sahil2004 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
<article class="max-w-screen flex flex-row items-center gap-4 scroll-auto"> | ||||||||||||||||||||||||||||||||||||
|
<article class="max-w-screen flex flex-row items-center gap-4 scroll-auto"> | |
<article class="max-w-screen flex flex-row items-center gap-4 overflow-x-auto"> |
🤖 Prompt for AI Agents
In platforms/metagram/src/lib/fragments/UploadedPostView/UploadedPostView.svelte
at line 29, replace the invalid Tailwind CSS class 'scroll-auto' with
'overflow-x-auto' to correctly enable horizontal scrolling when the content
overflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosweetham Perfect! I'll implement that CSS class fix for you.
flowchart TB
A["Task: Fix CSS class in UploadedPostView.svelte"]
A --> B["Replace 'scroll-auto' with 'overflow-x-auto' in article element"]
Another agent will handle implementing this change for you. The fix will ensure proper horizontal scrolling behavior when the uploaded images overflow the container width.
⏳ Preparing changes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A summary of the edits CodeRabbit can apply:
Will replace the invalid Tailwind CSS class 'scroll-auto' with 'overflow-x-auto' in UploadedPostView.svelte to enable proper horizontal scrolling.
A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets):
✏️ platforms/metagram/src/lib/fragments/UploadedPostView/UploadedPostView.svelte
Open platforms/metagram/src/lib/fragments/UploadedPostView/UploadedPostView.svelte and locate the article element at line 29 with the class attribute containing "scroll-auto".
On line 29, replace scroll-auto with overflow-x-auto so that the line reads:
<article class="max-w-screen flex flex-row items-center gap-4 overflow-x-auto">
Ensure only that class name changes and the rest of the attribute stays identical.
Save the file and verify that the indentation and formatting remain consistent with the surrounding code.
Run the application (or component story/tests) to confirm that horizontal scrolling is enabled when the image list overflows the container.
- ✅ Create PR with these edits
- 📌 Create commit in current branch
- 📋 Get copyable edits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add keyboard accessibility for image removal.
The Cross icon only supports mouse interaction, missing keyboard navigation for accessibility.
Add keyboard support and proper ARIA attributes:
<Cross
class="absolute right-0 top-0 -translate-y-1/2 translate-x-1/2 cursor-pointer"
+ role="button"
+ tabindex="0"
+ aria-label={`Remove ${image.alt}`}
onclick={() => crossHandler(i)}
+ onkeydown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ crossHandler(i);
+ }
+ }}
/>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<Cross | |
class="absolute right-0 top-0 -translate-y-1/2 translate-x-1/2 cursor-pointer" | |
onclick={() => crossHandler(i)} | |
/> | |
<Cross | |
class="absolute right-0 top-0 -translate-y-1/2 translate-x-1/2 cursor-pointer" | |
role="button" | |
tabindex="0" | |
aria-label={`Remove ${image.alt}`} | |
onclick={() => crossHandler(i)} | |
onkeydown={(e) => { | |
if (e.key === 'Enter' || e.key === ' ') { | |
e.preventDefault(); | |
crossHandler(i); | |
} | |
}} | |
/> |
🤖 Prompt for AI Agents
In platforms/metagram/src/lib/fragments/UploadedPostView/UploadedPostView.svelte
around lines 32 to 35, the Cross icon currently only supports mouse clicks and
lacks keyboard accessibility. To fix this, add keyboard event handling such as
on:keydown to trigger crossHandler when Enter or Space is pressed. Also, include
appropriate ARIA attributes like role="button" and tabindex="0" to make the icon
focusable and accessible to screen readers.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export { default as Header } from './Header/Header.svelte'; | ||
export { default as BottomNav } from './BottomNav/BottomNav.svelte'; | ||
export { default as SettingsNavigationButton } from './SettingsNavigationButton/SettingsNavigationButton.svelte'; | ||
export { default as MessageInput } from './MessageInput/MessageInput.svelte'; | ||
export { default as InputFile } from './InputFile/InputFile.svelte'; | ||
export { default as Drawer } from './Drawer/Drawer.svelte'; | ||
export { default as Message } from './Message/Message.svelte'; | ||
export { default as ActionMenu } from './ActionMenu/ActionMenu.svelte'; | ||
export { default as Modal } from './Modal/Modal.svelte'; | ||
export { default as SideBar } from './SideBar/SideBar.svelte'; | ||
export { default as Post } from './Post/Post.svelte'; | ||
export { default as Header } from "./Header/Header.svelte"; | ||
export { default as BottomNav } from "./BottomNav/BottomNav.svelte"; | ||
export { default as SettingsNavigationButton } from "./SettingsNavigationButton/SettingsNavigationButton.svelte"; | ||
export { default as MessageInput } from "./MessageInput/MessageInput.svelte"; | ||
export { default as InputFile } from "./InputFile/InputFile.svelte"; | ||
export { default as Drawer } from "./Drawer/Drawer.svelte"; | ||
export { default as Message } from "./Message/Message.svelte"; | ||
export { default as ActionMenu } from "./ActionMenu/ActionMenu.svelte"; | ||
export { default as Modal } from "./Modal/Modal.svelte"; | ||
export { default as SideBar } from "./SideBar/SideBar.svelte"; | ||
export { default as Post } from "./Post/Post.svelte"; | ||
export { default as UploadedPostView } from "./UploadedPostView/UploadedPostView.svelte"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import type { ISvgProps } from './../types'; | ||
|
||
let { size = '20px', color = '#DA4A11', ...restProps }: ISvgProps = $props(); | ||
</script> | ||
|
||
<svg | ||
width={size} | ||
height={size} | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...restProps} | ||
> | ||
<rect width="24" height="24" rx="12" fill={color} /> | ||
<path | ||
d="M16.0837 7.91663L7.91699 16.0833M7.91699 7.91663L16.0837 16.0833" | ||
stroke="white" | ||
stroke-width="1.75" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
</svg> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export { default as Icons } from './Icons.svelte'; | ||
export { default as Like } from './Like.svelte'; | ||
export { default as Refresh } from './Refresh.svelte'; | ||
export { default as Comment } from './Comment.svelte'; | ||
export { default as VerticalDots } from './VerticalDots.svelte'; | ||
export { default as Home } from './Home.svelte'; | ||
export { default as Flash } from './Flash.svelte'; | ||
export { default as CommentsTwo } from './CommentsTwo.svelte'; | ||
export { default as Search } from './Search.svelte'; | ||
export { default as Camera } from './Camera.svelte'; | ||
export { default as Settings } from './Settings.svelte'; | ||
export { default as Icons } from "./Icons.svelte"; | ||
export { default as Like } from "./Like.svelte"; | ||
export { default as Refresh } from "./Refresh.svelte"; | ||
export { default as Comment } from "./Comment.svelte"; | ||
export { default as VerticalDots } from "./VerticalDots.svelte"; | ||
export { default as Home } from "./Home.svelte"; | ||
export { default as Flash } from "./Flash.svelte"; | ||
export { default as CommentsTwo } from "./CommentsTwo.svelte"; | ||
export { default as Search } from "./Search.svelte"; | ||
export { default as Camera } from "./Camera.svelte"; | ||
export { default as Settings } from "./Settings.svelte"; | ||
export { default as Cross } from "./Cross.svelte"; |
Uh oh!
There was an error while loading. Please reload this page.