Fix snooze dropdown clipping in toasts, add Dismiss label to banner

- SnoozeDropdown: added direction prop (up/down), toasts use 'down'
  so dropdown opens below the button instead of clipping off-screen
- AlertBanner dismiss button now shows X icon + 'Dismiss' text to
  match toast style

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-02-24 03:37:13 +08:00
parent 6cd5b71d1c
commit 0c767317ab
3 changed files with 8 additions and 3 deletions

View File

@ -38,9 +38,10 @@ export default function AlertBanner({ alerts, onDismiss, onSnooze }: AlertBanner
<button <button
onClick={() => onDismiss(alert.id)} onClick={() => onDismiss(alert.id)}
aria-label={`Dismiss "${alert.title}"`} aria-label={`Dismiss "${alert.title}"`}
className="p-1 rounded hover:bg-accent/10 hover:text-accent text-muted-foreground transition-colors shrink-0" className="flex items-center gap-1 px-1.5 py-1 rounded hover:bg-accent/10 hover:text-accent text-muted-foreground transition-colors shrink-0"
> >
<X className="h-3.5 w-3.5" /> <X className="h-3.5 w-3.5" />
<span className="text-[11px] font-medium">Dismiss</span>
</button> </button>
</div> </div>
))} ))}

View File

@ -4,6 +4,7 @@ import { Clock } from 'lucide-react';
interface SnoozeDropdownProps { interface SnoozeDropdownProps {
onSnooze: (minutes: 5 | 10 | 15) => void; onSnooze: (minutes: 5 | 10 | 15) => void;
label: string; label: string;
direction?: 'up' | 'down';
} }
const OPTIONS: { value: 5 | 10 | 15; label: string }[] = [ const OPTIONS: { value: 5 | 10 | 15; label: string }[] = [
@ -12,7 +13,7 @@ const OPTIONS: { value: 5 | 10 | 15; label: string }[] = [
{ value: 15, label: '15 minutes' }, { value: 15, label: '15 minutes' },
]; ];
export default function SnoozeDropdown({ onSnooze, label }: SnoozeDropdownProps) { export default function SnoozeDropdown({ onSnooze, label, direction = 'up' }: SnoozeDropdownProps) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
@ -38,7 +39,9 @@ export default function SnoozeDropdown({ onSnooze, label }: SnoozeDropdownProps)
<span className="text-[11px] font-medium">Snooze</span> <span className="text-[11px] font-medium">Snooze</span>
</button> </button>
{open && ( {open && (
<div className="absolute right-0 bottom-full mb-1 w-32 rounded-md border bg-popover shadow-lg z-50 py-1 animate-fade-in"> <div className={`absolute right-0 w-32 rounded-md border bg-popover shadow-lg z-50 py-1 animate-fade-in ${
direction === 'up' ? 'bottom-full mb-1' : 'top-full mt-1'
}`}>
{OPTIONS.map((opt) => ( {OPTIONS.map((opt) => (
<button <button
key={opt.value} key={opt.value}

View File

@ -110,6 +110,7 @@ export function AlertsProvider({ children }: { children: ReactNode }) {
<SnoozeDropdown <SnoozeDropdown
onSnooze={(m) => snoozeRef.current(reminder.id, m)} onSnooze={(m) => snoozeRef.current(reminder.id, m)}
label={reminder.title} label={reminder.title}
direction="down"
/> />
<button <button
onClick={() => dismissRef.current(reminder.id)} onClick={() => dismissRef.current(reminder.id)}