-
Notifications
You must be signed in to change notification settings - Fork 474
feat(ui): upload, change, and remove the profile picture in place #9693
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 all commits
6586834
4e5e1f1
5b30651
a788ef6
1b254bc
34bd68b
2a601b9
ce1ba10
76ee266
c0e6159
48f1adf
d166785
fd98d25
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,2 @@ | ||
| --- | ||
| --- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { useCallback, useEffect, useRef, useState } from 'react'; | ||
|
|
||
| /** | ||
| * Holds the avatar a story is showing and swaps in an object URL for a picked file, revoking the | ||
| * one it replaces so repeated picks don't retain every earlier file for the life of the page. | ||
| * Only URLs this hook created are revoked, so the remote avatar it starts on is left alone. | ||
| */ | ||
| export function usePreviewImage(initialUrl?: string) { | ||
| const [imageUrl, setImageUrl] = useState<string | undefined>(initialUrl); | ||
| const objectUrlRef = useRef<string | undefined>(undefined); | ||
|
|
||
| const release = useCallback(() => { | ||
| if (objectUrlRef.current) { | ||
| URL.revokeObjectURL(objectUrlRef.current); | ||
| objectUrlRef.current = undefined; | ||
| } | ||
| }, []); | ||
|
|
||
| useEffect(() => release, [release]); | ||
|
|
||
| const showFile = useCallback( | ||
| (file: File) => { | ||
| release(); | ||
| const next = URL.createObjectURL(file); | ||
| objectUrlRef.current = next; | ||
| setImageUrl(next); | ||
| }, | ||
| [release], | ||
| ); | ||
|
|
||
| const clearImage = useCallback(() => { | ||
| release(); | ||
| setImageUrl(undefined); | ||
| }, [release]); | ||
|
|
||
| return { imageUrl, showFile, clearImage }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Toast | ||
|
|
||
| Transient, self-dismissing message raised over the surface it belongs to, for feedback that has nowhere of its own to live — a picture the picker turned away, an action that failed after the row it started from is gone. Not yet implemented. | ||
|
|
||
| Until it lands, a row that must report a failure renders it inline: `Section.Error` under the row, or `Field.Error` inside a `Field.Root`. The profile picture row is the case this component is meant to take over. | ||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add the required story sections or exempt this TODO page. This file contains only a title and introduction. The story-page contract requires As per path instructions, 🤖 Prompt for AI AgentsSource: Path instructions |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type { StoryMeta } from '@/lib/types'; | ||
|
|
||
| export const meta: StoryMeta = { | ||
| group: 'Components', | ||
| title: 'Toast', | ||
| status: 'todo', | ||
| }; |
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fill in the changeset.
The front matter declares no package and no bump type, and the body is empty. Changesets will publish no version bump and no changelog entry for this change. The change also removes the public
onEditProfilePictureprop, so record the bump and the migration note here.📝 Proposed changeset
As per coding guidelines: "
.changeset/**: Use Changesets for version management and changelogs".📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines