Skip to content

Update profile saving#143

Merged
erskingardner merged 3 commits intomasterfrom
update-profile-saving
Apr 1, 2025
Merged

Update profile saving#143
erskingardner merged 3 commits intomasterfrom
update-profile-saving

Conversation

@erskingardner
Copy link
Copy Markdown
Member

@erskingardner erskingardner commented Apr 1, 2025

Fixes #141

Summary by CodeRabbit

  • New Features

    • The avatar now updates immediately when a new image is provided.
    • A new, customizable textarea component has been added to the Profile settings, enhancing text input consistency.
  • Style

    • Profile settings have been refined with improved spacing, alignment, and repositioned save controls for a cleaner layout.
    • Wallet settings now feature enhanced viewport responsiveness for a more consistent display across devices.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2025

Walkthrough

This pull request introduces a conditional update in the Avatar.svelte component to reflect changes in the picture prop. It adds a new custom Textarea component in the UI library—with full TypeScript type support and enhanced event handling—and integrates it into the profile settings page, replacing the standard HTML textarea. Additionally, a minor CSS adjustment is made in the wallet settings page to change the height calculation from vh to svh.

Changes

File(s) Change Summary
src/.../Avatar.svelte Added a conditional check in the $effect block to update avatarImage when the picture prop is defined; existing user data flow remains unchanged.
src/.../ui/textarea/index.ts
src/.../ui/textarea/textarea.svelte
Introduced a new customizable Textarea component with two-way data binding, comprehensive event handling, and exported TypeScript types (TextareaEvents, FormTextareaEvent); exposes the component as both Root and Textarea.
src/.../settings/profile/+page.svelte Replaced the native <textarea> with the new Textarea component; restructured the layout by removing the form wrapper and adding spacing classes (px-4), and adjusted the save button placement.
src/.../settings/wallet/+page.svelte Modified the CSS height calculation for the <main> element by changing from h-[calc(100vh-7rem)] to h-[calc(100svh-7rem)] to alter the layout on varying screen sizes.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Parent Component
    participant Avatar as Avatar.svelte Component
    Parent->>Avatar: Update picture prop
    Avatar->>Avatar: Trigger $effect block
    Avatar->>Avatar: Check if picture exists
    Avatar->>Avatar: Update avatarImage
    Avatar-->>Parent: Re-render with updated image
Loading
sequenceDiagram
    participant User as End User
    participant Profile as Profile Settings Page
    participant Textarea as Textarea Component
    User->>Textarea: Inputs text
    Textarea->>Textarea: Update value via two-way binding
    Textarea->>Profile: Emit input event and update state
Loading

Possibly related PRs

  • Add switch profile #140: Modified the $effect block in Avatar.svelte to handle avatarImage updates, similar to the changes in this PR.

Suggested reviewers

  • jgmontoya
  • josefinalliende

Poem

I'm a little rabbit coding through the night,
Hopping over lines with pure delight.
New checks update avatars so bright,
And text areas now dance just right.
With settings refreshed, my code takes flight—
Cheers to change, and carrots in sight! 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (1)
src/lib/components/ui/textarea/textarea.svelte (1)

18-38: Good implementation of customizable textarea with comprehensive event handling.

The textarea includes all necessary event handlers and utilizes the cn utility for class merging. The implementation allows for complete customization via both classes and additional attributes through $$restProps.

Consider enhancing the component with these accessibility and UX features:

<script lang="ts">
import { cn } from "$lib/utils.js";
import type { HTMLTextareaAttributes } from "svelte/elements";
import type { TextareaEvents } from "./index.js";

type $$Props = HTMLTextareaAttributes;
type $$Events = TextareaEvents;

let className: $$Props["class"] = undefined;
export let value: $$Props["value"] = undefined;
export { className as class };

// Workaround for https://github.com/sveltejs/svelte/issues/9305
// Fixed in Svelte 5, but not backported to 4.x.
export let readonly: $$Props["readonly"] = undefined;
+// Optional accessibility and UX enhancements
+export let maxLength: number | undefined = undefined;
+export let showCharCount = false;
+export let autoGrow = false;
+
+// For auto-growing functionality
+let textarea: HTMLTextAreaElement;
+let height = 'auto';
+
+function adjustHeight() {
+  if (autoGrow && textarea) {
+    textarea.style.height = 'auto';
+    textarea.style.height = `${textarea.scrollHeight}px`;
+  }
+}
+
+$: if (value && autoGrow) adjustHeight();
</script>

<textarea
	class={cn(
		"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[3rem] w-full border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-input focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
		className
	)}
	bind:value
	{readonly}
+	bind:this={textarea}
+	style={autoGrow ? `height: ${height}` : undefined}
+	{maxLength}
	on:blur
	on:change
	on:click
	on:focus
	on:keydown
	on:keypress
	on:keyup
	on:mouseover
	on:mouseenter
	on:mouseleave
	on:paste
	on:input
	{...$$restProps}
></textarea>
+{#if showCharCount && maxLength}
+<div class="text-xs text-muted-foreground text-right mt-1">
+  {value ? value.length : 0}/{maxLength}
+</div>
+{/if}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9c46e and 8c22710.

📒 Files selected for processing (5)
  • src/lib/components/Avatar.svelte (1 hunks)
  • src/lib/components/ui/textarea/index.ts (1 hunks)
  • src/lib/components/ui/textarea/textarea.svelte (1 hunks)
  • src/routes/(app)/settings/profile/+page.svelte (3 hunks)
  • src/routes/(app)/settings/wallet/+page.svelte (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-android-split
  • GitHub Check: build-android-universal
  • GitHub Check: build-macos (x86_64, x86_64-apple-darwin)
  • GitHub Check: build-macos (aarch64, aarch64-apple-darwin)
  • GitHub Check: build-linux
  • GitHub Check: rust-checks
🔇 Additional comments (9)
src/routes/(app)/settings/wallet/+page.svelte (1)

103-103: Good accessibility improvement with small viewport height unit

Changing from vh to svh unit improves layout consistency across different mobile browsers where UI elements like address bars can appear/disappear, affecting the available viewport height.

src/lib/components/Avatar.svelte (1)

27-30: Great addition for reactive avatar updates

This change improves component reactivity by ensuring the avatar image updates whenever the picture prop changes, not just on initial render or when the pubkey changes.

src/lib/components/ui/textarea/index.ts (1)

1-28: Well-structured component with proper TypeScript typing

The new Textarea component implementation follows best practices with:

  • Comprehensive event typing for strong type safety
  • Clear export pattern consistent with other UI components
  • Proper extension of native HTML events

This will provide excellent developer experience and type checking when using the component.

src/routes/(app)/settings/profile/+page.svelte (5)

7-7: Good import of the new Textarea component

Properly imports the new UI component that will replace the standard HTML textarea.


68-68: Consistent layout approach with wallet page

Using h-[calc(100svh-7rem)] matches the same pattern used in the wallet settings page, providing consistent behavior across different settings screens.


129-133: Good implementation of the new Textarea component

The custom Textarea component replaces the standard HTML textarea element, maintaining the same binding approach while gaining the benefits of the styled component.


116-149: Improved form layout with consistent padding

The restructured form with consistent px-4 padding for each input section improves the visual consistency and spacing of the form elements.


150-151: Well-positioned save button with responsive behavior

The save button positioning provides a good mobile experience (fixed to bottom) while maintaining proper layout on desktop (relative positioning with appropriate margins).

src/lib/components/ui/textarea/textarea.svelte (1)

1-16: Well-structured TypeScript definitions and props setup.

The component has solid TypeScript typing with proper inheritance from HTML textarea attributes. The workaround for the Svelte 4.x issue with readonly attributes is well-documented and future-proofed.

@erskingardner erskingardner merged commit 4ae8087 into master Apr 1, 2025
16 checks passed
@erskingardner erskingardner deleted the update-profile-saving branch April 1, 2025 08:03
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.

Uploading new PFP or banner shouldn't auto-submit

1 participant