-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(Toast): use View Transition API for Toast animations #7631
base: main
Are you sure you want to change the base?
Conversation
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.
those animations look so nice now!
Looks like we no longer focus the next toast when we remove a toast from the list. I checked against main.
## API Changes
@react-stately/toast/@react-stately/toast:ToastQueue ToastQueue <T> {
add: (T, ToastOptions) => void
close: (string) => void
constructor: (ToastStateProps) => void
pauseAll: () => void
- remove: (string) => void
resumeAll: () => void
subscribe: (() => void) => void
visibleToasts: Array<QueuedToast<T>>
} /@react-stately/toast:ToastState ToastState <T> {
add: (T, ToastOptions) => string
close: (string) => void
pauseAll: () => void
- remove: (string) => void
resumeAll: () => void
visibleToasts: Array<QueuedToast<T>>
} /@react-stately/toast:QueuedToast QueuedToast <T> {
- animation?: 'entering' | 'queued' | 'exiting' | null
content: T
key: string
onClose?: () => void
priority?: number
timer?: Timer
} /@react-stately/toast:ToastStateProps ToastStateProps {
- hasExitAnimation?: boolean
maxVisibleToasts?: number
} |
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.
Should toasts that timeout to leave also animate?
otherwise looks good, focus of next toast appears to be working again
className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')} | ||
style={{ | ||
// @ts-expect-error | ||
viewTransitionName: `_${toast.key.slice(2)}`, |
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.
we can probably use the actual key if we apply https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape_static when we generate the random id
Removes useToast's existing animation API in favor of using the browser's View Transition API to animate toasts.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: