Skip to content

Commit

Permalink
make toaster duration configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Jan 19, 2024
1 parent f971454 commit eb50ac5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import { Button } from '../Button';
import { useLocalStorage } from '../../util/useLocalStorage';
import { Transition } from '@headlessui/react';

interface ToastProps extends ComponentPropsWithoutRef<'div'> {
export interface ToastProps extends ComponentPropsWithoutRef<'div'> {
error?: string;
success?: string;
theme?: string;
durationMs?: number;
}

const defaultDurationMs = 10000;

function Error(props: ToastProps) {
const { error } = props;

Expand Down Expand Up @@ -71,7 +74,7 @@ export function Toast(props: ToastProps) {
<Toaster
position="top-center"
toastOptions={{
duration: 4000,
duration: props.durationMs ?? defaultDurationMs,
}}
>
{(t) => (
Expand Down

0 comments on commit eb50ac5

Please sign in to comment.