-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultilineStrings  #-}
{-# LANGUAGE RecordWildCards   #-}
-----------------------------------------------------------------------------
module Miso.UI.Kbd
  ( -- ** Props
    KbdProps (..)
  , defaultKbdProps
    -- ** Views
  , kbd_
  , kbdGroup_
    -- ** Samples
  , kbdSample
  , kbdCodeSample
  , kbdPropsApi
  ) where
-----------------------------------------------------------------------------
import           Miso
import qualified Miso.Html.Element as H
import qualified Miso.Html.Property as P
-----------------------------------------------------------------------------
-- | Props for 'kbd_'
data KbdProps action
  = KbdProps
  { forall action. KbdProps action -> [MisoString]
kbdClasses :: [MisoString]
    -- ^ Extra classes appended to @kbd@
  , forall action. KbdProps action -> [Attribute action]
kbdAttrs :: [Attribute action]
  }
-----------------------------------------------------------------------------
-- | Smart constructor
defaultKbdProps :: KbdProps action
defaultKbdProps :: forall action. KbdProps action
defaultKbdProps
  = KbdProps
  { kbdClasses :: [MisoString]
kbdClasses = []
  , kbdAttrs :: [Attribute action]
kbdAttrs = []
  }
-----------------------------------------------------------------------------
-- | <https://basecoatui.com/components/kbd/ Kbd>, driven by 'KbdProps'
kbd_
  :: KbdProps action
  -> [View model action]
  -> View model action
kbd_ :: forall action model.
KbdProps action -> [View model action] -> View model action
kbd_ KbdProps {[MisoString]
[Attribute action]
kbdClasses :: forall action. KbdProps action -> [MisoString]
kbdAttrs :: forall action. KbdProps action -> [Attribute action]
kbdClasses :: [MisoString]
kbdAttrs :: [Attribute action]
..} [View model action]
kids =
  [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
H.kbd_
    ( [MisoString] -> Attribute action
forall action. [MisoString] -> Attribute action
P.classes_ (MisoString
"kbd" MisoString -> [MisoString] -> [MisoString]
forall a. a -> [a] -> [a]
: [MisoString]
kbdClasses)
    Attribute action -> [Attribute action] -> [Attribute action]
forall a. a -> [a] -> [a]
: [Attribute action]
kbdAttrs
    ) [View model action]
kids
-----------------------------------------------------------------------------
-- | Groups several 'kbd_' keys on one line
kbdGroup_
  :: [Attribute action]
  -> [View model action]
  -> View model action
kbdGroup_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
kbdGroup_ [Attribute action]
attrs [View model action]
kids =
  [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
H.span_
    ( MisoString -> Attribute action
forall action. MisoString -> Attribute action
P.class_ MisoString
"inline-flex items-center gap-1"
    Attribute action -> [Attribute action] -> [Attribute action]
forall a. a -> [a] -> [a]
: [Attribute action]
attrs
    ) [View model action]
kids
-----------------------------------------------------------------------------
kbdSample :: View model action
kbdSample :: forall model action. View model action
kbdSample =
  [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
H.div_
  [ MisoString -> Attribute action
forall action. MisoString -> Attribute action
P.class_ MisoString
"flex flex-col items-center gap-4" ]
  [ [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
kbdGroup_ []
    [ KbdProps action -> [View model action] -> View model action
forall action model.
KbdProps action -> [View model action] -> View model action
kbd_ KbdProps action
forall action. KbdProps action
defaultKbdProps [ View model action
k ] | View model action
k <- [ View model action
"⌘", View model action
"⇧", View model action
"⌥", View model action
"⌃" ] ]
  , [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
kbdGroup_ []
    [ KbdProps action -> [View model action] -> View model action
forall action model.
KbdProps action -> [View model action] -> View model action
kbd_ KbdProps action
forall action. KbdProps action
defaultKbdProps [ View model action
"Ctrl" ]
    , [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
H.span_ [] [ View model action
"+" ]
    , KbdProps action -> [View model action] -> View model action
forall action model.
KbdProps action -> [View model action] -> View model action
kbd_ KbdProps action
forall action. KbdProps action
defaultKbdProps [ View model action
"B" ]
    ]
  ]
-----------------------------------------------------------------------------
kbdCodeSample :: View model action
kbdCodeSample :: forall model action. View model action
kbdCodeSample =
  View model action
"""
  -----------------------------------------------------------------------------
  module MyKbd (kbdSample) where
  -----------------------------------------------------------------------------
  import           Miso
  import qualified Miso.Html.Element as H
  import qualified Miso.Html.Property as P
  import           Miso.UI.Kbd
  -----------------------------------------------------------------------------
  kbdSample :: View model action
  kbdSample =
    H.div_
    [ P.class_ "flex flex-col items-center gap-4" ]
    [ kbdGroup_ []
      [ kbd_ defaultKbdProps [ k ] | k <- [ "⌘", "⇧", "⌥", "⌃" ] ]
    , kbdGroup_ []
      [ kbd_ defaultKbdProps [ "Ctrl" ]
      , H.span_ [] [ "+" ]
      , kbd_ defaultKbdProps [ "B" ]
      ]
    ]
  """
-----------------------------------------------------------------------------
kbdPropsApi :: View model action
kbdPropsApi :: forall model action. View model action
kbdPropsApi =
  View model action
"""
  -- | Props for 'kbd_'
  data KbdProps action
    = KbdProps
    { kbdClasses :: [MisoString]
      -- ^ Extra classes appended to @kbd@
    , kbdAttrs :: [Attribute action]
    }
  -----------------------------------------------------------------------------
  -- | Smart constructor
  defaultKbdProps :: KbdProps action
  defaultKbdProps
    = KbdProps
    { kbdClasses = []
    , kbdAttrs = []
    }
  """
-----------------------------------------------------------------------------