Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/sileo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ interface SileoProps {
onMouseEnter?: MouseEventHandler<HTMLButtonElement>;
onMouseLeave?: MouseEventHandler<HTMLButtonElement>;
onDismiss?: () => void;
dismiss?: boolean;
}

/* ---------------------------------- Icons --------------------------------- */
Expand Down Expand Up @@ -136,6 +137,7 @@ export const Sileo = memo(function Sileo({
onMouseEnter,
onMouseLeave,
onDismiss,
dismiss,
}: SileoProps) {
const next: View = useMemo(
() => ({ title, description, state, icon, styles, button, fill }),
Expand Down Expand Up @@ -542,6 +544,12 @@ export const Sileo = memo(function Sileo({
if (exiting || !onDismiss) return;
const target = e.target as HTMLElement;
if (target.closest("[data-sileo-button]")) return;

if (dismiss) {
onDismiss();
return;
}

pointerStartRef.current = e.clientY;
e.currentTarget.setPointerCapture(e.pointerId);
const el = buttonRef.current;
Expand All @@ -551,7 +559,7 @@ export const Sileo = memo(function Sileo({
el.addEventListener("pointerup", h.onUp, { passive: true });
}
},
[exiting, onDismiss],
[exiting, onDismiss, dismiss],
);

/* --------------------------------- Render --------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export function Toaster({
onMouseEnter={h.enter}
onMouseLeave={h.leave}
onDismiss={h.dismiss}
dismiss={item.dismiss}
/>
);
})}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ export interface SileoOptions {
roundness?: number;
autopilot?: boolean | { expand?: number; collapse?: number };
button?: SileoButton;
dismiss?: boolean;
}