diff --git a/example/storybook-nativewind/src/components/Toast/Toast.tsx b/example/storybook-nativewind/src/components/Toast/Toast.tsx index 262ed4164..4f3ac5fed 100644 --- a/example/storybook-nativewind/src/components/Toast/Toast.tsx +++ b/example/storybook-nativewind/src/components/Toast/Toast.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Icon, CloseIcon } from '@/components/ui/icon'; import { VStack } from '@/components/ui/vstack'; import { Pressable } from '@/components/ui/pressable'; @@ -26,31 +26,46 @@ const ToastFigmaStory = ({ _placement = 'top', _colorMode, ...props }: any) => { ); }; -const ToastBasic = ({ placement = 'top', ...props }: any) => { +const ToastBasic = ({ ...props }: any) => { const toast = useToast(); + const [toastId, setToastId] = useState(0); + + const handleToast = () => { + if (!toast.isActive(toastId)) { + showNewToast(); + } + }; + + const showNewToast = () => { + const newId = Math.random(); + setToastId(newId); + + toast.show({ + id: newId, + placement: props.placement, + duration: 3000, + // duration: null, + render: ({ id }) => { + const uniqueToastId = `toast-${id}`; + return ( + + + Hello World Toast + + Please create a support ticket from the support page + + + toast.close(id)}> + + + + ); + }, + }); + }; + return ( - ); diff --git a/example/storybook-nativewind/src/components/Toast/index.nw.stories.mdx b/example/storybook-nativewind/src/components/Toast/index.nw.stories.mdx index ae7bd4014..53daa3f03 100644 --- a/example/storybook-nativewind/src/components/Toast/index.nw.stories.mdx +++ b/example/storybook-nativewind/src/components/Toast/index.nw.stories.mdx @@ -61,32 +61,41 @@ This is an illustration of **Toast** component. showArgsController={true} metaData={{ code: ` - function Example() { + function Example() { const toast = useToast(); + const [toastId, setToastId] = React.useState(0); + const handleToast = () => { + if (!toast.isActive(toastId)) { + showNewToast(); + } + }; + const showNewToast = () => { + const newId = Math.random(); + setToastId(newId); + toast.show({ + id: newId, + placement: 'top', + duration: 3000, + // duration: null, + render: ({ id }) => { + const uniqueToastId = "toast-" + id; + return ( + + Toast Heading + + Lorem ipsum dolor sit amet consectetur. + + + ); + }, + }); + }; return ( - ); - }; + } `, transformCode: (code) => { return transformedCode(code, 'function', 'Example'); @@ -405,64 +414,61 @@ The Examples section provides visual representations of the different variants o showArgsController={false} metaData={{ code: ` - function Example() { + function Example() { const toast = useToast(); + const [toastId, setToastId] = React.useState(0); + const handleToast = () => { + if (!toast.isActive(toastId)) { + showNewToast(); + } + }; + const showNewToast = () => { + const newId = Math.random(); + setToastId(newId); + toast.show({ + id: newId, + placement: 'top', + duration: 3000, + render: ({ id }) => { + const uniqueToastId = "toast-" + id; + return ( + + + + + Toast Heading + + Lorem ipsum dolor sit amet consectetur. + + + + + + toast.close(id)}> + + + + + ); + }, + }); + }; return ( - - toast.close(id)}> - - - - - ); - }, - }); - }} - > - Show Toast + ); - }; + } `, transformCode: (code) => { return transformedCode(code, 'function', 'Example'); @@ -583,68 +589,74 @@ The Examples section provides visual representations of the different variants o metaData={{ code: ` function Example() { - const toast = useToast(); - return ( - - - - - - ); - }, - }); - }} - > - Show Toast - - ); + Not now + + + + + + ); + }, + }); }; + return ( + + ); + } `, transformCode: (code) => { return transformedCode(code, 'function', 'Example');