Slackblocks.Color (slackblocks v2.8.0)
View SourceAttachment color conveniences. Returned binaries can be passed to Slackblocks.Attachment.
iex> Slackblocks.Color.hex!("A0B1c2")
"#A0B1c2"
iex> Slackblocks.Color.rgb!(0, 128, 255)
"#0080ff"
Summary
Functions
Validates six hex digits, with an optional # prefix; preserves letter case.
Like hex/1, raising on invalid input.
Resolves a semantic or named color atom: good, warning, danger, red, blue, yellow, green, orange, purple or black.
Like named/1, raising on invalid input.
Converts three integer channels in 0..255 to a lowercase hexadecimal color.
Like rgb/3, raising on invalid input.
Functions
@spec hex(binary()) :: {:ok, binary()} | {:error, Slackblocks.ValidationError.t()}
Validates six hex digits, with an optional # prefix; preserves letter case.
Like hex/1, raising on invalid input.
@spec named(atom()) :: {:ok, binary()} | {:error, Slackblocks.ValidationError.t()}
Resolves a semantic or named color atom: good, warning, danger, red, blue, yellow, green, orange, purple or black.
Like named/1, raising on invalid input.
@spec rgb(integer(), integer(), integer()) :: {:ok, binary()} | {:error, Slackblocks.ValidationError.t()}
Converts three integer channels in 0..255 to a lowercase hexadecimal color.
Like rgb/3, raising on invalid input.