ShtukbaseStandard
página del paquete→ /design/conventions/style.md

pages/design/conventions/style.md

99 líneas, 6.6 KB. Como página.

Este texto aún no está traducido. Debajo está el original en inglés.

  1. ---
  2. type: Convention
  3. title: "A design style"
  4. description: "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."
  5. icon: "🎨"
  6. ---
  7. # A design style
  8. How [conventions](/base/conventions.md) work: this page is the convention of the base package `design-tokens`. The packages that
  9. follow it say `follows: [design/conventions/style]`: `shtukbase-style`, `shadcn` and `keer-style`.
  10. ## 1. What it covers
  11. A **style** is a package that gives a project its look as values: colours, radius, fonts, shadows. It is not components and it
  12. is not markup. Components (`design-components` and the libraries on it) and viewers read only the names of the token
  13. contract, so a style can be swapped for another one and the whole project changes its look. `design-tokens` works out of the box
  14. with the example tokens it lays; a style package replaces them.
  15. ## 2. Gives
  16. A style package gives these, and nothing more is required:
  17. - **The names of the contract** ([The token contract](/design/contract.md), data in [contract.json](/design/contract.json), version 1):
  18. every required name defined in `:root`, every colour also in the dark scheme.
  19. - **The tokens** in the DTCG format: `/design/<id>/tokens.json` (the light scheme) and `/design/<id>/tokens.dark.json` (the dark
  20. scheme). A token path becomes a name: `card-foreground` is `--card-foreground`, `sb.hue.1` is `--sb-hue-1`.
  21. - **The built CSS** `/design/<id>/tokens.css`: the light scheme on `:root`, the dark scheme on `.dark, [data-theme="dark"]`. It is
  22. built, not written by hand: the action `build` calls `buildStyle(id)` of `design-tokens`, and runs after install and update.
  23. - **A way to choose it:** `style: <id>` in the header of [Design](/design/design.md). A style package may set it on install when it
  24. is empty (the action `adopt` of `shtukbase-style` does).
  25. The `<id>` is the id of the package. Everything the package lays about its own look (`/design/<id>.md`, fonts, a mark, a
  26. showcase, its norms) is free, see section 4.
  27. ## 3. Expects
  28. From `design-tokens` and nothing else:
  29. - the contract (`/design/contract.json`) and the build library `buildStyle(id)` in `.shtukbase/packages/design-tokens/actions/build.ts`;
  30. - the page `/design/design.md` (the choice `style:`).
  31. Not from the components, not from any other style, not from `icons`. A style does not know which libraries are used with it.
  32. ## 4. Free to choose
  33. Everything the contract leaves open. This is where an alternative is creative:
  34. - the **palette**: any values for the colour names; how many shades and what to call them in the package itself (`--sb-graphite` is
  35. `shtukbase-style`'s own);
  36. - the **fonts** (`--font-sans`, `--font-mono`, `--font-display`) and how they are loaded;
  37. - the **radius** and the **shadows** (`--radius`, `--shadow-sm`, `--shadow-md`, `--shadow-lg`);
  38. - the **optional extension** of the contract (`--sb-hue-1` … `--sb-hue-12` with `-soft`, `-tint`, `-ink`, `--sb-glow`, `--sb-edge`,
  39. `--sb-ease`, `--sb-dur`, …): set them or leave them, the defaults apply;
  40. - names of its own, as many as it needs (they are reported as `extra`, which is only information);
  41. - anything else it lays: fonts, a mark, a showcase page, norms of its own look.
  42. ## 5. Make an alternative
  43. The recipe for an agent who is told "make a style like `shtukbase-style`, but in another taste":
  44. 1. Copy the **skeleton**: the folder `skeleton/style/` of the package `design-tokens` (installed at
  45. `.shtukbase/packages/design-tokens/skeleton/style/`; in the repository `apps/standard/packages/design-tokens/skeleton/style/`).
  46. It is a complete style package with a plain neutral value for every required name in both schemes.
  47. 2. Make it a package: a new folder `packages/<new-id>/`, rename `my-style` to `<new-id>` in `package.md`, in the folder
  48. `pages/design/my-style/` and in `actions/build.ts` (the constant `ID`). Keep `follows: [design/conventions/style]`.
  49. 3. Change the values in `tokens.json` and `tokens.dark.json`. Keep every name; a colour needs both schemes. Add the optional
  50. extension if the look needs it.
  51. 4. Build and judge: `shtuk run <new-id> build`, then `shtuk run design-tokens health --style <new-id>`. Read the lines: add what is
  52. `missing`, and decide for each name in `fallbacks` whether the default is what you want.
  53. 5. Choose it with `style: <new-id>` on `/design/design.md` and look at it: open `/design/<new-id>/...` showcase if you wrote one,
  54. or the catalog lens of `design-lenses`, in both schemes.
  55. 6. Run `shtuk check`: the hard gate [DTK-R03](/norms/rules/design-tokens/DTK-R03.md) and the report DTK-R04 must both be quiet about
  56. `missing`.
  57. **References.**
  58. - `shtukbase-style`: a full style package. Read it for the structure: tokens in DTCG, the built CSS, `build` and `adopt`, the optional
  59. extension (the 12 hues), fonts, norms of its own look. **Do not copy** its raspberry, Outfit and Onest, the Viewfinder mark, the glow
  60. and the even edge: that is its taste, not the promise.
  61. - `shadcn`: the origin of the names. Its theme (`.shtukbase/packages/shadcn/registry/styles/theme.css`) has only the shadcn names and
  62. is a valid style as it is: judge it with `shtuk run design-tokens health --css <file>`. Read it to see how little a style needs.
  63. **Do not copy** the `components.json` and component placement: that is `shadcn`'s own business, not a style's.
  64. - `keer-style`: a style of an earlier product with its own `--ds-` names. It follows the convention in intent but does not fill the
  65. contract names yet; its health shows what is missing. Read it for the idea of two themes, not as a model.
  66. ## 6. Health
  67. The norm [DTK-R04](/norms/rules/design-tokens/DTK-R04.md), enforcer `checks/health.ts`, mode `warn`. It judges the chosen style
  68. (`--style <id>`, `--all` and `--css <file>` judge others) and prints lines `health style/<id>: <band>`:
  69. | Band | Means for a style |
  70. |---|---|
  71. | `full` | every required name is set, every colour has a dark value, no optional name is left out |
  72. | `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 |
  73. | `fallbacks` | optional names left out; the defaults of the contract apply (each one derived from the required names), so nothing breaks |
  74. | `extra` | names outside the contract; may be the style's own, or a hint that the contract should grow |
  75. It never fails. The hard version of the same judgement is the gate [DTK-R03](/norms/rules/design-tokens/DTK-R03.md) (`shtuk run design-tokens contract`).