💀 remove the Theme concept

This commit is contained in:
Tessa Kelly 2020-07-02 13:20:04 -07:00
parent 3b84784f27
commit d45acff065

View File

@ -156,7 +156,18 @@ info :
-> Model -> Model
-> Html msg -> Html msg
info config getFocusable model = info config getFocusable model =
view Info config getFocusable model view
config.wrapMsg
config.title
[ overlayColor (Nri.Ui.Colors.Extra.withAlpha 0.9 Colors.navy)
, size
, titleAttribute Colors.navy config.visibleTitle
, getFocusable
{ viewContent = viewContent config.visibleTitle
, closeButton = closeButton config.wrapMsg
}
]
model
{-| -} {-| -}
@ -174,32 +185,18 @@ warning :
-> Model -> Model
-> Html msg -> Html msg
warning config getFocusable model = warning config getFocusable model =
view Warning config getFocusable model view
config.wrapMsg
config.title
type Theme [ overlayColor (Nri.Ui.Colors.Extra.withAlpha 0.9 Colors.gray20)
= Info , size
| Warning , titleAttribute Colors.red config.visibleTitle
, getFocusable
{ viewContent = viewContent config.visibleTitle
themeToOverlayColor : Theme -> Css.Color , closeButton = closeButton config.wrapMsg
themeToOverlayColor theme = }
case theme of ]
Info -> model
Colors.navy
Warning ->
Colors.gray20
themeToTitleColor : Theme -> Css.Color
themeToTitleColor theme =
case theme of
Info ->
Colors.navy
Warning ->
Colors.red
@ -318,8 +315,8 @@ onlyFocusableElementView f =
) )
titleAttribute : Theme -> Bool -> Attribute msg titleAttribute : Color -> Bool -> Attribute msg
titleAttribute theme visibleTitle = titleAttribute titleColor visibleTitle =
if visibleTitle then if visibleTitle then
titleStyles titleStyles
[ Fonts.baseFont [ Fonts.baseFont
@ -329,7 +326,7 @@ titleAttribute theme visibleTitle =
, Css.margin Css.zero , Css.margin Css.zero
, Css.fontSize (Css.px 20) , Css.fontSize (Css.px 20)
, Css.textAlign Css.center , Css.textAlign Css.center
, Css.color (themeToTitleColor theme) , Css.color titleColor
] ]
else else
@ -365,52 +362,12 @@ size =
view : view :
Theme
->
{ visibleTitle : Bool
, title : String
, wrapMsg : Msg -> msg
}
->
({ viewContent : { content : List (Html msg), footer : List (Html msg) } -> Html msg
, closeButton : List (Html.Attribute msg) -> Html msg
}
-> Attribute msg
)
-> Model
-> Html msg
view theme config getFocusable model =
let
viewFuncs =
{ viewContent = viewContent config.visibleTitle
, closeButton = closeButton config.wrapMsg
}
focusables : Attribute msg
focusables =
getFocusable viewFuncs
in
view_
config.wrapMsg
config.title
([ overlayColor (Nri.Ui.Colors.Extra.withAlpha 0.9 (themeToOverlayColor theme))
, size
, titleAttribute theme config.visibleTitle
]
++ [ focusables ]
)
model
|> List.singleton
|> div [ css [ Css.position Css.relative, Css.zIndex (Css.int 1) ] ]
view_ :
(Msg -> msg) (Msg -> msg)
-> String -> String
-> List (Attribute msg) -> List (Attribute msg)
-> Model -> Model
-> Html msg -> Html msg
view_ wrapMsg ti attributes model = view wrapMsg ti attributes model =
let let
config = config =
List.foldl (\(Attribute f) acc -> f acc) (defaults wrapMsg ti) attributes List.foldl (\(Attribute f) acc -> f acc) (defaults wrapMsg ti) attributes
@ -426,6 +383,8 @@ view_ wrapMsg ti attributes model =
, height (pct 100) , height (pct 100)
, displayFlex , displayFlex
, alignItems center , alignItems center
, position relative
, zIndex (int 1)
] ]
] ]
[ viewBackdrop config [ viewBackdrop config