PaackEng/paack-ui/6.8.0

NOTE: the latest version is 7.23.0

UI.Palette.V2

UI.Palette is an interface offering all colors variations proposed in the design system.

Palette.blue600
    |> Palette.toElementColor

Which color

Shorthand for the most common occurrence of blue. Equivalent to blue700

Shorthand for the most common occurrence of gray. Equivalent to gray700

Shorthand for the most common occurrence of green. Equivalent to green500

Shorthand for the most common occurrence of red. Equivalent to red600

Shorthand for the most common occurrence of yellow. Equivalent to yellow500

Which hue

type Hue

The design system describes four main entries that here are called Hues.

A hue is one of the five pure colors of the palette.

Which shade

type Shade

Each hue can be paired with eight different shades.

The shades are 800, 700, 600, 500, 400, 300, 200 and 100.

Building

type Color

Palette.Color holds data about some desired color.

Given a hue and shade it constructs a color.

Palette.color hueBlue shade600
toBackgroundColor : Color -> Attribute msg

Shorthand for setting background colors

Element.row
    [ Palette.blue600 |> Palette.toBackgroundColor
    ]
    []
toFontColor : Color -> Attribute msg

Shorthand for setting font colors

Element.row
    [ Palette.blue600 |> Palette.toFontColor
    , Font.size 16
    , Font.justify
    ]
    []
toBorderColor : Color -> Attribute msg

Shorthand for setting border colors

Element.row
    [ Palette.blue600 |> Palette.toBorderColor
    , Border.width 2
    , Border.solid
    ]
    []

Making it transparent

withAlpha : Float -> Color -> Color

Applies an alpha value to the color adding transparency.

backgroundColor
    |> Palette.withAlpha 0.5
    |> Palette.toElementColor
    |> Element.Background.color

Obtaining a usable variation

Manually transforms a Palette.Color into an Elm-UI-compatible color.

let
    backgroundColor =
        Palette.color tonePrimary brightnessMiddle
in
Element.el
    [ backgroundColor
        |> Palette.toElementColor
        |> Element.Font.color
    , backgroundColor
        |> Palette.toElementColor
        |> Element.Background.color
    ]
<|
    Element.text "Hello World!"
toCssColor : Color -> String

Transforms a Palette.Color into a CSS-compatible parameter.

Palette.blue700
    |> Palette.toCssColor
    |> Html.Attributes.style "font-color"