Expand description
The custom theme, which is custom CSS. Itโs applied after the theme tokens in src/theme.css,
so a theme changes colors and radii by setting those tokens.
The saved theme.css and exported theme files are the same plain CSS. Nothing in a theme may
load from outside this device: it can reference only embedded data URLs, so a shared theme
canโt reveal anything to a remote server. The CSS editor can name local files, which are
embedded before the theme is saved.
Constantsยง
- MAX_
CSS_ ๐BYTES - Room for images and fonts embedded as data URLs.
- MAX_
IMPORT_ ๐DEPTH - How deeply local CSS files can import each other.
Functionsยง
- check_
size ๐ - css_
is_ local - True when the CSS canโt load anything except embedded data URLs.
url(#id)refers to an element in the same document. - data_
url ๐ - Reads an image or font file as a data URL, typed by its extension. The file name is kept as a
form-encoded
nameparameter, which browsers ignore, so the CSS editor can show it. - embed ๐
- embed_
files - Embeds the local files that theme CSS names. Each
@importof a local CSS file is replaced with that fileโs contents, and eachurl()naming a local file becomes a data URL. Absolute paths andfile:URLs are local, and inside an imported file, relative paths resolve against its folder. Other URLs are left forvalidateto reject. - embed_
urls ๐ - Replaces each
url()that names a local file with the file as a data URL. - import_
target ๐ - The path an
@importnames as a string orurl(), when only;follows it, and the length of the rule after@import. - inline_
imports ๐ - Replaces each unconditional
@importof a local CSS file with the fileโs embedded contents. - local_
path ๐ - The local file a value names: an absolute path, a
file:URL, or a path relative tofolder. Network paths and other URLs arenโt local. - normalize_
css ๐ - Lowercases CSS, decodes escapes, and drops comments outside strings.
- read_
file ๐ - split_
url ๐ - Splits the text after
url(into the whitespace and opening quote, the value, and the rest, which starts at the closing quote or parenthesis. - validate
- Checks that theme CSS is within the size limit and loads nothing from outside this device.