@@ -54,6 +54,7 @@ toVariant = case _ of
5454mkToast :: { title :: String, description :: String, color :: Color, variant :: Variant } -> JSX
5555mkToast = component "ToastStory" \props -> React.do
5656 latestToastId /\ setLatestToastId <- React.useState' (Nothing :: Maybe String)
57+ status /\ setStatus <- React.useState' "No toast added yet"
5758 let runtime = standaloneToastRuntime props.title props.description
5859 pure $ provider {}
5960 [ div { className: "dark bg-background text-foreground p-6 rounded-lg flex flex-col gap-4 max-w-lg" }
@@ -90,27 +91,27 @@ mkToast = component "ToastStory" \props -> React.do
9091 , div { className: "flex flex-wrap items-center gap-2" }
9192 [ Btn.button
9293 { color: T.Primary
93− , onPress: handler_ (showToast props setLatestToastId)
94+ , onPress: handler_ (showToast props setLatestToastId setStatus)
9495 }
9596 (text "addToast")
9697 , Btn.button
9798 { variant: T.Bordered
9899 , isDisabled: latestToastId == Nothing
99− , onPress: handler_ (closeLatest latestToastId setLatestToastId)
100+ , onPress: handler_ (closeLatest latestToastId setLatestToastId setStatus)
100101 }
101102 (text "closeToast")
102103 , Btn.button
103104 { variant: T.Flat
104105 , color: T.Danger
105− , onPress: handler_ (closeAll setLatestToastId)
106+ , onPress: handler_ (closeAll setLatestToastId setStatus)
106107 }
107108 (text "closeAllToasts")
108109 ]
109− , div { className: "text-sm text-default-500" } (statusText latestToastId)
110+ , div { className: "text-sm text-default-500" } (text status)
110111 ]
111112 ]
112113 where
113− showToast props setLatestToastId = do
114+ showToast props setLatestToastId setStatus = do
114115 latestToastId <- Toast.addToast
115116 { title: text props.title
116117 , description: text props.description
@@ -122,21 +123,22 @@ mkToast = component "ToastStory" \props -> React.do
122123 , shouldShowTimeoutProgress: true
123124 }
124125 setLatestToastId latestToastId
126+ case latestToastId of
127+ Just toastId -> setStatus ("Latest toast id: " <> toastId)
128+ Nothing -> setStatus "No toast id returned"
125129
126− closeLatest latestToastId setLatestToastId = do
130+ closeLatest latestToastId setLatestToastId setStatus = do
127131 case latestToastId of
128132 Just toastId -> do
129133 Toast.closeToast toastId
130134 setLatestToastId Nothing
131− Nothing -> pure unit
135+ setStatus ("Closed toast id: " <> toastId)
136+ Nothing -> setStatus "No tracked toast id to close"
132137
133− closeAll setLatestToastId = do
138+ closeAll setLatestToastId setStatus = do
134139 Toast.closeAllToasts
135140 setLatestToastId Nothing
136−
137− statusText = case _ of
138− Just toastId -> text ("Latest toast id: " <> toastId)
139− Nothing -> text "No toast id yet"
141+ setStatus "Closed all toasts"
140142
141143default :: JSX
142144default = story "default" mkToast