Extract tag dropdown into a separate component

This commit is contained in:
eikek
2022-01-15 13:26:32 +01:00
parent 829fb2af87
commit ab2b18e192
16 changed files with 335 additions and 157 deletions

View File

@ -9,41 +9,14 @@ module Util.Tag exposing
( catSettings
, getCategories
, makeCatDropdownModel
, makeDropdownModel
, tagSettings
)
import Api.Model.Tag exposing (Tag)
import Comp.Dropdown
import Data.DropdownStyle as DS
import Data.UiSettings
import Util.List
makeDropdownModel : Comp.Dropdown.Model Tag
makeDropdownModel =
let
init =
Comp.Dropdown.makeModel
{ multiple = True
, searchable = \n -> n > 0
}
in
{ init | searchWithAdditional = True }
tagSettings : String -> DS.DropdownStyle -> Comp.Dropdown.ViewSettings Tag
tagSettings placeholder ds =
{ makeOption = \tag -> { text = tag.name, additional = Maybe.withDefault "" tag.category }
, labelColor =
\tag ->
\settings ->
Data.UiSettings.tagColorString2 tag settings
, placeholder = placeholder
, style = ds
}
makeCatDropdownModel : Comp.Dropdown.Model String
makeCatDropdownModel =
Comp.Dropdown.makeModel