Coelho.Icons (coelho v0.14.0)

Copy Markdown View Source

The toolbar's icons.

One line drawing per command, written for this library rather than taken from an icon set: nothing to attribute, nothing to keep up with, and no second visual identity arriving with the dependency.

Each is a 24-grid <svg> stroked in currentColor, so it takes the colour of the button it sits in — including the pressed and disabled states the stylesheet already draws. Its size is the --coelho-icon custom property, 20px by default:

.coelho { --coelho-icon: 24px; }

An application replaces one, or all of them, through the editor's :icons attribute — see Coelho.LiveView.coelho_editor/1. What it passes has to be safe markup already, since it is rendered rather than escaped: markup is what an application states, never what it happens to hold.

A command with no icon here falls back to its label as text, which is what a command an application added does until it is given one.

A heading naming its level — heading_3, beside heading — is deliberately one of those: six drawings of an H differing by a numeral are six buttons nobody can tell apart at 20px, where "Heading 3" is read at a glance. An application that wants a drawing there passes its own through :icons.

Summary

Functions

The commands this module draws.

The icon for a command, or nil where there is none.

What a command is called in English, or its own name where nothing is.

Functions

commands()

@spec commands() :: [String.t()]

The commands this module draws.

icon(command)

@spec icon(String.t()) :: {:safe, iodata()} | nil

The icon for a command, or nil where there is none.

Safe markup, so it is rendered rather than escaped. Every path in it is a literal in this module: nothing reaches it from a document, a parameter or an application.

label(command)

@spec label(String.t()) :: String.t()

What a command is called in English, or its own name where nothing is.