git.iko.soy/rowtype-yoga/purescript-yoga-heroui3
on main help sign in
stories: pass plain String children instead of (text "..."); drop now-unused text imports
commitebf532a370d3ea729f82477833e2655e9aea2cd2 authorMark <mark.eibes@gmail.com> dateSun 31 May 2026, 18:39 (4 months ago) parentf504f73
2 files changed+12−10
src/HeroUI/Toast.purs+11−8 test/HeroUI/Toast/Stories.purs+1−2
src/HeroUI/Toast.purs+11−8
@@ -9,6 +9,7 @@ import Yoga.React.DOM.Internal (class IsJSX)
99import Data.Function.Uncurried (runFn4)
1010import HeroUI.Internal (class CoerceHeroProps, createElementTransformImpl)
1111import HeroUI.Raw as Raw
12+import Unsafe.Coerce (unsafeCoerce)
1213
1314-- Render the provider once near the root of the app; fire toasts imperatively.
1415type ToastProviderProps r =
@@ -64,17 +65,19 @@ foreign import closeAllToastsImpl :: Effect Unit
6465foreign import pauseAllToastsImpl :: Effect Unit
6566foreign import resumeAllToastsImpl :: Effect Unit
6667
67−toastSuccess :: JSX -> Effect String
68−toastSuccess = runEffectFn1 toastSuccessImpl
68+-- | The message accepts anything renderable (`IsJSX`): a plain `String`, a
69+-- | `JSX` element, or an `Array JSX`.
70+toastSuccess :: forall msg. IsJSX msg => msg -> Effect String
71+toastSuccess msg = runEffectFn1 toastSuccessImpl (unsafeCoerce msg)
6972
70−toastDanger :: JSX -> Effect String
71−toastDanger = runEffectFn1 toastDangerImpl
73+toastDanger :: forall msg. IsJSX msg => msg -> Effect String
74+toastDanger msg = runEffectFn1 toastDangerImpl (unsafeCoerce msg)
7275
73−toastInfo :: JSX -> Effect String
74−toastInfo = runEffectFn1 toastInfoImpl
76+toastInfo :: forall msg. IsJSX msg => msg -> Effect String
77+toastInfo msg = runEffectFn1 toastInfoImpl (unsafeCoerce msg)
7578
76−toastWarning :: JSX -> Effect String
77−toastWarning = runEffectFn1 toastWarningImpl
79+toastWarning :: forall msg. IsJSX msg => msg -> Effect String
80+toastWarning msg = runEffectFn1 toastWarningImpl (unsafeCoerce msg)
7881
7982closeToast :: String -> Effect Unit
8083closeToast = runEffectFn1 closeToastImpl
test/HeroUI/Toast/Stories.purs+1−2
@@ -8,14 +8,13 @@ import HeroUI.Button as Btn
88import HeroUI.Toast as Toast
99import Yoga.React (component)
1010import Yoga.React.DOM.HTML (div)
11−import Yoga.React.DOM.Internal (text)
1211import YogaStories.Story (story)
1312
1413mkToast :: { message :: String } -> JSX
1514mkToast = component "ToastStory" \props -> React.do
1615 pure $ div { className: "dark bg-background text-foreground p-6 rounded-lg" }
1716 [ Toast.toastProvider { placement: "bottom-right" } ([] :: Array JSX)
18− , Btn.button { variant: Btn.Primary, onPress: handler_ (void (Toast.toastSuccess (text props.message))) }
17+ , Btn.button { variant: Btn.Primary, onPress: handler_ (void (Toast.toastSuccess props.message)) }
1918 "Show toast"
2019 ]
2120