TheSacredLipton/elm-ui-hexcolor/1.0.0

NOTE: the latest version is 1.0.1

elm-ui-hexcolor

Add hex color declarations to elm-ui.

Example

module Main exposing (view)

import Element exposing (..)
import Element.Background as Background
import Element.HexColor as HexColor


hex : (Color -> Attribute msg) -> String -> Attribute msg
hex colorattr colorhex =
    case HexColor.hex colorhex of
        Just color ->
            colorattr color

        Nothing ->
            inFront <| text <| "Color conversion failed:" ++ colorhex


bgColor : String -> Attribute msg
bgColor =
    hex Background.color


view : Element msg
view =
    el
        [ width <| px 100
        , height <| px 100
        , bgColor "#212121"
        ]
        none