Skip to content

中文版 AI 姿势参考图库 · 1439 组 / 2878 张图片 / 完整汉化 · 零依赖静态画廊

fix(notifications): retain Sonner motion and time only readable queued notices

H-Bolefb2ca1a2b208
diff --git a/src/components/layout/RecipeDock.tsx b/src/components/layout/RecipeDock.tsx
index 002607c..1311a67 100644
--- a/src/components/layout/RecipeDock.tsx
+++ b/src/components/layout/RecipeDock.tsx
@@ -1,7 +1,7 @@
import { useQueryClient } from '@tanstack/react-query'
import { Link, useLocation } from '@tanstack/react-router'
import { CopyIcon, DicesIcon, LoaderCircleIcon, PersonStandingIcon, ShirtIcon, SparklesIcon, Trash2Icon, UserRoundIcon, XIcon } from 'lucide-react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { costumesQuery, portraitsQuery, posesQuery } from '@/api/gallery'
import { poseThumbPath, referenceImageUrl } from '@/lib/recipeImages'
import { workflowIdentity } from '@/lib/comfyWorkflowParameters'
diff --git a/src/components/studio/WorkflowParameters.tsx b/src/components/studio/WorkflowParameters.tsx
index 774b53b..0f97fe4 100644
--- a/src/components/studio/WorkflowParameters.tsx
+++ b/src/components/studio/WorkflowParameters.tsx
@@ -1,6 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useRef, useState, type ChangeEvent } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Switch } from '@/components/ui/switch'
diff --git a/src/components/ui/sonner.tsx b/src/components/ui/sonner.tsx
index 4de9cf8..e918585 100644
--- a/src/components/ui/sonner.tsx
+++ b/src/components/ui/sonner.tsx
@@ -1,100 +1,143 @@
-import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
-import { toast, useSonner, type Action, type ToastT, type ToasterProps } from 'sonner'
-import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon, XIcon } from 'lucide-react'
+import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { Toaster as Sonner, useSonner, type ToasterProps } from 'sonner'
+import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react'
+import { adoptNotification, toast, type Notification } from '@/lib/notifications'
+import { useTheme } from '@/components/theme/ThemeProvider'
-// 排队时仍保留计时器组件,只暂停倒计时,避免隐藏消息提前过期或重置剩余时间。
-function NoticeLifetime({ notice, paused, onExpire }: { notice: ToastT; paused: boolean; onExpire: () => void }) {
- const duration = notice.duration === Infinity || notice.type === 'loading' ? Infinity : Number.isFinite(notice.duration) ? Math.max(0, notice.duration!) : 4000
+function Lifetime({ notice, paused }: { notice: Notification; paused: boolean }) {
+ const duration = notice.notificationDuration ?? 4000
const remaining = useRef(duration)
- const callback = useRef(onExpire)
- callback.current = onExpire
- useEffect(() => { remaining.current = duration }, [duration, notice.title, notice.type])
+ useEffect(() => { remaining.current = duration }, [duration, notice.type, notice.notificationRevision])
useEffect(() => {
- if (paused || duration === Infinity) return
+ if (paused || notice.type === 'loading' || duration === Infinity) return
const started = performance.now()
- const timer = window.setTimeout(() => callback.current(), remaining.current)
- return () => { clearTimeout(timer); remaining.current = Math.max(0, remaining.current - (performance.now() - started)) }
- }, [paused, duration, notice.title, notice.type])
+ const timer = window.setTimeout(() => {
+ if (notice.notificationAutoClosing) notice.notificationAutoClosing.current = true
+ try { notice.onAutoClose?.(notice) }
+ finally { toast.dismiss(notice.id) }
+ }, Math.max(0, remaining.current))
+ return () => {
+ clearTimeout(timer)
+ remaining.current = Math.max(0, remaining.current - (performance.now() - started))
+ }
+ }, [paused, duration, notice])
return null
}
-function Notice({ notice, closing, front, expanded, dismiss }: { notice: ToastT; closing: boolean; front: boolean; expanded: boolean; dismiss: () => void }) {
- const action = notice.action && typeof notice.action === 'object' && 'label' in notice.action ? notice.action as Action : null
- const Icon = ({success: CircleCheckIcon, error: OctagonXIcon, warning: TriangleAlertIcon, loading: Loader2Icon} as const)[notice.type as 'success' | 'error' | 'warning' | 'loading'] || InfoIcon
- return <div className="app-notice" data-notice-id={String(notice.id)} data-closing={closing} data-kind={notice.type || 'normal'} role={notice.type === 'error' ? 'alert' : 'status'} aria-hidden={!front && !expanded} inert={!front && !expanded}>
- <span className="app-notice-icon" aria-hidden="true">{notice.icon || <Icon className={notice.type === 'loading' ? 'size-4 animate-spin' : 'size-4'} />}</span>
- <div className="app-notice-content">
- <div>{typeof notice.title === 'function' ? notice.title() : notice.title}</div>
- {notice.description && <div className="app-notice-description">{typeof notice.description === 'function' ? notice.description() : notice.description}</div>}
- {notice.action && <div>{action ? <button onClick={(e) => { action.onClick(e); dismiss() }}>{action.label}</button> : notice.action as React.ReactNode}</div>}
- </div>
- <button type="button" className="app-notice-close" aria-label="关闭此通知" tabIndex={front || expanded ? 0 : -1} disabled={closing} onClick={dismiss}><XIcon className="size-3.5" /></button>
- </div>
-}
-
-export function Toaster(_props: ToasterProps) {
+export function Toaster(props: ToasterProps) {
+ const { theme } = useTheme()
const { toasts } = useSonner()
+ const region = useRef<HTMLElement>(null)
+ const events = useRef<HTMLDivElement>(null)
+ const [expanded, setExpanded] = useState(false)
const [hovered, setHovered] = useState(false)
const [focused, setFocused] = useState(false)
- const [hidden, setHidden] = useState(document.hidden)
+ const [toggleFocused, setToggleFocused] = useState(false)
+ const [toggleTop, setToggleTop] = useState(128)
+ const [background, setBackground] = useState(document.hidden || !document.hasFocus())
const [visibleCount, setVisibleCount] = useState(3)
- const [closing, setClosing] = useState<Set<ToastT['id']>>(new Set())
- const closeTimers = useRef(new Map<ToastT['id'], number>())
- const heights = useRef(new Map<string, number>())
- const region = useRef<HTMLDivElement>(null)
- const expanded = hovered || focused
- const dismiss = useCallback((notice: ToastT, automatic = false) => {
- if (closeTimers.current.has(notice.id)) return
- setClosing((current) => new Set(current).add(notice.id))
- const delay = document.documentElement.dataset.galleryMotion === 'off' || matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 160
- closeTimers.current.set(notice.id, window.setTimeout(() => {
- try { if (automatic) notice.onAutoClose?.(notice); else notice.onDismiss?.(notice) }
- finally { toast.dismiss(notice.id) }
- }, delay))
- }, [])
- useEffect(() => () => { closeTimers.current.forEach(clearTimeout) }, [])
- useEffect(() => {
- const live = new Set(toasts.map((notice) => notice.id))
- for (const [id, timer] of closeTimers.current) if (!live.has(id)) { clearTimeout(timer); closeTimers.current.delete(id) }
- setClosing((current) => [...current].some((id) => !live.has(id)) ? new Set([...current].filter((id) => live.has(id))) : current)
- for (const id of heights.current.keys()) if (!toasts.some((notice) => String(notice.id) === id)) heights.current.delete(id)
- if (!toasts.length) setHovered(false)
- if (!region.current?.contains(document.activeElement)) setFocused(false)
- }, [toasts])
+ const [readable, setReadable] = useState<Set<Notification['id']>>(new Set())
+
+ useLayoutEffect(() => { toasts.forEach(adoptNotification) }, [toasts])
+
useLayoutEffect(() => {
+ const root = region.current
+ if (!root) return
const measure = () => {
- const element = region.current
- if (!element) return
- element.querySelectorAll<HTMLElement>('[data-notice-id]').forEach((node) => heights.current.set(node.dataset.noticeId!, node.offsetHeight))
- const budget = Math.max(100, Math.min(360, innerHeight * .45, innerHeight - element.getBoundingClientRect().top - 24))
- let used = 0, count = 0
- for (const notice of toasts.slice(0, 3)) {
- const height = heights.current.get(String(notice.id)) ?? 72
+ const nodes = [...root.querySelectorAll<HTMLElement>('[data-sonner-toast]')]
+ const active = nodes.filter((node) => node.dataset.removed !== 'true')
+ const top = root.querySelector('[data-sonner-toaster]')?.getBoundingClientRect().top ?? 64
+ const toggleSpace = toasts.length > 1 && matchMedia('(pointer: coarse)').matches ? 52 : 0
+ const budget = Math.max(0, (window.visualViewport?.height ?? innerHeight) - top - 24 - toggleSpace)
+ let count = 0, used = 0
+ for (const node of active.slice(0, 3)) {
+ const height = parseFloat(node.style.getPropertyValue('--initial-height')) || node.offsetHeight
if (count && used + height + 8 > budget) break
- used += height + (count ? 8 : 0); count++
+ used += height + (count ? 8 : 0)
+ count++
}
setVisibleCount(Math.max(1, count))
+ const visible = active.filter((node) => node.dataset.visible === 'true')
+ const frontHeight = visible[0]?.offsetHeight ?? 56
+ const stackHeight = visible.reduce((height, node, index) => {
+ const bottom = node.dataset.expanded === 'true'
+ ? (parseFloat(node.style.getPropertyValue('--offset')) || 0) + node.offsetHeight
+ : frontHeight + index * 8
+ return Math.max(height, bottom)
+ }, frontHeight)
+ setToggleTop(top + stackHeight + 8)
+ const next = new Set<Notification['id']>()
+ for (const node of nodes) {
+ const accessible = node.dataset.visible === 'true' && node.dataset.mounted === 'true' && node.dataset.removed !== 'true' && (node.dataset.front === 'true' || node.dataset.expanded === 'true')
+ node.inert = !accessible
+ node.setAttribute('aria-hidden', String(!accessible))
+ if (accessible) {
+ const marker = [...node.classList].find((name) => name.startsWith('app-notification-'))
+ // A promise resolving directly to a React element bypasses Sonner's result options.
+ const notice = marker ? toasts.find((item: Notification) => marker === `app-notification-${item.notificationRevision}`) : toasts[active.indexOf(node)]
+ if (notice) next.add(notice.id)
+ }
+ }
+ setReadable((current) => current.size === next.size && [...current].every((name) => next.has(name)) ? current : next)
}
measure()
- const observer = new ResizeObserver(measure)
- region.current?.querySelectorAll('[data-notice-id]').forEach((node) => observer.observe(node))
+ const observer = new MutationObserver(measure)
+ observer.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-visible', 'data-mounted', 'data-expanded', 'data-removed', 'style', 'class'] })
+ const resize = new ResizeObserver(measure)
+ resize.observe(root)
window.addEventListener('resize', measure)
- return () => { observer.disconnect(); window.removeEventListener('resize', measure) }
- }, [toasts, visibleCount, expanded])
+ window.visualViewport?.addEventListener('resize', measure)
+ return () => { observer.disconnect(); resize.disconnect(); window.removeEventListener('resize', measure); window.visualViewport?.removeEventListener('resize', measure) }
+ }, [toasts])
+
+ useEffect(() => {
+ if (!toasts.length) { setExpanded(false); setHovered(false); setFocused(false); setToggleFocused(false) }
+ }, [toasts.length])
+
useEffect(() => {
- const reset = () => { setHovered(false); setFocused(false) }
- const visibility = () => { setHidden(document.hidden); reset() }
- const outside = (e: PointerEvent) => { if (region.current && !region.current.contains(e.target as Node)) reset() }
- window.addEventListener('blur', reset); window.addEventListener('pointercancel', reset)
- document.addEventListener('visibilitychange', visibility); document.addEventListener('pointerdown', outside)
- return () => { window.removeEventListener('blur', reset); window.removeEventListener('pointercancel', reset); document.removeEventListener('visibilitychange', visibility); document.removeEventListener('pointerdown', outside) }
+ const reset = () => { setHovered(false); setExpanded(false); setFocused(false); setToggleFocused(false) }
+ const visibility = () => { setBackground(document.hidden || !document.hasFocus()); if (document.hidden) reset() }
+ const outside = (event: PointerEvent) => { if (!events.current?.contains(event.target as Node)) setExpanded(false) }
+ const blur = () => { setBackground(true); reset() }
+ window.addEventListener('blur', blur)
+ window.addEventListener('focus', visibility)
+ window.addEventListener('pointercancel', reset)
+ document.addEventListener('visibilitychange', visibility)
+ document.addEventListener('pointerdown', outside)
+ return () => { window.removeEventListener('blur', blur); window.removeEventListener('focus', visibility); window.removeEventListener('pointercancel', reset); document.removeEventListener('visibilitychange', visibility); document.removeEventListener('pointerdown', outside) }
}, [])
+
return <>
- {toasts.map((notice, index) => <NoticeLifetime key={notice.id} notice={notice} paused={index >= visibleCount || expanded || hidden || closing.has(notice.id)} onExpire={() => dismiss(notice, true)} />)}
- <div ref={region} className="app-notices" data-expanded={expanded} data-queued={Math.max(0, toasts.length - visibleCount)} role="region" aria-label="操作通知" onPointerEnter={(e) => {if (e.pointerType !== 'touch') setHovered(true)}} onPointerLeave={() => setHovered(false)} onFocusCapture={() => setFocused(true)} onBlurCapture={(e) => {if (!e.currentTarget.contains(e.relatedTarget)) setFocused(false)}} onKeyDown={(e) => {if (e.key === 'Escape' && toasts[0]) { e.stopPropagation(); dismiss(toasts[0]) }}}>
- {toasts.slice(0, visibleCount).map((notice, index) => <div key={notice.id} className="app-notice-layer" data-front={index === 0} style={{'--notice-index': index, zIndex: 3 - index} as React.CSSProperties} onPointerDown={(e) => {if (e.pointerType === 'touch' && !(e.target as HTMLElement).closest('button')) setHovered(true)}}>
- <Notice notice={notice} closing={closing.has(notice.id)} front={index === 0} expanded={expanded} dismiss={() => dismiss(notice)} />
- </div>)}
+ {toasts.map((notice: Notification) => <Lifetime key={notice.id} notice={notice} paused={notice.notificationRevision === undefined || background || hovered || focused || toggleFocused || expanded || !readable.has(notice.id)} />)}
+ <div ref={events} className="app-notification-events"
+ onPointerEnter={(event) => { if (event.pointerType !== 'touch') setHovered(true) }}
+ onPointerLeave={() => setHovered(false)}
+ onPointerDownCapture={(event) => { if (event.pointerType === 'touch' && !(event.target as HTMLElement).closest('.app-notification-toggle')) setExpanded(true) }}
+ onFocusCapture={(event) => {
+ const toggle = (event.target as HTMLElement).closest('.app-notification-toggle') !== null
+ setToggleFocused(toggle); setFocused(!toggle)
+ }}
+ onBlurCapture={(event) => { if (!event.currentTarget.contains(event.relatedTarget)) { setFocused(false); setToggleFocused(false) } }}
+ onKeyDownCapture={(event) => {
+ if (event.key !== 'Escape') return
+ event.stopPropagation()
+ const target = (event.target as HTMLElement).closest('[data-sonner-toast]')
+ const notice = toasts.find((item: Notification) => target?.classList.contains(`app-notification-${item.notificationRevision}`)) ?? toasts[0]
+ if (notice && notice.dismissible !== false && notice.type !== 'loading') toast.dismiss(notice.id)
+ setExpanded(false)
+ }}>
+ <Sonner {...props} ref={region} theme={theme} className="app-notifications" position="top-center"
+ richColors={false} closeButton duration={Infinity} visibleToasts={visibleCount} expand={expanded || focused} gap={8}
+ offset={{ top: 'calc(64px + env(safe-area-inset-top, 0px))', left: 12, right: 12 }}
+ mobileOffset={{ top: 'calc(64px + env(safe-area-inset-top, 0px))', left: 12, right: 12 }}
+ customAriaLabel="操作通知(Alt+T 聚焦,Esc 关闭)"
+ hotkey={['altKey', 'KeyT']}
+ toastOptions={{ ...props.toastOptions, closeButtonAriaLabel: '关闭此通知' }}
+ icons={{ success: <CircleCheckIcon size={18} />, info: <InfoIcon size={18} />, warning: <TriangleAlertIcon size={18} />, error: <OctagonXIcon size={18} /> }} />
+ {toasts.length > 1 && <button type="button" className="app-notification-toggle" style={{ top: toggleTop }}
+ aria-expanded={expanded || focused} onClick={() => { setFocused(false); setExpanded((current) => !current) }}>
+ {expanded || focused ? '收起通知' : '展开通知'}
+ </button>}
</div>
</>
}
diff --git a/src/lib/notifications.ts b/src/lib/notifications.ts
new file mode 100644
index 0000000..05b8851
--- /dev/null
+++ b/src/lib/notifications.ts
@@ -0,0 +1,81 @@
+import { isValidElement, type ReactNode } from 'react'
+import { toast as sonner, type ExternalToast, type ToastT } from 'sonner'
+
+export type Notification = ToastT & {
+ notificationDuration?: number
+ notificationRevision?: number
+ notificationAutoClosing?: { current: boolean }
+ notificationOnDismiss?: ToastT['onDismiss']
+ notificationDismissHandler?: ToastT['onDismiss']
+}
+let revision = 0
+
+// Sonner hides overflow toasts but still starts their clocks. Keep its renderer/store;
+// the Toaster starts these clocks only after a notification can actually be read.
+function managed(options: ExternalToast = {}) {
+ const previous = options.id === undefined ? undefined : sonner.getToasts().find((item) => item.id === options.id) as Notification | undefined
+ const nextRevision = ++revision
+ const autoClosing = { current: false }
+ const onDismiss = 'onDismiss' in options ? options.onDismiss : previous?.notificationOnDismiss
+ const dismissHandler = (notice: ToastT) => { if (!autoClosing.current) onDismiss?.(notice) }
+ return {
+ ...options,
+ duration: Infinity,
+ notificationDuration: options.duration ?? previous?.notificationDuration ?? 4000,
+ notificationRevision: nextRevision,
+ notificationAutoClosing: autoClosing,
+ notificationOnDismiss: onDismiss,
+ notificationDismissHandler: dismissHandler,
+ onDismiss: dismissHandler,
+ className: `${(options.className ?? '').split(/\s+/).filter((name) => !/^app-notification-\d+$/.test(name)).join(' ')} app-notification-${nextRevision}`,
+ }
+}
+
+// Other independently built features can keep importing Sonner directly.
+export function adoptNotification(notice: Notification): boolean {
+ if (notice.delete) return false
+ const current = sonner.getToasts().find((item) => item.id === notice.id) as Notification | undefined
+ if (!current || current.delete) return false
+ if (current.notificationRevision !== undefined && current.duration === Infinity && current.onDismiss === current.notificationDismissHandler) return false
+ const onDismiss = current.onDismiss === current.notificationDismissHandler ? current.notificationOnDismiss : current.onDismiss
+ const duration = current.notificationRevision !== undefined && current.duration === Infinity ? current.notificationDuration : current.duration
+ const options = managed({ ...current, duration, onDismiss })
+ // Sonner's plain message method clears type; its typed methods preserve it.
+ const publish = current.type === 'success' || current.type === 'info' || current.type === 'warning' || current.type === 'error' || current.type === 'loading'
+ ? sonner[current.type] : sonner
+ publish(current.title, options)
+ return true
+}
+
+type PromiseOptions<T> = NonNullable<Parameters<typeof sonner.promise<T>>[1]>
+function promiseResult(value: unknown, fallback: Omit<ExternalToast, 'description'>) {
+ const extended = value && typeof value === 'object' && !isValidElement(value) && 'message' in value
+ ? value as ExternalToast & { message: ReactNode }
+ : { message: value as ReactNode }
+ return { ...managed({ ...fallback, ...extended }), message: extended.message }
+}
+
+export const toast: typeof sonner = Object.assign(
+ (message: Parameters<typeof sonner>[0], options?: ExternalToast) => sonner(message, managed(options)),
+ {
+ ...sonner,
+ success: (message: Parameters<typeof sonner.success>[0], options?: ExternalToast) => sonner.success(message, managed(options)),
+ info: (message: Parameters<typeof sonner.info>[0], options?: ExternalToast) => sonner.info(message, managed(options)),
+ warning: (message: Parameters<typeof sonner.warning>[0], options?: ExternalToast) => sonner.warning(message, managed(options)),
+ error: (message: Parameters<typeof sonner.error>[0], options?: ExternalToast) => sonner.error(message, managed(options)),
+ loading: (message: Parameters<typeof sonner.loading>[0], options?: ExternalToast) => sonner.loading(message, managed(options)),
+ message: (message: Parameters<typeof sonner.message>[0], options?: ExternalToast) => sonner.message(message, managed(options)),
+ custom: (render: Parameters<typeof sonner.custom>[0], options?: ExternalToast) => sonner.custom(render, managed(options)),
+ promise: <T>(promise: Parameters<typeof sonner.promise<T>>[0], data?: PromiseOptions<T>) => {
+ if (!data) return sonner.promise(promise, data)
+ const { description, ...options } = data
+ return sonner.promise(promise, {
+ ...data,
+ ...managed(options),
+ description,
+ success: data.success === undefined ? undefined : async (value: T) => promiseResult(await (typeof data.success === 'function' ? data.success(value) : data.success), options),
+ error: data.error === undefined ? undefined : async (error: unknown) => promiseResult(await (typeof data.error === 'function' ? data.error(error) : data.error), options),
+ })
+ },
+ },
+)
diff --git a/src/notifications.css b/src/notifications.css
index 8590718..68ebac8 100644
--- a/src/notifications.css
+++ b/src/notifications.css
@@ -1,25 +1,74 @@
-.app-notices { position:fixed; z-index:1000; top:calc(64px + env(safe-area-inset-top, 0px)); left:50%; transform:translateX(-50%); width:max-content; max-width:min(440px,calc(100vw - 24px)); pointer-events:none; }
-.app-notice-layer { --notice-index:0; position:absolute; top:0; width:100%; transform:translateY(calc(var(--notice-index) * 7px)) scale(calc(1 - var(--notice-index) * .045)); transform-origin:top center; transition:transform 180ms ease,opacity 160ms ease; pointer-events:none; }
-.app-notice-layer[data-front=true] {position:relative;pointer-events:auto;}
-.app-notices[data-expanded=true] {display:flex; flex-direction:column; gap:8px; padding:2px;}
-.app-notices[data-expanded=true] .app-notice-layer {position:relative;transform:none;pointer-events:auto;}
-.app-notice {display:flex;align-items:center;gap:10px;min-width:180px;min-height:50px;padding:4px 4px 4px 16px;border:1px solid var(--border);border-radius:14px;background:var(--popover);color:var(--popover-foreground);box-shadow:0 8px 24px #00000014;font-size:14px;line-height:1.45;animation:notice-enter 180ms ease both;}
-.app-notice-content {min-width:0;flex:1;overflow-wrap:anywhere;}
-.app-notice-description {font-size:12px;opacity:.8;margin-top:3px;}
-.app-notice-icon {display:flex;flex-shrink:0;align-self:flex-start;margin-top:13px;}
-.app-notice-close {display:flex;flex-shrink:0;width:44px;height:44px;align-items:center;justify-content:center;align-self:flex-start;border-radius:10px;opacity:.75;cursor:pointer;}
-.app-notice-close:hover {background:#0000000c;opacity:1;}
-.app-notice-close:focus-visible {outline:2px solid currentColor;outline-offset:-5px;}
-.app-notice[data-kind=success] {background:#f0fdf4;border-color:#b5e8c9;color:#166546;}
-.app-notice[data-kind=error] {background:#fff1f2;border-color:#f8c6cb;color:#982a38;}
-.app-notice[data-kind=warning] {background:#fffbeb;border-color:#f0d99a;color:#81520c;}
-.dark .app-notice[data-kind=success] {background:#002617;border-color:#164734;color:#7ed4aa;}
-.dark .app-notice[data-kind=error] {background:#351419;border-color:#682e3a;color:#ffacb9;}
-.dark .app-notice[data-kind=warning] {background:#30240d;border-color:#614d23;color:#f0ce7a;}
-@keyframes notice-enter {from {opacity:0;translate:0 -8px;} to {opacity:1;translate:0 0;}}
-@media(prefers-reduced-motion:reduce) {.app-notice,.app-notice-layer {animation:none;transition:none;}}
-
-.app-notice[data-closing=true] {animation:notice-exit 160ms ease both;pointer-events:none;}
-@keyframes notice-exit {to {opacity:0;translate:0 -6px;}}
-html[data-gallery-motion=off] .app-notice,html[data-gallery-motion=off] .app-notice-layer {animation:none;transition:none;}
-@media(prefers-reduced-motion:reduce) {.app-notice[data-closing=true] {animation:none;}}
+/* Keep Sonner's absolute positioning and interruptible transform transitions. */
+[data-sonner-toaster].app-notifications[data-sonner-theme] {
+ --normal-bg: var(--popover);
+ --normal-text: var(--popover-foreground);
+ --normal-border: var(--border);
+ --border-radius: 14px;
+ --width: min(420px, calc(100vw - 24px)) !important;
+ font-family: var(--font-sans);
+ z-index: 1000;
+}
+[data-sonner-toaster].app-notifications [data-sonner-toast][data-styled=true] {
+ min-height: 56px;
+ padding: 12px 52px 12px 16px;
+ gap: 10px;
+ font-size: 14px;
+ background: var(--popover);
+ color: var(--popover-foreground);
+ border-color: var(--border);
+ box-shadow: 0 8px 24px #00000014;
+}
+[data-sonner-toaster].app-notifications [data-sonner-toast] [data-description] { color: var(--muted-foreground); font-size: 12px; }
+[data-sonner-toaster].app-notifications [data-sonner-toast] [data-icon] { margin: 0; width: 18px; height: 18px; }
+[data-sonner-toaster].app-notifications [data-type=success] [data-icon] { color: var(--chart-2); }
+[data-sonner-toaster].app-notifications [data-type=error] [data-icon] { color: var(--destructive); }
+[data-sonner-toaster].app-notifications [data-type=warning] [data-icon] { color: oklch(0.58 0.13 75); }
+[data-sonner-toaster].app-notifications [data-type=info] [data-icon] { color: var(--chart-4); }
+.dark [data-sonner-toaster].app-notifications [data-type=warning] [data-icon] { color: oklch(0.8 0.13 75); }
+[data-sonner-toaster].app-notifications [data-sonner-toast][data-styled=true] [data-close-button] {
+ left: auto;
+ right: 4px;
+ top: 4px;
+ transform: none;
+ width: 44px;
+ height: 44px;
+ border: 0;
+ border-radius: 10px;
+ background: transparent;
+ color: var(--muted-foreground);
+}
+[data-sonner-toaster].app-notifications [data-sonner-toast]:hover [data-close-button]:hover {
+ background: var(--accent);
+ color: var(--accent-foreground);
+}
+[data-sonner-toaster].app-notifications [data-sonner-toast] [data-button] { min-height: 44px; height: auto; font-size: 14px; }
+[data-sonner-toaster].app-notifications [data-sonner-toast]:focus-visible,
+[data-sonner-toaster].app-notifications button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
+/* Top stacks expose the bottom edges; all layers keep the same position model. */
+[data-sonner-toaster].app-notifications [data-sonner-toast][data-expanded=false][data-front=false] { transform-origin: bottom center; }
+.app-notification-toggle { display: none; }
+@media (pointer: coarse) {
+ .app-notification-toggle {
+ display: block;
+ position: fixed;
+ left: 50%;
+ transform: translateX(-50%);
+ z-index: 1000;
+ min-height: 44px;
+ padding: 0 16px;
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ background: var(--popover);
+ color: var(--popover-foreground);
+ font: inherit;
+ box-shadow: 0 4px 12px #00000014;
+ touch-action: manipulation;
+ }
+ .app-notification-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
+}
+html[data-gallery-motion=off] [data-sonner-toaster].app-notifications,
+html[data-gallery-motion=off] [data-sonner-toaster].app-notifications * { transition: none !important; animation: none !important; }
+@media (prefers-reduced-motion: reduce) {
+ [data-sonner-toaster].app-notifications,
+ [data-sonner-toaster].app-notifications * { transition: none !important; animation: none !important; }
+}
diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx
index e7959ae..41801dc 100644
--- a/src/routes/__root.tsx
+++ b/src/routes/__root.tsx
@@ -26,7 +26,7 @@ function RootLayout() {
</main>
</SidebarInset>
</SidebarProvider>
- <Toaster position="top-center" richColors />
+ <Toaster />
</TooltipProvider>
)
}
diff --git a/src/routes/costumes.tsx b/src/routes/costumes.tsx
index 12eb1b8..7170453 100644
--- a/src/routes/costumes.tsx
+++ b/src/routes/costumes.tsx
@@ -13,7 +13,7 @@ import {
SearchIcon,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { costumesQuery, isNsfwCostume, isNsfwCostumeCategory } from '@/api/gallery'
import { EmptyState } from '@/components/common/EmptyState'
import { PageHeader } from '@/components/common/PageHeader'
diff --git a/src/routes/portraits.tsx b/src/routes/portraits.tsx
index 30b6512..07edeeb 100644
--- a/src/routes/portraits.tsx
+++ b/src/routes/portraits.tsx
@@ -14,7 +14,7 @@ import {
SearchIcon,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { portraitsQuery } from '@/api/gallery'
import { EmptyState } from '@/components/common/EmptyState'
import { PageHeader } from '@/components/common/PageHeader'
diff --git a/src/routes/poses.tsx b/src/routes/poses.tsx
index b344c67..08f16c9 100644
--- a/src/routes/poses.tsx
+++ b/src/routes/poses.tsx
@@ -13,7 +13,7 @@ import {
SearchIcon,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { ANGLES, isNsfwPose, isNsfwPoseSystem, posesQuery } from '@/api/gallery'
import { EmptyState } from '@/components/common/EmptyState'
import { PageHeader } from '@/components/common/PageHeader'
diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx
index d764aec..d696f10 100644
--- a/src/routes/settings.tsx
+++ b/src/routes/settings.tsx
@@ -10,7 +10,7 @@ import {
SparklesIcon,
} from 'lucide-react'
import { useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { Field, Section } from '@/components/common/FormSection'
import { PageHeader } from '@/components/common/PageHeader'
import { Button } from '@/components/ui/button'
diff --git a/src/routes/studio.tsx b/src/routes/studio.tsx
index b0c39cd..90fc805 100644
--- a/src/routes/studio.tsx
+++ b/src/routes/studio.tsx
@@ -27,7 +27,7 @@ import {
XIcon,
} from 'lucide-react'
import { type ChangeEvent, type DragEvent, useEffect, useMemo, useRef, useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { costumesQuery, portraitsQuery, posesQuery } from '@/api/gallery'
import { Field, Section } from '@/components/common/FormSection'
import { WorkflowParameters } from '@/components/studio/WorkflowParameters'
diff --git a/src/store/studioStore.tsx b/src/store/studioStore.tsx
index 0fe9f13..62b4d6b 100644
--- a/src/store/studioStore.tsx
+++ b/src/store/studioStore.tsx
@@ -1,5 +1,5 @@
import { createContext, type ReactNode, useContext, useEffect, useEffectEvent, useRef, useState } from 'react'
-import { toast } from 'sonner'
+import { toast } from '@/lib/notifications'
import { isNsfwCostume, isNsfwPose } from '@/api/gallery'
import {
AlertDialog,