import React from 'react'; import { PxlKitToastProvider, useToast } from './PxlKitToastProvider'; import { PixelButton } from '../actions'; function TriggerRow({ children }: { children: React.ReactNode }) { return
{children}
; } function DefaultTriggers() { const { toast } = useToast(); return ( toast({ title: 'Saved', message: 'Your changes were persisted.' })}> Push toast ); } export function Default() { return ( ); } function ToneTriggers() { const { toast } = useToast(); return ( toast.success('Saved', 'Changes persisted.')}> Success toast.info('Heads up', 'New release available.')}> Info toast.warning('Careful', 'Storage almost full.')}> Warning toast.error('Failed', 'Upload could not finish.')}> Error ); } export function Tones() { return ( ); } function PositionTriggers() { const { toast } = useToast(); return ( toast({ title: 'Bottom-right toast' })}> Push to bottom-right ); } export function BottomRight() { return ( ); } export function TopCenter() { return ( ); } function StackedTriggers() { const { toast } = useToast(); return ( { toast({ title: 'First', message: 'Oldest of the stack.' }); toast({ title: 'Second', message: 'In the middle.' }); toast({ title: 'Third', message: 'Newest in front.' }); }} > Push three ); } export function Stacked() { return ( ); } export function Flat() { return ( ); } function SurfaceTriggers() { const { toast } = useToast(); return ( toast({ title: 'Pixel surface', message: 'HP-bar accent on the left edge.', tone: 'cyan' }) } > Push pixel toast ); } export function PixelSurface() { return ( ); } export function LinearSurface() { return ( ); } function LoadingTriggers() { const { toast } = useToast(); return ( { const id = toast.loading('Uploading…', 'Hang tight.'); setTimeout(() => { toast.update(id, { title: 'Uploaded', message: 'File is ready.', tone: 'green', loading: false, duration: 4500, }); }, 1500); }} > Run loading → success ); } export function Loading() { return ( ); } function PromiseTriggers() { const { toast } = useToast(); return ( toast.promise( () => new Promise((resolve) => setTimeout(() => resolve('ok'), 1500)), { loading: { title: 'Saving…' }, success: { title: 'Saved', message: 'All set.' }, error: { title: 'Failed', message: 'Try again.' }, }, ) } > Run promise ); } export function PromiseFlow() { return ( ); } function MaxTriggers() { const { toast } = useToast(); return ( { for (let i = 1; i <= 5; i += 1) { toast({ title: `Toast ${i}`, message: 'Only the latest two stay.' }); } }} > Push five (max 2) ); } export function MaxLimit() { return ( ); } function ActionTriggers() { const { toast } = useToast(); return ( toast({ tone: 'red', title: 'File deleted', message: 'You can still restore it.', action: ( Undo ), }) } > Push with action ); } export function WithAction() { return ( ); }