Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Jun 4, 2025

Description of change

Built a upload a post modal and text area

Issue Number

N/A

Type of change

  • New (a change which implements a new feature)
  • Update (a change which updates existing functionality)

How the change has been tested

CI and Manual

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • New Features

    • Introduced a photo upload modal, allowing users to select images, preview them, and add captions before posting.
    • Added a new styled textarea component for improved caption input experience.
  • Enhancements

    • File input and modal components now support greater customization and more flexible usage options.
    • Modal interface supports multiple breakpoints and improved dismissal handling.
    • UI adjustments for modal pane width and height for better visual consistency.
    • Radio input component enhanced to support optional ID attribute for better accessibility.
  • Documentation

    • Added Storybook stories for the new textarea component to aid in documentation and testing.
  • Style

    • Simplified main container padding for improved layout consistency.
    • Consistent use of single quotes and indentation style across story and fragment files.
    • Minor UI positioning and styling tweaks in message input and modal components.

@ghost ghost requested a review from coodos as a code owner June 4, 2025 06:30
Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

Walkthrough

This update introduces a photo upload modal to the protected layout, enabling users to select images, preview them, and add captions within a modal interface. Supporting changes include enhancements to the InputFile and Modal components for greater flexibility, and the addition of a reusable Textarea UI component with Storybook documentation.

Changes

File(s) Change Summary
platforms/metagram/src/lib/fragments/InputFile/InputFile.svelte Extended props to support all HTML label attributes, made several props optional, improved class composition.
platforms/metagram/src/lib/fragments/Modal/Modal.svelte Added initialBreak and handleDismiss props, updated modal breakpoints, improved dismissal logic and styling.
platforms/metagram/src/lib/ui/Textarea/Textarea.svelte
platforms/metagram/src/lib/ui/Textarea/Textarea.stories.ts
Added a new styled textarea component and its Storybook story.
platforms/metagram/src/lib/ui/index.ts Exported the new Textarea component.
platforms/metagram/src/routes/(protected)/+layout.svelte Added photo upload modal with file selection, preview, caption input, and modal state management.
platforms/metagram/src/routes/+layout.svelte Simplified main container class assignment for consistent padding.
platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte Added optional id prop to radio input component and applied it to the input element.
platforms/metagram/src/lib/fragments/SettingsTile/SettingsTile.stories.ts Reformatted story file with consistent single quotes and indentation.
platforms/metagram/src/lib/fragments/index.ts Replaced double quotes with single quotes in export statements and added export for AddPostModal.
platforms/metagram/src/lib/ui/Input/Input.stories.ts Reformatted story file with consistent single quotes and indentation.
platforms/metagram/src/lib/ui/InputRadio/InputRadio.stories.ts Reformatted story file with consistent single quotes and indentation.
platforms/metagram/src/lib/fragments/AddPostModal/AddPostModal.svelte Added new component managing photo upload, caption input, and post visibility selection within a modal.
platforms/metagram/src/routes/(protected)/messages/[id]/+page.svelte Adjusted CSS classes and positioning for message input and layout.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SideBar
    participant Layout
    participant Modal
    participant InputFile
    participant Textarea

    User->>SideBar: Click "Post" action
    SideBar->>Layout: handlePost callback
    Layout->>Modal: Present modal (paneModal.present())
    Modal->>InputFile: Render file input if no files selected
    User->>InputFile: Select image files
    InputFile->>Layout: Update files state
    Layout->>Layout: Generate image previews
    Modal->>Layout: Display image previews
    User->>Modal: Click "Next"
    Modal->>Textarea: Show caption input
    User->>Textarea: Enter caption
    User->>Modal: Click "Cancel" or dismiss modal
    Modal->>Layout: handleDismiss, clear files/caption
Loading

Possibly related PRs

  • feat: FileInput #150: Introduced the initial creation of the InputFile.svelte component and its story, which this PR directly extends and enhances.

Suggested reviewers

  • coodos
  • sosweetham
  • JulienAuvo

Poem

A modal hops up with a cheerful display,
Upload your photos, let captions hold sway!
With previews to show and a textarea new,
Styling and props now flexible too.
Rabbits rejoice in this upload parade—
More features for users, all carefully made!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cab184 and fca0cf5.

📒 Files selected for processing (1)
  • platforms/metagram/src/routes/(protected)/+layout.svelte (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • platforms/metagram/src/routes/(protected)/+layout.svelte
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (7)
platforms/metagram/src/lib/ui/Textarea/Textarea.svelte (3)

18-20: Consider breaking down the long CSS class string for better maintainability.

The CSS class string is difficult to read and maintain. Consider using a multi-line template literal or extracting related classes into semantic groups.

-	const cbase = $derived(
-		'w-full bg-grey resize-none py-3.5 px-6 text-[15px] text-black-800 font-geist font-normal placeholder:text-black-600 rounded-4xl outline-0 border border-transparent invalid:border-red invalid:text-red focus:invalid:text-black-800 focus:invalid:border-transparent'
-	);
+	const cbase = $derived(`
+		w-full bg-grey resize-none
+		py-3.5 px-6
+		text-[15px] text-black-800 font-geist font-normal
+		placeholder:text-black-600
+		rounded-4xl outline-0
+		border border-transparent
+		invalid:border-red invalid:text-red
+		focus:invalid:text-black-800 focus:invalid:border-transparent
+	`);

30-30: Simplify the class name concatenation.

The cn utility function likely already handles arrays, so the manual join is redundant.

-	class={cn([cbase, restProps.class].join(' '))}
+	class={cn(cbase, restProps.class)}

31-31: Remove unnecessary tabindex attribute.

Textarea elements are naturally focusable and don't need an explicit tabindex="0".

-	tabindex="0"
platforms/metagram/src/lib/fragments/InputFile/InputFile.svelte (2)

29-30: Use const instead of let for immutable variable.

The cBase variable is never reassigned, so it should be declared with const for better code clarity.

-	let cBase =
+	const cBase =

43-43: Simplify the class name concatenation.

The cn utility function likely already handles arrays, so the manual join is redundant.

-<label {...restProps} for={uniqueId} class={cn([cBase, restProps.class].join(' '))}>
+<label {...restProps} for={uniqueId} class={cn(cBase, restProps.class)}>
platforms/metagram/src/lib/fragments/Modal/Modal.svelte (1)

75-75: Use overflow: auto instead of overflow: scroll.

Using auto will only show scrollbars when content overflows, providing a better user experience.

-		overflow: scroll !important;
+		overflow: auto !important;
platforms/metagram/src/routes/(protected)/+layout.svelte (1)

209-212: Avoid hardcoding dimensions in multiple places.

The image dimensions are hardcoded in both classes and inline styles. Consider using CSS variables or extracting to constants.

-				<div class="h-[100px] w-[80px] overflow-hidden rounded-lg border">
+				<div class="aspect-[4/5] h-[100px] overflow-hidden rounded-lg border">
 					<!-- svelte-ignore a11y_img_redundant_alt -->
-					<img {src} alt="Selected image" class="h-[100px] w-[80px] object-cover" />
+					<img {src} alt="Selected image" class="h-full w-full object-cover" />
 				</div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26dc10f and c9d5192.

📒 Files selected for processing (9)
  • platforms/metagram/src/lib/fragments/InputFile/InputFile.svelte (1 hunks)
  • platforms/metagram/src/lib/fragments/Modal/Modal.svelte (3 hunks)
  • platforms/metagram/src/lib/fragments/UserRequest/UserRequest.svelte (1 hunks)
  • platforms/metagram/src/lib/ui/Textarea/Textarea.stories.ts (1 hunks)
  • platforms/metagram/src/lib/ui/Textarea/Textarea.svelte (1 hunks)
  • platforms/metagram/src/lib/ui/index.ts (1 hunks)
  • platforms/metagram/src/routes/(protected)/+layout.svelte (4 hunks)
  • platforms/metagram/src/routes/(protected)/discover/+page.svelte (1 hunks)
  • platforms/metagram/src/routes/+layout.svelte (1 hunks)
🔇 Additional comments (4)
platforms/metagram/src/lib/ui/index.ts (1)

8-8: Export new Textarea component
The Textarea component is correctly added to the UI index with a consistent naming convention. Ensure that downstream imports are updated to use this consolidated export.

platforms/metagram/src/routes/(protected)/discover/+page.svelte (1)

10-23: Formatting cleanup in conditional rendering
Indentation and class‐attribute reordering within the {#if searchValue} block are purely presentational. No logic or behavior changes.

platforms/metagram/src/lib/fragments/UserRequest/UserRequest.svelte (1)

18-31: Approve formatting adjustments
Reordered class names (items-center justify-between) and updated indentation for improved readability. No functional changes detected.

platforms/metagram/src/routes/+layout.svelte (1)

37-42: Syntax consistency refinements
Added semicolons in setTimeout/onMount blocks, normalized self‐closing <img /> syntax, and adjusted element class ordering. No impact on runtime behavior.

Also applies to: 46-51

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
platforms/metagram/src/routes/(protected)/+layout.svelte (3)

196-196: Fix the accept attribute value.


88-102: Add error handling for file reading operations.


192-192: Reset all modal state when dismissing.

🧹 Nitpick comments (3)
platforms/metagram/src/routes/(protected)/+layout.svelte (3)

219-224: Improve radio button ID generation for stability.

Using option + i for IDs could lead to issues if the options array changes. Consider using a more stable identifier.

-		{#each postVisibilityOptions as option,i}
+		{#each postVisibilityOptions as option}
 		<div class="flex items-center justify-between w-[50%] mb-2">
-			<Label for={option + i}>{option}</Label>
-			<InputRadio name="post-visibility" id={option + i} value={option} bind:selected={postVisibility}/>
+			<Label for={`visibility-${option.replace(/\s+/g, '-')}`}>{option}</Label>
+			<InputRadio name="post-visibility" id={`visibility-${option.replace(/\s+/g, '-')}`} value={option} bind:selected={postVisibility}/>
 		</div>
 		{/each}

208-209: Add validation and accessibility to caption input.

Consider adding character limits and proper labeling for the caption textarea.

-		<Label>Add a Caption</Label>
-		<Textarea class="mb-4" bind:value={caption} placeholder="enter caption" />
+		<Label for="caption-input">Add a Caption</Label>
+		<Textarea 
+			id="caption-input"
+			class="mb-4" 
+			bind:value={caption} 
+			placeholder="Enter caption (max 2200 characters)" 
+			maxlength={2200}
+		/>

201-202: Improve image alt text for accessibility.

Consider providing more descriptive alt text that includes the image index or unique identifier.

-						<img {src} alt="Selected image" class="h-full w-full object-cover" />
+						<img {src} alt={`Selected image ${imagePreviews.indexOf(src) + 1} of ${imagePreviews.length}`} class="h-full w-full object-cover" />

Apply similar changes to the caption view images at line 214.

Also applies to: 214-214

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca12273 and 0be364c.

📒 Files selected for processing (4)
  • platforms/metagram/src/lib/fragments/Modal/Modal.svelte (3 hunks)
  • platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte (2 hunks)
  • platforms/metagram/src/lib/ui/index.ts (1 hunks)
  • platforms/metagram/src/routes/(protected)/+layout.svelte (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • platforms/metagram/src/lib/ui/index.ts
  • platforms/metagram/src/lib/fragments/Modal/Modal.svelte
🔇 Additional comments (1)
platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte (1)

9-9: LGTM! Good accessibility enhancement.

The addition of the optional id prop properly enables external labeling and improves accessibility of the radio input component. The implementation correctly follows Svelte patterns.

Also applies to: 16-16, 28-28

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
platforms/metagram/src/lib/fragments/AddPostModal/AddPostModal.svelte (5)

44-46: Simplify the dismiss handler syntax.

The comma operator usage is valid but unconventional. Consider using a more explicit approach for better readability.

 	handleDismiss={() => {
-		(files = undefined), (isAddCaption = false);
+		files = undefined;
+		isAddCaption = false;
+		caption = '';
 	}}

56-57: Remove unnecessary accessibility ignore comments.

The alt text "Selected image" is descriptive and appropriate. The svelte-ignore a11y_img_redundant_alt comments are unnecessary.

-					<!-- svelte-ignore a11y_img_redundant_alt -->
 					<img {src} alt="Selected image" class="h-full w-full object-cover" />
-				<!-- svelte-ignore a11y_img_redundant_alt -->
 				<img {src} alt="Selected image" class="h-[100px] w-[80px] object-cover" />

Also applies to: 68-69


67-70: Fix image aspect ratio preservation.

The fixed dimensions on the caption step images may distort the aspect ratio. Consider using object-cover with flexible containers.

-			<div class="h-[100px] w-[80px] overflow-hidden rounded-lg border">
-				<img {src} alt="Selected image" class="h-[100px] w-[80px] object-cover" />
+			<div class="aspect-[4/5] w-[80px] overflow-hidden rounded-lg border">
+				<img {src} alt="Selected image" class="h-full w-full object-cover" />
 			</div>

20-20: Extract post visibility options to a constant.

Consider extracting the hardcoded options to improve maintainability and enable potential internationalization.

+	const POST_VISIBILITY_OPTIONS = ['Only followers', 'Close friends', 'Anyone'] as const;
-	let postVisibilityOptions = ['Only followers', 'Close friends', 'Anyone'];
+	let postVisibilityOptions = POST_VISIBILITY_OPTIONS;

97-103: Add validation and submission functionality.

The "Next" button allows proceeding to the caption step without any validation, and there's no final submission functionality. Consider adding validation and a submit action.

The modal currently lacks:

  1. Validation to ensure files are selected before proceeding
  2. A final submit/post action after caption and visibility are set
  3. Loading states during submission

Would you like me to help implement these missing features?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5863565 and facdbd4.

📒 Files selected for processing (3)
  • platforms/metagram/src/lib/fragments/AddPostModal/AddPostModal.svelte (1 hunks)
  • platforms/metagram/src/lib/fragments/index.ts (1 hunks)
  • platforms/metagram/src/routes/(protected)/+layout.svelte (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • platforms/metagram/src/lib/fragments/index.ts
  • platforms/metagram/src/routes/(protected)/+layout.svelte

@ghost ghost self-assigned this Jun 9, 2025
@coodos coodos closed this Aug 12, 2025
@coodos coodos deleted the feat/upload-photo branch August 12, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants