{-# LANGUAGE AllowAmbiguousTypes #-}

module Dashi.Components.Widget where

import Clay (Css)
import Miso.Prelude

class Widget w model action where
    widget' :: [Attribute action] -> w -> View model action
    widget :: w -> View model action
    widget = [Attribute action] -> w -> View model action
forall w model action.
Widget w model action =>
[Attribute action] -> w -> View model action
widget' []
    style :: Css

data SomeWidget = forall w model action. (Widget w model action) => SomeWidget w

instance Widget () model action where
    widget' :: [Attribute action] -> () -> View model action
widget' [Attribute action]
_ () = Maybe Key -> MisoString -> View model action
forall model action. Maybe Key -> MisoString -> View model action
VText Maybe Key
forall a. Maybe a
Nothing MisoString
""
    style :: Css
style = () -> Css
forall a. a -> StyleM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

instance Widget (View model action) model action where
    widget' :: [Attribute action] -> View model action -> View model action
    widget' :: [Attribute action] -> View model action -> View model action
widget' [Attribute action]
_ View model action
view = View model action
view
    style :: Css
style = () -> Css
forall a. a -> StyleM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()