orus-io/elm-orus-ui/1.0.1

Formerly cdevienne/elm-orus-ui. Search finds this package by either name.

OUI.Material.Color

Material 3 color utilities and scheme

Types

type alias KeyColors =
{ primary : Color
, secondary : Color
, tertiary : Color
, error : Color
, neutral : Color
, neutralVariant : Color
}

A set of colors suitable for generating a color scheme

type alias Scheme =
{ keyColors : KeyColors
, primary : Color
, primaryContainer : Color
, onPrimary : Color
, onPrimaryContainer : Color
, inversePrimary : Color
, secondary : Color
, secondaryContainer : Color
, onSecondary : Color
, onSecondaryContainer : Color
, tertiary : Color
, tertiaryContainer : Color
, onTertiary : Color
, onTertiaryContainer : Color
, surface : Color
, surfaceDim : Color
, surfaceBright : Color
, surfaceContainerLowest : Color
, surfaceContainerLow : Color
, surfaceContainer : Color
, surfaceContainerHigh : Color
, surfaceContainerHighest : Color
, surfaceVariant : Color
, onSurface : Color
, onSurfaceVariant : Color
, inverseSurface : Color
, inverseOnSurface : Color
, background : Color
, onBackground : Color
, error : Color
, errorContainer : Color
, onError : Color
, onErrorContainer : Color
, outline : Color
, outlineVariant : Color
, shadow : Color
, surfaceTint : Color
, scrim : Color
}

A Material 3 color scheme

type alias Theme =
{ name : String
, description : String
, keyColors : KeyColors
, schemes :
{ light : Scheme
, dark : Scheme
}
}

A Material color theme

Constructors

defaultKeyColors : KeyColors

The default Material 3 key colors

The default Material 3 light theme based on the default key colors

The default Material 3 dark theme based on the default key colors

defaultTheme : Theme

The default Material 3 theme

lightFromKeyColors : KeyColors -> Scheme

Create a light color scheme from key colors

darkFromKeyColors : KeyColors -> Scheme

Create a dark color scheme from key colors

makeTheme : String -> String -> KeyColors -> Theme

Build a theme

Getters

getColor : Color -> Scheme -> Color

Get a color of a scheme

getOnColor : Color -> Scheme -> Color

Get a "on" color of a scheme

getElementColor : Color -> Scheme -> Color

Get a color of a scheme directly as a 'Element.Color'

getOnElementColor : Color -> Scheme -> Color

Get a "on" color of a scheme directly as a 'Element.Color'

toElementColor : Color -> Color

Convert a Color to Element.Color

getContainerColor : Color -> Scheme -> Color

get a container color

getOnContainerColor : Color -> Scheme -> Color

get a "on container" color

getContainerElementColor : Color -> Scheme -> Color

get a "container" color directly as a 'Element.color'

getOnContainerElementColor : Color -> Scheme -> Color

get a "on container" color directly as a 'Element.color'

getSurfaceColor : Color -> Scheme -> Color

get the "surface" color

getOnSurfaceColor : Color -> Scheme -> Color

get the "on surface" color

getSurfaceVariantColor : Color -> Scheme -> Color

get the "surface variant" color

getOnSurfaceVariantColor : Color -> Scheme -> Color

get the "on surface variant" color

get the "surface container lowest" color

getSurfaceContainerLowColor : Color -> Scheme -> Color

get the "surface container low" color

getSurfaceContainerColor : Color -> Scheme -> Color

get the "surface container" color

getSurfaceContainerHighColor : Color -> Scheme -> Color

get the "surface container high" color

get the "surface container highest" color

The "hover" state layer opacity

The "focus" state layer opacity

The "press" state layer opacity

Helper functions

setAlpha : Float -> Color -> Color

set the opacity of a color

withShade : Color -> Float -> Color -> Color

Simulates adding a color in front (subtractive color mixing).

--Darkens the color by 50%
withShade (Color.rgb255 255 255 255) 0.5


--Makes the color 50% more red
withShade (Color.rgb255 255 0 0) 0.5
isError : Color -> Bool

returns true if the given color is a error color

tone : Int -> Color -> Color