diff --git a/packages/react/components/Toast.tsx b/packages/react/components/Toast.tsx index 7909d12..afa5578 100644 --- a/packages/react/components/Toast.tsx +++ b/packages/react/components/Toast.tsx @@ -256,11 +256,23 @@ const ToastTemplate = ({ ); }; -const Toaster = ({ - defaultOption, -}: { +const [toasterVariant, resolveToasterVariantProps] = vcn({ + base: "fixed p-4 flex flex-col gap-4 top-0 right-0 w-full md:max-w-md md:bottom-0 md:top-auto pointer-events-none z-40", + variants: {}, + defaults: {}, +}); + +interface ToasterProps + extends React.ComponentPropsWithoutRef<"div">, + VariantProps { defaultOption?: Partial; -}) => { +} + +const Toaster = React.forwardRef((props, ref) => { + const [variantProps, otherPropsCompressed] = + resolveToasterVariantProps(props); + const { defaultOption, ...otherPropsExtracted } = otherPropsCompressed; + const [toastList, setToastList] = React.useState(toasts); useEffect(() => { @@ -280,7 +292,11 @@ const Toaster = ({ return ( <> {ReactDOM.createPortal( -
+
{Object.entries(toastList).map(([id]) => ( ); -}; +}); export { Toaster, useToast };