Refactor FixedDropdown

This commit is contained in:
Eike Kettner
2021-04-02 22:46:47 +02:00
parent 8d15d97857
commit 9a23ba9afb
16 changed files with 170 additions and 176 deletions

View File

@ -81,7 +81,7 @@ init flags sett =
Data.ListType.fromString sett.listType
|> Maybe.withDefault Data.ListType.Whitelist
, categoryListTypeModel =
Comp.FixedDropdown.initMap Data.ListType.label Data.ListType.all
Comp.FixedDropdown.init Data.ListType.all
}
, Cmd.batch
[ Api.getTags flags "" GetTagsResp
@ -181,18 +181,18 @@ update flags msg model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
catListTypeItem =
Comp.FixedDropdown.Item
model.categoryListType
(Data.ListType.label model.categoryListType)
Nothing
categoryCfg =
{ makeOption = \s -> { text = s, additional = "" }
, labelColor = \_ -> \_ -> "grey "
, placeholder = "Choose categories "
, style = DS.mainStyle
}
catListCfg =
{ display = Data.ListType.label
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
div []
[ Markdown.toHtml [ class "px-2 py-2 opacity-75" ]
@ -201,7 +201,11 @@ view2 texts settings model =
[ label [ class S.inputLabel ]
[ text texts.blacklistOrWhitelist ]
, Html.map CategoryListTypeMsg
(Comp.FixedDropdown.view2 (Just catListTypeItem) model.categoryListTypeModel)
(Comp.FixedDropdown.viewStyled2 catListCfg
False
(Just model.categoryListType)
model.categoryListTypeModel
)
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]