Theme engine v2, the document side: component tokens, layout variants, decoration, icon packs
A theme may now say how each piece of a site is built, not only one radius and one density: - components (themeComponents.ts): 36 generic parts with clamped tokens (radius, border incl. 98.css-style bevels, fill by color role / glass / gradient, padding, sizes, type, shadow, shape, hover/active/focus), presets and parents; compiled over a site's part map as soft values (--wb-part-*) and rigid rules; text on a chosen fill keeps its contrast. - variants (themeVariants.ts): fixed words on six axes; the owner holds an axis or switches layout changes off; the look of a variant is the site's skin. - decoration (themeDecor.ts): dividers, chrome (title bar, masthead, prompt), a focus ring that is always visible, selection, scrollbars, links, motion under reduced-motion. - icon packs (themeIcons.ts): a standalone document of glyphs by semantic name (path data, colored layers or a small PNG, never an SVG document), with license, source and credits; a theme only names a pack; the owner's icon choice is separate; drawn as CSS masks of the current color over the site's own svg boxes, behind forced-colors and mask-support guards, per group. - a theme document gains the optional groups components, variants, decor, icons and colors.actions; a theme without them is sanitized to exactly what it was. - theme.schema.json and the new icons.schema.json are generated from the same tables (scripts/theme-schema.mjs; a test fails when they are stale).
This commit is contained in:
parent
507cd95d8e
commit
582c3d9460
12 changed files with 6689 additions and 88 deletions
646
packages/waybetter/icons.schema.json
Normal file
646
packages/waybetter/icons.schema.json
Normal file
|
|
@ -0,0 +1,646 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://unpkg.com/waybetter/icons.schema.json",
|
||||
"title": "wayBetter icon pack",
|
||||
"description": "Glyphs by semantic name, drawn over a site's own icons. Path data, colored layers of path data, or small PNGs: never an SVG document.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"license",
|
||||
"glyphs"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]{1,40}$"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 60
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 200
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"maxLength": 60
|
||||
},
|
||||
"license": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 60,
|
||||
"description": "SPDX id, \"own\" for the author's own drawings, or a plain name for artwork under other terms."
|
||||
},
|
||||
"source": {
|
||||
"type": "string",
|
||||
"maxLength": 200
|
||||
},
|
||||
"credits": {
|
||||
"type": "string",
|
||||
"maxLength": 400
|
||||
},
|
||||
"version": {
|
||||
"const": 1
|
||||
},
|
||||
"style": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"stroke": {
|
||||
"type": "number",
|
||||
"minimum": 1,
|
||||
"maximum": 2.5
|
||||
},
|
||||
"cap": {
|
||||
"enum": [
|
||||
"round",
|
||||
"square",
|
||||
"butt"
|
||||
]
|
||||
},
|
||||
"join": {
|
||||
"enum": [
|
||||
"round",
|
||||
"miter",
|
||||
"bevel"
|
||||
]
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"minimum": 0.8,
|
||||
"maximum": 1.25
|
||||
}
|
||||
}
|
||||
},
|
||||
"glyphs": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"home": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"home.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"explore": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"explore.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"notifications": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"notifications.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"messages": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"messages.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"grok": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"bookmarks": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"bookmarks.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"lists": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"communities": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"premium": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"profile": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"profile.active": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"more": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"compose": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"reply": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"repost": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"repost.on": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"like": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"like.on": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"views": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"bookmark": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"bookmark.on": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"share": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"verified": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"logo": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"caret": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"back": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"close": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"search": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"settings": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"media": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"gif": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"poll": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"emoji": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"schedule": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"pinned": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"repostContext": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
},
|
||||
"lock": {
|
||||
"$ref": "#/$defs/glyph"
|
||||
}
|
||||
},
|
||||
"maxProperties": 64,
|
||||
"minProperties": 1
|
||||
},
|
||||
"symbols": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"like": {
|
||||
"enum": [
|
||||
"heart",
|
||||
"star",
|
||||
"custom"
|
||||
]
|
||||
},
|
||||
"separator": {
|
||||
"enum": [
|
||||
"dot",
|
||||
"bullet",
|
||||
"slash",
|
||||
"dash",
|
||||
"pipe",
|
||||
"none"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"reply": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
},
|
||||
"repost": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
},
|
||||
"like": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
},
|
||||
"views": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
},
|
||||
"bookmark": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
},
|
||||
"share": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 12,
|
||||
"pattern": "^[^\\u0000-\\u001f\"\\\\<>&{};'`]+$"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"hex": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9a-fA-F]{6}$"
|
||||
},
|
||||
"role": {
|
||||
"description": "A color role of the theme. Components never carry a color literal.",
|
||||
"enum": [
|
||||
"bg",
|
||||
"surface",
|
||||
"elevated",
|
||||
"page",
|
||||
"border",
|
||||
"text",
|
||||
"muted",
|
||||
"accent",
|
||||
"onAccent",
|
||||
"inverse",
|
||||
"onInverse"
|
||||
]
|
||||
},
|
||||
"fontRoleName": {
|
||||
"enum": [
|
||||
"interface",
|
||||
"post",
|
||||
"heading",
|
||||
"numbers",
|
||||
"mono",
|
||||
"chrome",
|
||||
"dialog"
|
||||
]
|
||||
},
|
||||
"shadow": {
|
||||
"enum": [
|
||||
"none",
|
||||
"soft",
|
||||
"deep",
|
||||
"hard",
|
||||
"inset",
|
||||
"glow"
|
||||
]
|
||||
},
|
||||
"fill": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
{
|
||||
"const": "transparent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"state": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"fill": {
|
||||
"$ref": "#/$defs/fill"
|
||||
},
|
||||
"text": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"borderColor": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"shadow": {
|
||||
"$ref": "#/$defs/shadow"
|
||||
},
|
||||
"lift": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 4
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"minimum": 0.96,
|
||||
"maximum": 1.04
|
||||
},
|
||||
"underline": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fillGlass": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
{
|
||||
"const": "transparent"
|
||||
},
|
||||
{
|
||||
"const": "glass"
|
||||
}
|
||||
]
|
||||
},
|
||||
"stateGlass": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"fill": {
|
||||
"$ref": "#/$defs/fillGlass"
|
||||
},
|
||||
"text": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"borderColor": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"shadow": {
|
||||
"$ref": "#/$defs/shadow"
|
||||
},
|
||||
"lift": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 4
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"minimum": 0.96,
|
||||
"maximum": 1.04
|
||||
},
|
||||
"underline": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fillGradient": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
{
|
||||
"const": "transparent"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"from": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"to": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"angle": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 360
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"to"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"stateGradient": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"fill": {
|
||||
"$ref": "#/$defs/fillGradient"
|
||||
},
|
||||
"text": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"borderColor": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"shadow": {
|
||||
"$ref": "#/$defs/shadow"
|
||||
},
|
||||
"lift": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 4
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"minimum": 0.96,
|
||||
"maximum": 1.04
|
||||
},
|
||||
"underline": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fillGlassGradient": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
{
|
||||
"const": "transparent"
|
||||
},
|
||||
{
|
||||
"const": "glass"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"from": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"to": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"angle": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 360
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"to"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"stateGlassGradient": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"fill": {
|
||||
"$ref": "#/$defs/fillGlassGradient"
|
||||
},
|
||||
"text": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"borderColor": {
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
"shadow": {
|
||||
"$ref": "#/$defs/shadow"
|
||||
},
|
||||
"lift": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 4
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"minimum": 0.96,
|
||||
"maximum": 1.04
|
||||
},
|
||||
"underline": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pathData": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 4000,
|
||||
"pattern": "^[MmLlHhVvCcSsQqTtAaZz0-9eE\\s,.+-]+$"
|
||||
},
|
||||
"glyph": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"d": {
|
||||
"$ref": "#/$defs/pathData"
|
||||
},
|
||||
"rule": {
|
||||
"const": "evenodd"
|
||||
},
|
||||
"stroke": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"d"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"layers": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 6,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"d": {
|
||||
"$ref": "#/$defs/pathData"
|
||||
},
|
||||
"fill": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/role"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/hex"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"from": {
|
||||
"$ref": "#/$defs/hex"
|
||||
},
|
||||
"to": {
|
||||
"$ref": "#/$defs/hex"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"to"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"opacity": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"rule": {
|
||||
"const": "evenodd"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"d",
|
||||
"fill"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"layers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"png": {
|
||||
"type": "string",
|
||||
"maxLength": 6022,
|
||||
"pattern": "^data:image/png;base64,[A-Za-z0-9+/]+={0,2}$"
|
||||
},
|
||||
"pixel": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"png"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue