200 lines
9.5 KiB
JSON
200 lines
9.5 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://unpkg.com/waybetter/theme.schema.json",
|
|
"title": "wayBetter theme",
|
|
"description": "A wayBetter theme document (data, not a stylesheet). Only `name` is required. Apps sanitize every field before use: values out of range are clamped and unknown values fall back to the default, so this schema describes what is kept unchanged.",
|
|
"type": "object",
|
|
"required": ["name"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"$schema": { "type": "string" },
|
|
"id": { "type": "string", "pattern": "^[a-z0-9-]{1,40}$", "description": "Derived from the name when missing." },
|
|
"name": { "type": "string", "minLength": 1, "maxLength": 60, "pattern": "\\S" },
|
|
"description": { "type": "string", "maxLength": 200 },
|
|
"author": { "type": "string", "maxLength": 60 },
|
|
"version": { "const": 1 },
|
|
"mode": { "enum": ["light", "dark", "auto"], "default": "auto", "description": "Which way scrollbars and form controls lean." },
|
|
"colors": {
|
|
"description": "bg, text and accent are required; every other role is derived from them when missing. null keeps the site's own colors.",
|
|
"oneOf": [
|
|
{ "type": "null" },
|
|
{
|
|
"type": "object",
|
|
"required": ["bg", "text", "accent"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"bg": { "$ref": "#/$defs/hex", "description": "Column background." },
|
|
"surface": { "$ref": "#/$defs/hex", "description": "Raised surface (cards, inputs)." },
|
|
"elevated": { "$ref": "#/$defs/hex", "description": "Hover / selected surface." },
|
|
"border": { "$ref": "#/$defs/hex" },
|
|
"text": { "$ref": "#/$defs/hex" },
|
|
"muted": { "$ref": "#/$defs/hex", "description": "Secondary text." },
|
|
"accent": { "$ref": "#/$defs/hex", "description": "Links, focus, selected tabs." },
|
|
"inverse": { "$ref": "#/$defs/hex", "description": "The filled primary button." },
|
|
"onInverse": { "$ref": "#/$defs/hex", "description": "The filled primary button's label." },
|
|
"page": { "$ref": "#/$defs/hex", "description": "The canvas behind the columns (defaults to bg)." }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"font": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"family": { "$ref": "#/$defs/fontStack", "description": "Interface font stack; empty keeps the site's font. Shorthand of roles.interface.family (kept for older apps); when roles.interface is present it wins." },
|
|
"tweet": { "$ref": "#/$defs/fontStack", "description": "Post text stack; shorthand of roles.post.family (roles.post wins)." },
|
|
"roles": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"description": "Which font goes where. A role is \"inherit\" (the interface font; an inheriting mono role keeps a monospaced face) or its own stack with optional settings.",
|
|
"properties": {
|
|
"interface": { "$ref": "#/$defs/interfaceRole", "description": "The site's whole UI; every other role inherits it." },
|
|
"post": { "$ref": "#/$defs/fontRole", "description": "Post text." },
|
|
"heading": { "$ref": "#/$defs/fontRole", "description": "Display names and headings." },
|
|
"numbers": { "$ref": "#/$defs/fontRole", "description": "Counts (likes, reposts, followers)." },
|
|
"mono": { "$ref": "#/$defs/fontRole", "description": "Code." },
|
|
"chrome": { "$ref": "#/$defs/fontRole", "description": "The app's own window: tabs, address bar, titlebar, panel." },
|
|
"dialog": { "$ref": "#/$defs/fontRole", "description": "Plugin dialogs and toasts (the UI kit)." }
|
|
}
|
|
},
|
|
"scale": { "type": "number", "minimum": 0.85, "maximum": 1.2, "default": 1 },
|
|
"weight": { "type": "integer", "minimum": 300, "maximum": 500, "default": 400 },
|
|
"bold": { "type": "integer", "minimum": 500, "maximum": 800, "default": 700 },
|
|
"tracking": { "type": "number", "minimum": -0.03, "maximum": 0.06, "default": 0, "description": "Letter spacing in em." },
|
|
"leading": {
|
|
"description": "Post line height; 0 keeps the site's.",
|
|
"anyOf": [{ "const": 0 }, { "type": "number", "minimum": 1.2, "maximum": 1.8 }],
|
|
"default": 0
|
|
}
|
|
}
|
|
},
|
|
"shape": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"radius": { "type": "integer", "minimum": 0, "maximum": 28, "default": 16, "description": "Card radius in px." },
|
|
"button": { "type": "integer", "minimum": 0, "maximum": 9999, "default": 9999, "description": "Button radius in px (9999 = pill)." },
|
|
"avatar": { "enum": ["circle", "rounded", "square"], "default": "circle" }
|
|
}
|
|
},
|
|
"layout": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"column": { "type": "integer", "minimum": 520, "maximum": 820, "default": 600 },
|
|
"sidebar": { "type": "integer", "minimum": 290, "maximum": 400, "default": 350 },
|
|
"density": { "enum": ["compact", "default", "comfortable"], "default": "default" },
|
|
"cards": { "type": "boolean", "default": false },
|
|
"frame": { "type": "boolean", "default": false }
|
|
}
|
|
},
|
|
"background": {
|
|
"oneOf": [
|
|
{
|
|
"type": "object",
|
|
"required": ["kind"],
|
|
"additionalProperties": false,
|
|
"properties": { "kind": { "const": "none" } }
|
|
},
|
|
{
|
|
"type": "object",
|
|
"required": ["kind", "from", "to"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"kind": { "const": "gradient" },
|
|
"from": { "$ref": "#/$defs/hex" },
|
|
"to": { "$ref": "#/$defs/hex" },
|
|
"angle": { "type": "integer", "minimum": 0, "maximum": 360, "default": 180 },
|
|
"glow": { "$ref": "#/$defs/hex" }
|
|
}
|
|
},
|
|
{
|
|
"type": "object",
|
|
"required": ["kind", "ink"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"kind": { "const": "pattern" },
|
|
"pattern": { "enum": ["dots", "grid", "diagonal", "scanlines", "paper", "clouds"], "default": "dots" },
|
|
"ink": { "$ref": "#/$defs/hex" },
|
|
"opacity": { "type": "number", "minimum": 0, "maximum": 0.6, "default": 0.1 },
|
|
"size": { "type": "integer", "minimum": 2, "maximum": 400, "default": 24 }
|
|
}
|
|
},
|
|
{
|
|
"type": "object",
|
|
"required": ["kind", "url"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"kind": { "const": "image" },
|
|
"url": {
|
|
"type": "string",
|
|
"maxLength": 1100000,
|
|
"pattern": "^data:image/(png|jpeg|webp|gif|avif);base64,[A-Za-z0-9+/]+={0,2}$",
|
|
"description": "An embedded image (about 800 KB at most). Remote URLs are never loaded."
|
|
},
|
|
"fit": { "enum": ["cover", "tile"], "default": "cover" },
|
|
"dim": { "type": "number", "minimum": 0.35, "maximum": 0.95, "default": 0.6 }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"effects": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"motion": { "type": "integer", "minimum": 0, "maximum": 400, "default": 0, "description": "Transition length in ms." },
|
|
"hover": { "enum": ["none", "tint", "lift", "glow"], "default": "none" },
|
|
"shadow": { "enum": ["none", "soft", "deep"], "default": "none" },
|
|
"crt": { "type": "boolean", "default": false }
|
|
}
|
|
},
|
|
"css": {
|
|
"type": "string",
|
|
"maxLength": 60000,
|
|
"description": "Free-form CSS appended last. Same trust level as the owner's own Custom CSS; import dialogs say so."
|
|
}
|
|
},
|
|
"$defs": {
|
|
"hex": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
|
|
"source": { "const": "google", "description": "The first family is a Google Fonts family: apps download it (asking first for an imported theme) and load it from bytes." },
|
|
"interfaceRole": {
|
|
"oneOf": [
|
|
{ "const": "inherit" },
|
|
{
|
|
"type": "object",
|
|
"required": ["family"],
|
|
"additionalProperties": false,
|
|
"properties": { "family": { "$ref": "#/$defs/fontStack" }, "source": { "$ref": "#/$defs/source" } }
|
|
}
|
|
]
|
|
},
|
|
"fontRole": {
|
|
"oneOf": [
|
|
{ "const": "inherit" },
|
|
{
|
|
"type": "object",
|
|
"required": ["family"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"family": { "$ref": "#/$defs/fontStack", "description": "Empty keeps the inherited family and changes only the settings below." },
|
|
"source": { "$ref": "#/$defs/source" },
|
|
"weight": { "type": "integer", "minimum": 100, "maximum": 900 },
|
|
"size": { "type": "number", "minimum": 0.75, "maximum": 1.5, "description": "Relative to the site's size." },
|
|
"tracking": { "type": "number", "minimum": -0.05, "maximum": 0.1, "description": "Letter spacing in em." },
|
|
"tabular": { "type": "boolean", "description": "Tabular (fixed-width) figures." }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"fontStack": {
|
|
"type": "array",
|
|
"maxItems": 8,
|
|
"items": {
|
|
"anyOf": [
|
|
{ "enum": ["system-ui", "sans-serif", "serif", "monospace", "cursive", "ui-sans-serif", "ui-serif", "ui-monospace", "ui-rounded", "-apple-system", "BlinkMacSystemFont"] },
|
|
{ "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9 .\\-]{0,47}$" }
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|