{-# OPTIONS_GHC -Wno-missing-role-annotations #-}

module Dashi.Components.Breadcrumbs where

import Clay hiding (Color, action, href, label, span_)
import Dashi.Components.Icon
    ( Phosphor (CaretRight)
    , Weight (Bold)
    , iconContent
    , iconFontFamilyOverride
    )
import Dashi.Prelude hiding (has, (#), (&), (|>))
import Dashi.Style.Text (TextColour (TextColour))
import Dashi.Style.Tokens
import Dashi.Style.Util (color', fontSize', has, paddingYX, token)
import Data.List qualified as List
import Miso.Html.Element (div_, span_)
import Miso.Html.Property (class_)

newtype Breadcrumbs model action = Breadcrumbs {forall model action.
Breadcrumbs model action -> [View model action]
crumbs :: [View model action]}

instance Widget (Breadcrumbs model action) model action where
    widget' :: [Attribute action] -> Breadcrumbs model action -> View model action
widget' [Attribute action]
attrs Breadcrumbs{[View model action]
crumbs :: forall model action.
Breadcrumbs model action -> [View model action]
crumbs :: [View model action]
..} = [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
div_ (MisoString -> Attribute action
forall action. MisoString -> Attribute action
class_ MisoString
"breadcrumbs" Attribute action -> [Attribute action] -> [Attribute action]
forall a. a -> [a] -> [a]
: [Attribute action]
attrs) ([View model action] -> View model action)
-> [View model action] -> View model action
forall a b. (a -> b) -> a -> b
$ View model action -> [View model action] -> [View model action]
forall a. a -> [a] -> [a]
List.intersperse View model action
separator [View model action]
crumbs
      where
        separator :: View model action
        separator :: View model action
separator = [Attribute action] -> [View model action] -> View model action
forall action model.
[Attribute action] -> [View model action] -> View model action
span_ [MisoString -> Attribute action
forall action. MisoString -> Attribute action
class_ MisoString
"separator"] []
    style :: Css
style =
        Selector
".breadcrumbs" Selector -> Css -> Css
? do
            Display -> Css
display Display
flex
            FlexDirection -> Css
flexDirection FlexDirection
row
            Selector
".separator" Selector -> Css -> Css
? do
                TextColour -> Css
forall t. Token t => t -> Css
color' (Appearance -> TextColour
TextColour Appearance
Subtle)
                Size LengthUnit -> Size LengthUnit -> Css
forall a. Size a -> Size a -> Css
paddingYX Size LengthUnit
forall a. Size a
nil (Size LengthUnit -> Css)
-> (Space -> Size LengthUnit) -> Space -> Css
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Space -> Size LengthUnit
Space -> ValueType Space
forall t.
(Token t, Val (ValueType t), Other (ValueType t)) =>
t -> ValueType t
token (Space -> Css) -> Space -> Css
forall a b. (a -> b) -> a -> b
$ SizeToken -> Space
Space SizeToken
XSmall
                Weight -> Css
iconFontFamilyOverride Weight
Bold
                SizeToken -> Css
fontSize' SizeToken
Small
                Refinement
before Refinement -> Css -> Css
& Content -> Css
content (Phosphor -> Content
iconContent Phosphor
CaretRight)
                AlignSelfValue -> Css
alignSelf AlignSelfValue
forall a. Center a => a
center
            Selector -> Refinement
has Selector
".icon" Refinement -> Css -> Css
& Selector
".separator" Selector -> Css -> Css
? do
                Position -> Css
position Position
relative
                Size LengthUnit -> Css
forall a. Size a -> Css
top (Size LengthUnit -> Css)
-> (Number -> Size LengthUnit) -> Number -> Css
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Number -> Size LengthUnit
em (Number -> Css) -> Number -> Css
forall a b. (a -> b) -> a -> b
$ -Number
0.05