Expresso.ThemeVerifier (expresso v0.1.0)

Copy Markdown View Source

The Spark verifier of the contrast of the theme option

It runs one time for each deck module at compile time. A built-in theme meets each minimum of Expresso.Palette, so only a theme of 16 colors can fail. The verifier gives a warning for each role that fails, and the deck still compiles. The option itself refuses a value that is not a theme.

The warning of a role names the slot of its color, and a color for that slot that passes, from Expresso.Palette.suggestions/1. The colors of the map stay as the user gives them.

The verifier checks each variant of the option that is a map, after the adjustment of adjust: true, and the warning of a variant names it. An adjustment that changes a color by more than the limit of a built-in theme gives a warning too.

The verifier also gives a warning for each variant that does not dim at the dim_contrast option of the deck. dim_messages/2 gives the rules.

Summary

Functions

Return the warning of each variant of a theme that does not dim at a minimum contrast ratio

Return the warning of each role of a theme under its minimum of contrast

Give a warning for each role of the theme of the deck under its minimum of contrast

Functions

dim_messages(theme, ratio)

@spec dim_messages(term(), number() | nil) :: [String.t()]

Return the warning of each variant of a theme that does not dim at a minimum contrast ratio

ratio is the dim_contrast option of the deck, or nil for the default of 3:1. A variant does not dim when its dim opacity is 1.0: then no opacity under 1.0 keeps each role of text at ratio on its background. A dimmed image, SVG file, embed and video then do not dim, because the style sheet dims them with --dim-opacity. The warning also names each role of text that keeps its color in the state dim.

A variant that fails a minimum of messages/1 gets no warning here, because its warnings of contrast tell the cause.

iex> Expresso.ThemeVerifier.dim_messages(:default, nil)
[]
iex> [message] = Expresso.ThemeVerifier.dim_messages(:solarized_light, 4.5)
iex> message =~ "no role of text dims"
true

messages(theme)

@spec messages(term()) :: [String.t()]

Return the warning of each role of a theme under its minimum of contrast

theme is a value of the theme option. verify/1 and Expresso.Check call this function.

iex> Expresso.ThemeVerifier.messages(:dracula)
[]

verify(dsl_state)

@spec verify(map()) :: :ok | {:warn, [String.t()]}

Give a warning for each role of the theme of the deck under its minimum of contrast