这段内容尚未翻译,下面是英文原文。
A design style
How a style package is made: it fills the names of the token contract in a light and a dark scheme. What it gives, what it expects, what is free (palette, fonts, radii, extensions), how to make an alternative from the skeleton, and its health.
How conventions work: this page is the convention of the base package design-tokens. The packages that
follow it say follows: [design/conventions/style]: shtukbase-style, shadcn and keer-style.
1. What it covers
A style is a package that gives a project its look as values: colours, radius, fonts, shadows. It is not components and it
is not markup. Components (design-components and the libraries on it) and viewers read only the names of the token
contract, so a style can be swapped for another one and the whole project changes its look. design-tokens works out of the box
with the example tokens it lays; a style package replaces them.
2. Gives
A style package gives these, and nothing more is required:
- The names of the contract (The token contract, data in contract.json, version 1):
every required name defined in
:root, every colour also in the dark scheme. - The tokens in the DTCG format:
/design/<id>/tokens.json(the light scheme) and/design/<id>/tokens.dark.json(the dark scheme). A token path becomes a name:card-foregroundis--card-foreground,sb.hue.1is--sb-hue-1. - The built CSS
/design/<id>/tokens.css: the light scheme on:root, the dark scheme on.dark, [data-theme="dark"]. It is built, not written by hand: the actionbuildcallsbuildStyle(id)ofdesign-tokens, and runs after install and update. - A way to choose it:
style: <id>in the header of Design. A style package may set it on install when it is empty (the actionadoptofshtukbase-styledoes).
The <id> is the id of the package. Everything the package lays about its own look (/design/<id>.md, fonts, a mark, a
showcase, its norms) is free, see section 4.
3. Expects
From design-tokens and nothing else:
- the contract (
/design/contract.json) and the build librarybuildStyle(id)in.shtukbase/packages/design-tokens/actions/build.ts; - the page
/design/design.md(the choicestyle:).
Not from the components, not from any other style, not from icons. A style does not know which libraries are used with it.
4. Free to choose
Everything the contract leaves open. This is where an alternative is creative:
- the palette: any values for the colour names; how many shades and what to call them in the package itself (
--sb-graphiteisshtukbase-style's own); - the fonts (
--font-sans,--font-mono,--font-display) and how they are loaded; - the radius and the shadows (
--radius,--shadow-sm,--shadow-md,--shadow-lg); - the optional extension of the contract (
--sb-hue-1…--sb-hue-12with-soft,-tint,-ink,--sb-glow,--sb-edge,--sb-ease,--sb-dur, …): set them or leave them, the defaults apply; - names of its own, as many as it needs (they are reported as
extra, which is only information); - anything else it lays: fonts, a mark, a showcase page, norms of its own look.
5. Make an alternative
The recipe for an agent who is told "make a style like shtukbase-style, but in another taste":
- Copy the skeleton: the folder
skeleton/style/of the packagedesign-tokens(installed at.shtukbase/packages/design-tokens/skeleton/style/; in the repositoryapps/standard/packages/design-tokens/skeleton/style/). It is a complete style package with a plain neutral value for every required name in both schemes. - Make it a package: a new folder
packages/<new-id>/, renamemy-styleto<new-id>inpackage.md, in the folderpages/design/my-style/and inactions/build.ts(the constantID). Keepfollows: [design/conventions/style]. - Change the values in
tokens.jsonandtokens.dark.json. Keep every name; a colour needs both schemes. Add the optional extension if the look needs it. - Build and judge:
shtuk run <new-id> build, thenshtuk run design-tokens health --style <new-id>. Read the lines: add what ismissing, and decide for each name infallbackswhether the default is what you want. - Choose it with
style: <new-id>on/design/design.mdand look at it: open/design/<new-id>/...showcase if you wrote one, or the catalog lens ofdesign-lenses, in both schemes. - Run
shtuk check: the hard gate DTK-R03 and the report DTK-R04 must both be quiet aboutmissing.
References.
shtukbase-style: a full style package. Read it for the structure: tokens in DTCG, the built CSS,buildandadopt, the optional extension (the 12 hues), fonts, norms of its own look. Do not copy its raspberry, Outfit and Onest, the Viewfinder mark, the glow and the even edge: that is its taste, not the promise.shadcn: the origin of the names. Its theme (.shtukbase/packages/shadcn/registry/styles/theme.css) has only the shadcn names and is a valid style as it is: judge it withshtuk run design-tokens health --css <file>. Read it to see how little a style needs. Do not copy thecomponents.jsonand component placement: that isshadcn's own business, not a style's.keer-style: a style of an earlier product with its own--ds-names. It follows the convention in intent but does not fill the contract names yet; its health shows what is missing. Read it for the idea of two themes, not as a model.
6. Health
The norm DTK-R04, enforcer checks/health.ts, mode warn. It judges the chosen style
(--style <id>, --all and --css <file> judge others) and prints lines health style/<id>: <band>:
| Band | Means for a style |
|---|---|
full | every required name is set, every colour has a dark value, no optional name is left out |
missing | a required name, a dark value (--x (dark)) or a reference that leads nowhere; components that read it fall back to the browser default |
fallbacks | optional names left out; the defaults of the contract apply (each one derived from the required names), so nothing breaks |
extra | names outside the contract; may be the style's own, or a hint that the contract should grow |
It never fails. The hard version of the same judgement is the gate DTK-R03 (shtuk run design-tokens contract).
/design/conventions/style.md。源文本