mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Apply tag colors from settings
This commit is contained in:
@ -37,6 +37,7 @@ all =
|
||||
, Pink
|
||||
, Brown
|
||||
, Grey
|
||||
, Black
|
||||
]
|
||||
|
||||
|
||||
|
@ -4,9 +4,13 @@ module Data.UiSettings exposing
|
||||
, defaults
|
||||
, merge
|
||||
, mergeDefaults
|
||||
, tagColor
|
||||
, tagColorString
|
||||
, toStoredUiSettings
|
||||
)
|
||||
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
import Data.Color exposing (Color)
|
||||
import Dict exposing (Dict)
|
||||
|
||||
|
||||
@ -66,6 +70,27 @@ toStoredUiSettings settings =
|
||||
}
|
||||
|
||||
|
||||
tagColor : Tag -> UiSettings -> Maybe Color
|
||||
tagColor tag settings =
|
||||
let
|
||||
readColor c =
|
||||
Dict.get c settings.tagCategoryColors
|
||||
|> Maybe.andThen Data.Color.fromString
|
||||
in
|
||||
Maybe.andThen readColor tag.category
|
||||
|
||||
|
||||
tagColorString : Tag -> UiSettings -> String
|
||||
tagColorString tag settings =
|
||||
tagColor tag settings
|
||||
|> Maybe.map Data.Color.toString
|
||||
|> Maybe.withDefault ""
|
||||
|
||||
|
||||
|
||||
--- Helpers
|
||||
|
||||
|
||||
choose : Maybe a -> a -> a
|
||||
choose m1 m2 =
|
||||
Maybe.withDefault m2 m1
|
||||
|
Reference in New Issue
Block a user