@whatsaaaa/design-system 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +150 -2
  3. package/assets/building-blocks/apple-touch-icon.png +0 -0
  4. package/assets/building-blocks/favicon-16.png +0 -0
  5. package/assets/building-blocks/favicon-32.png +0 -0
  6. package/assets/building-blocks/favicon.ico +0 -0
  7. package/assets/building-blocks/favicon.svg +1 -0
  8. package/assets/building-blocks/icon-192.png +0 -0
  9. package/assets/building-blocks/icon-512.png +0 -0
  10. package/assets/building-blocks/lockup-dark.svg +1 -0
  11. package/assets/building-blocks/lockup-light.svg +1 -0
  12. package/assets/building-blocks/mark-mono.svg +1 -0
  13. package/assets/building-blocks/mark-on-dark.svg +1 -0
  14. package/assets/building-blocks/mark-on-light.svg +1 -0
  15. package/assets/building-blocks/mark.svg +1 -0
  16. package/assets/building-blocks/readme-header.png +0 -0
  17. package/assets/building-blocks/readme-header.svg +1 -0
  18. package/assets/building-blocks/social-card.png +0 -0
  19. package/assets/building-blocks/social-card.svg +1 -0
  20. package/assets/building-blocks/wordmark-dark.svg +1 -0
  21. package/assets/building-blocks/wordmark-light.svg +1 -0
  22. package/assets/dotfiles/apple-touch-icon.png +0 -0
  23. package/assets/dotfiles/favicon-16.png +0 -0
  24. package/assets/dotfiles/favicon-32.png +0 -0
  25. package/assets/dotfiles/favicon.ico +0 -0
  26. package/assets/dotfiles/favicon.svg +1 -0
  27. package/assets/dotfiles/icon-192.png +0 -0
  28. package/assets/dotfiles/icon-512.png +0 -0
  29. package/assets/dotfiles/lockup-dark.svg +1 -0
  30. package/assets/dotfiles/lockup-light.svg +1 -0
  31. package/assets/dotfiles/mark-mono.svg +1 -0
  32. package/assets/dotfiles/mark-on-dark.svg +1 -0
  33. package/assets/dotfiles/mark-on-light.svg +1 -0
  34. package/assets/dotfiles/mark.svg +1 -0
  35. package/assets/dotfiles/readme-header.png +0 -0
  36. package/assets/dotfiles/readme-header.svg +1 -0
  37. package/assets/dotfiles/social-card.png +0 -0
  38. package/assets/dotfiles/social-card.svg +1 -0
  39. package/assets/dotfiles/wordmark-dark.svg +1 -0
  40. package/assets/dotfiles/wordmark-light.svg +1 -0
  41. package/assets/form-builder/apple-touch-icon.png +0 -0
  42. package/assets/form-builder/favicon-16.png +0 -0
  43. package/assets/form-builder/favicon-32.png +0 -0
  44. package/assets/form-builder/favicon.ico +0 -0
  45. package/assets/form-builder/favicon.svg +1 -0
  46. package/assets/form-builder/icon-192.png +0 -0
  47. package/assets/form-builder/icon-512.png +0 -0
  48. package/assets/form-builder/lockup-dark.svg +1 -0
  49. package/assets/form-builder/lockup-light.svg +1 -0
  50. package/assets/form-builder/mark-mono.svg +1 -0
  51. package/assets/form-builder/mark-on-dark.svg +1 -0
  52. package/assets/form-builder/mark-on-light.svg +1 -0
  53. package/assets/form-builder/mark.svg +1 -0
  54. package/assets/form-builder/readme-header.png +0 -0
  55. package/assets/form-builder/readme-header.svg +1 -0
  56. package/assets/form-builder/social-card.png +0 -0
  57. package/assets/form-builder/social-card.svg +1 -0
  58. package/assets/form-builder/wordmark-dark.svg +1 -0
  59. package/assets/form-builder/wordmark-light.svg +1 -0
  60. package/assets/manifest.json +541 -0
  61. package/assets/whatsaaaa/apple-touch-icon.png +0 -0
  62. package/assets/whatsaaaa/favicon-16.png +0 -0
  63. package/assets/whatsaaaa/favicon-32.png +0 -0
  64. package/assets/whatsaaaa/favicon.ico +0 -0
  65. package/assets/whatsaaaa/favicon.svg +1 -0
  66. package/assets/whatsaaaa/icon-192.png +0 -0
  67. package/assets/whatsaaaa/icon-512.png +0 -0
  68. package/assets/whatsaaaa/lockup-dark.svg +1 -0
  69. package/assets/whatsaaaa/lockup-light.svg +1 -0
  70. package/assets/whatsaaaa/mark-mono.svg +1 -0
  71. package/assets/whatsaaaa/mark-on-dark.svg +1 -0
  72. package/assets/whatsaaaa/mark-on-light.svg +1 -0
  73. package/assets/whatsaaaa/mark.svg +1 -0
  74. package/assets/whatsaaaa/pose-blink-dark.svg +1 -0
  75. package/assets/whatsaaaa/pose-blink-light.svg +1 -0
  76. package/assets/whatsaaaa/pose-idle-dark.svg +1 -0
  77. package/assets/whatsaaaa/pose-idle-light.svg +1 -0
  78. package/assets/whatsaaaa/pose-lost-dark.svg +1 -0
  79. package/assets/whatsaaaa/pose-lost-light.svg +1 -0
  80. package/assets/whatsaaaa/pose-shout-dark.svg +1 -0
  81. package/assets/whatsaaaa/pose-shout-light.svg +1 -0
  82. package/assets/whatsaaaa/pose-wag-left-dark.svg +1 -0
  83. package/assets/whatsaaaa/pose-wag-left-light.svg +1 -0
  84. package/assets/whatsaaaa/pose-wag-right-dark.svg +1 -0
  85. package/assets/whatsaaaa/pose-wag-right-light.svg +1 -0
  86. package/assets/whatsaaaa/readme-header.png +0 -0
  87. package/assets/whatsaaaa/readme-header.svg +1 -0
  88. package/assets/whatsaaaa/social-card.png +0 -0
  89. package/assets/whatsaaaa/social-card.svg +1 -0
  90. package/assets/whatsaaaa/wordmark-dark.svg +1 -0
  91. package/assets/whatsaaaa/wordmark-light.svg +1 -0
  92. package/dist/color.d.ts +5 -0
  93. package/dist/color.js +7 -0
  94. package/dist/css/base.css +50 -0
  95. package/dist/css/callout.css +64 -0
  96. package/dist/css/code.css +50 -0
  97. package/dist/css/ghost.css +93 -0
  98. package/dist/css/icons.css +8 -0
  99. package/dist/css/prose.css +320 -0
  100. package/dist/css/terminal.css +424 -0
  101. package/dist/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
  102. package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  103. package/dist/fonts/inter-latin-wght-italic.woff2 +0 -0
  104. package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
  105. package/dist/fonts/inter.OFL.txt +93 -0
  106. package/dist/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
  107. package/dist/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
  108. package/dist/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
  109. package/dist/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
  110. package/dist/fonts/jetbrains-mono.OFL.txt +93 -0
  111. package/dist/fonts.css +85 -0
  112. package/dist/ghost/bubble.d.ts +16 -0
  113. package/dist/ghost/bubble.js +50 -0
  114. package/dist/ghost/glyphs.d.ts +12 -0
  115. package/dist/ghost/glyphs.js +19 -0
  116. package/dist/ghost/index.d.ts +57 -0
  117. package/dist/ghost/index.js +227 -0
  118. package/dist/identity/ghost.d.ts +28 -0
  119. package/dist/identity/ghost.js +129 -0
  120. package/dist/identity/marks.d.ts +48 -0
  121. package/dist/identity/marks.js +52 -0
  122. package/dist/identity/sprite.d.ts +43 -0
  123. package/dist/identity/sprite.js +100 -0
  124. package/dist/index.css +1404 -0
  125. package/dist/shiki/index.d.ts +20 -0
  126. package/dist/shiki/index.js +64 -0
  127. package/dist/shortcuts/index.d.ts +62 -0
  128. package/dist/shortcuts/index.js +169 -0
  129. package/dist/shortcuts/init.js +2 -0
  130. package/dist/theme/index.d.ts +24 -0
  131. package/dist/theme/index.js +60 -0
  132. package/dist/theme/init.js +2 -0
  133. package/dist/tokens.css +537 -0
  134. package/dist/tokens.d.ts +194 -0
  135. package/dist/tokens.js +336 -0
  136. package/dist/vitepress-config/index.d.ts +16 -0
  137. package/dist/vitepress-config/index.js +36 -0
  138. package/dist/vitepress-config/markdown.d.ts +6 -0
  139. package/dist/vitepress-config/markdown.js +50 -0
  140. package/dist/vitepress-config/types.d.ts +16 -0
  141. package/dist/vitepress-config/types.js +1 -0
  142. package/docs/usage.md +226 -0
  143. package/licenses/README.md +10 -0
  144. package/licenses/departure-mono.OFL.txt +93 -0
  145. package/licenses/rose-pine-palette.LICENSE +21 -0
  146. package/package.json +162 -3
  147. package/src/vitepress/Layout.vue +77 -0
  148. package/src/vitepress/components/Crumb.vue +32 -0
  149. package/src/vitepress/components/NavGhost.vue +23 -0
  150. package/src/vitepress/components/NotFound.vue +22 -0
  151. package/src/vitepress/components/StatusLine.vue +128 -0
  152. package/src/vitepress/env.d.ts +2 -0
  153. package/src/vitepress/index.ts +34 -0
  154. package/src/vitepress/path.ts +19 -0
  155. package/src/vitepress/styles/doc.css +385 -0
  156. package/src/vitepress/styles/home.css +47 -0
  157. package/src/vitepress/styles/layout.css +97 -0
  158. package/src/vitepress/styles/nav.css +441 -0
  159. package/src/vitepress/styles/search.css +55 -0
  160. package/src/vitepress/styles/sidebar.css +173 -0
  161. package/src/vitepress/styles/vars.css +204 -0
  162. package/src/vitepress/support.ts +15 -0
  163. package/src/vitepress/theme.d.ts +8 -0
  164. package/tokens/contrast.json +271 -0
  165. package/tokens/core.tokens.json +743 -0
  166. package/tokens/palette.tokens.json +222 -0
  167. package/tokens/theme-dark.tokens.json +146 -0
  168. package/tokens/theme-light.tokens.json +146 -0
  169. package/tokens/whatsaaaa.resolver.json +43 -0
package/docs/usage.md ADDED
@@ -0,0 +1,226 @@
1
+ # Usage for coding agents
2
+
3
+ How to use the Whatsaaaa design system in another project. Written for a coding agent: short, in the order you need it, with the rules that are easy to get wrong.
4
+
5
+ The package is `@whatsaaaa/design-system`, on npm:
6
+
7
+ ```sh
8
+ pnpm add @whatsaaaa/design-system
9
+ ```
10
+
11
+ ## 1. Load the styles
12
+
13
+ One import has everything: fonts, tokens, page defaults and every class.
14
+
15
+ ```css
16
+ @import '@whatsaaaa/design-system/index.css';
17
+ ```
18
+
19
+ Or take pieces. `tokens.css` and `fonts.css` first, then what you use:
20
+
21
+ | Import | What it has |
22
+ | ------------------------------------------- | ------------------------------------------------------------------------------------- |
23
+ | `@whatsaaaa/design-system/tokens.css` | Every token as a CSS variable, for both themes |
24
+ | `@whatsaaaa/design-system/fonts.css` | JetBrains Mono and Inter, self-hosted, with Serbian Latin |
25
+ | `@whatsaaaa/design-system/css/base.css` | Page defaults. It resets margins and list markers |
26
+ | `@whatsaaaa/design-system/css/prose.css` | Long-form text, in a `.ws-prose` container |
27
+ | `@whatsaaaa/design-system/css/code.css` | `.ws-code`, a code block with a caption |
28
+ | `@whatsaaaa/design-system/css/callout.css` | `.ws-callout` |
29
+ | `@whatsaaaa/design-system/css/terminal.css` | Tab bar, prompts, status line, key caps, tags |
30
+ | `@whatsaaaa/design-system/css/ghost.css` | Styles of `<ws-ghost>` |
31
+ | `@whatsaaaa/design-system/css/icons.css` | The icons the callouts and prompts draw. Needed with `callout.css` and `terminal.css` |
32
+
33
+ Everything is prefixed: classes with `ws-`, variables with `--ws-`.
34
+
35
+ ## 2. Colors
36
+
37
+ Use the role tokens. Never write a hex value, and never use a `--ws-palette-*` color for interface: a role changes with the theme and carries the contrast rules, the palette does not.
38
+
39
+ | For | Token |
40
+ | --------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
41
+ | Page background | `--ws-color-bg` |
42
+ | Panels and cards | `--ws-color-surface` |
43
+ | Inline code, hover, current item | `--ws-color-raised` |
44
+ | Dividers | `--ws-color-border` |
45
+ | Outlines of inputs and buttons | `--ws-color-field-border` |
46
+ | Text | `--ws-color-text` |
47
+ | Secondary text | `--ws-color-text-secondary` |
48
+ | Disabled text, idle marks | `--ws-color-text-faint` |
49
+ | Brand accent | `--ws-color-brand` |
50
+ | Links, focus ring, primary button | `--ws-color-interactive`, with `--ws-color-on-interactive` for text on it |
51
+ | Tags | `--ws-color-tag-text` on `--ws-color-tag-bg` |
52
+ | Status | `--ws-color-tip`, `-note`, `-warning`, `-danger`: each with `-text` for its label and `-tint` for its background |
53
+
54
+ Rules:
55
+
56
+ - **Brand is not for controls.** `--ws-color-brand` is the accent and the color of an error. Buttons, links, focus and checked controls use `--ws-color-interactive`.
57
+ - **Brand is for graphics and large type.** For small text on the brand color use `--ws-color-on-brand` on `--ws-color-brand-fill`.
58
+ - **Faint is never body text.** `--ws-color-text-faint` is 3:1.
59
+ - **Status text uses the `-text` token**, not the status color. On the light theme the two differ.
60
+ - **A status is never color alone.** Give it a label, an icon or a word.
61
+ - **Code blocks are dark in both themes.** Use `--ws-code-*` and `--ws-syntax-*` for them, not the roles.
62
+ - **No placeholders in fields.** Put the hint under the field.
63
+
64
+ The pairs that are checked for contrast are in `tokens/contrast.json`. If you need a new pair, add it there.
65
+
66
+ ## 3. Theme
67
+
68
+ Dark is the default. Light applies when the system asks for it. `data-theme="dark"` or `data-theme="light"` on `<html>` overrides the system. Do not write your own `prefers-color-scheme` rules: the tokens already switch.
69
+
70
+ ```ts
71
+ import { getTheme, setTheme, toggleTheme, themeInitScript } from '@whatsaaaa/design-system/theme'
72
+
73
+ toggleTheme() // switches and remembers the choice
74
+ setTheme('system') // follows the system again
75
+ ```
76
+
77
+ Run the head script before the stylesheet, so a remembered choice applies before the first paint. Inline `themeInitScript` in a `<script>`, or load it as a file: `<script src=".../theme/init.js"></script>`. It is a plain script, not a module.
78
+
79
+ To name the theme in a status line, put both names in the page: an item with `ws-status-line__item--dark` shows on the dark theme only, one with `ws-status-line__item--light` on the light theme only. Do not set the name from a script.
80
+
81
+ `data-theme` also works on any element, to keep a part of a page in one theme.
82
+
83
+ ## 4. Type
84
+
85
+ Two families: `--ws-font-family-mono` (JetBrains Mono) for headings, labels, navigation and code, `--ws-font-family-sans` (Inter) for long-form text and field values.
86
+
87
+ Use a text style, not a size. A style is two lines:
88
+
89
+ ```css
90
+ .title {
91
+ font: var(--ws-text-h1);
92
+ letter-spacing: var(--ws-text-h1-letter-spacing);
93
+ }
94
+ ```
95
+
96
+ Styles: `display`, `h1`, `h2`, `h3`, `h4`, `lead`, `body`, `body-sm`, `label`, `label-sm`, `caption`, `overline` (set it in uppercase) and `code`. Below 64rem use `display-compact`, `h1-compact` and `h2-compact`.
97
+
98
+ Do not load other fonts, and do not load these from a CDN. Set `font-variant-ligatures: none` on anything that shows code.
99
+
100
+ ## 5. Space, radius, motion
101
+
102
+ - Space: `--ws-space-2` to `--ws-space-64`, named by px, set in rem. Use them for padding, margin and gap.
103
+ - Radius: `--ws-radius-xs` (key caps), `-sm` (inline code, tags), `-md` (inputs, buttons), `-lg` (blocks, cards), `-xl` (the window), `-full` (dots).
104
+ - Borders, not shadows: `--ws-border-width-thin`, `-medium`, `-thick`.
105
+ - Motion: `--ws-motion-duration-fast`, `-base`, `-slow` with `--ws-motion-easing-standard`. Wrap movement in `@media (prefers-reduced-motion: no-preference)`.
106
+ - One breakpoint: `@media (width < 64rem)`.
107
+
108
+ ## 6. Classes
109
+
110
+ - Long-form text: put rendered Markdown in `<article class="ws-prose">`. Wrap a table in `<div class="ws-table">` so it scrolls inside itself, and give a cell of running text `class="ws-table__text"` so a narrow frame scrolls instead of squeezing it. A first cell stays on one line unless it has that class. The docs theme does both.
111
+ - Code block with a caption: `<figure class="ws-code"><figcaption><span>file.ts</span><span>ts</span></figcaption><pre><code>...</code></pre></figure>`. For highlighting, use Shiki with `codeTheme` from `@whatsaaaa/design-system/shiki`.
112
+ - Callout: `<aside class="ws-callout ws-callout--warning"><p class="ws-callout__title">Warning</p><p>...</p></aside>`. Modifiers: `--tip`, `--warning`, `--danger`. None is a note.
113
+ - Terminal frame: `ws-term` (the window), `ws-tab-bar` with `ws-tab-bar__brand`, `ws-tabs` and `ws-tab-bar__end`, `ws-prompt` for headings, `ws-output`, `ws-status-line`. Mark the current tab with `aria-current="page"`.
114
+ - Small pieces: `ws-kbd`, `ws-tag`, `ws-tag--outline`, `ws-state` with `--active` or `--experimental`, `ws-arrow`, `ws-cursor`.
115
+
116
+ The markup of each piece is in the comment at the top of its stylesheet, and in the style guide.
117
+
118
+ ## 7. Keys
119
+
120
+ A key hint in a status line has to work. Put `data-ws-key` on the control the key presses, give the status line the keys switch, and turn the shortcuts on:
121
+
122
+ ```html
123
+ <span class="ws-status-line__keys">
124
+ <button type="button" data-ws-key="t"><kbd class="ws-kbd">t</kbd>theme</button>
125
+ </span>
126
+ <button
127
+ type="button"
128
+ class="ws-status-line__switch"
129
+ role="switch"
130
+ aria-label="Shortcut keys"
131
+ data-ws-keys-switch
132
+ >
133
+ keys
134
+ <span class="ws-status-line__on" aria-hidden="true">on</span>
135
+ <span class="ws-status-line__off" aria-hidden="true">off</span>
136
+ </button>
137
+ ```
138
+
139
+ ```ts
140
+ import { enableShortcuts } from '@whatsaaaa/design-system/shortcuts'
141
+
142
+ enableShortcuts()
143
+ ```
144
+
145
+ Hints are hidden until `enableShortcuts()` runs, and below 64rem. A key works only while its hint shows. Do not show a hint any other way. Number keys go to the tabs of a `ws-tabs` bar. A held key acts once: the repeats a keyboard sends while the key is down do nothing.
146
+
147
+ The switch is not optional. The keys are single characters that act on the whole page, so a visitor has to be able to turn them off (WCAG 2.1.4): it matters most with speech input, where a dictated word presses them.
148
+
149
+ - It reads "keys on" or "keys off". Pressing it turns every key off or on again, and the browser remembers the choice.
150
+ - Put it in the status line, outside `ws-status-line__keys`: it shows at every width, the hints do not.
151
+ - Do not write `aria-checked` on the switch or `aria-keyshortcuts` on a control. The module sets both while they are true, and the switch stays hidden until it has its state.
152
+ - With the keys off the controls stay and work by hand. What names a key goes: the key caps and the numbers of the tabs. Hide a control that is nothing but a key cap with `[data-ws-keys='off']`.
153
+ - A key acts only on a page that has the switch. A page without the switch has no shortcuts.
154
+ - Load `shortcuts/init.js` in the head, next to `theme/init.js`, or inline `keysInitScript`. It marks the page before the first paint when the keys are remembered as off, so the tab numbers are not drawn first and then taken away.
155
+
156
+ ## 8. The ghost
157
+
158
+ ```ts
159
+ import { defineGhost, ghostMarkup, ghostSvg } from '@whatsaaaa/design-system/ghost'
160
+
161
+ defineGhost() // registers <ws-ghost>, in the browser
162
+ ```
163
+
164
+ - `<ws-ghost px="6"></ws-ghost>` is the ghost with the easter egg. Render `ghostMarkup({ px: 6 })` inside it on the server.
165
+ - `ghostSvg({ px: 2 })` is the ghost as a picture, for a link or a decoration.
166
+ - `px` is the size of one sprite pixel. Use whole numbers.
167
+
168
+ Do not recolor the ghost, do not draw on it, do not rotate or stretch it, and do not redraw it. Its tongue is always the brand color. On a project's site the ghost links to the handle's site, and the project's own sprite is the logo.
169
+
170
+ ## 9. Assets
171
+
172
+ Generated files are in `assets/<name>/`, for `whatsaaaa` and for each project. `assets/manifest.json` lists every file with its size and use.
173
+
174
+ | Need | File |
175
+ | ---------------------- | ------------------------------------------------------------------------------------------------------ |
176
+ | Favicon | `favicon.ico`, `favicon.svg`, `apple-touch-icon.png`. `icon-192.png` and `icon-512.png` for a manifest |
177
+ | Logo on any background | `mark.svg` |
178
+ | Logo in a header | `mark-on-dark.svg`, `mark-on-light.svg`, or `mark-mono.svg` to take the text color |
179
+ | Name | `wordmark-dark.svg`, `wordmark-light.svg` |
180
+ | Logo with name | `lockup-dark.svg`, `lockup-light.svg` |
181
+ | Top of a README | `readme-header.svg` |
182
+ | Link preview | `social-card.png` |
183
+
184
+ Copy the files you need into the project. Show a mark at 16, 32, 48 or 64 px, where its pixels are sharp.
185
+
186
+ Never edit a file in `assets/`. To change artwork, change its source and run `pnpm assets` in this repository. For a project that has no kit yet, add a file like `identity/projects/form-builder.json` first.
187
+
188
+ ## 10. Docs sites
189
+
190
+ A VitePress site uses the theme and its base config together:
191
+
192
+ ```ts
193
+ // .vitepress/theme/index.ts
194
+ export { default } from '@whatsaaaa/design-system/vitepress'
195
+
196
+ // .vitepress/config.ts
197
+ import { defineConfigWithTheme } from 'vitepress'
198
+ import { type ThemeConfig, whatsaaaaConfig } from '@whatsaaaa/design-system/vitepress/config'
199
+ export default defineConfigWithTheme<ThemeConfig>({
200
+ extends: whatsaaaaConfig() /* the site's own config */,
201
+ })
202
+ ```
203
+
204
+ Keep the site's nav, sidebar and search config as they are. Do not restyle the theme with `--vp-*` variables: change a token here instead.
205
+
206
+ From 60rem up the brand has a box as wide as the sidebar, and the first tab starts on the sidebar's border, on pages without a sidebar too. With a logo there is room for about 23 characters in the site title, without one about 28. A longer title is cut with an ellipsis, and a short one leaves a gap before the tabs. The labels of the tabs have no such limit. Below 60rem there is no sidebar and the tabs follow the brand, and on a phone they take a row of their own under it.
207
+
208
+ ## 11. Data
209
+
210
+ The tokens as data, for code that cannot read CSS:
211
+
212
+ ```ts
213
+ import { resolver } from '@whatsaaaa/design-system/tokens'
214
+
215
+ const dark = resolver.apply({ theme: 'dark' })
216
+ dark['color.bg'].$value.hex // '#191724'
217
+ ```
218
+
219
+ The sources are in `tokens/`, in the Design Tokens Community Group format.
220
+
221
+ ## Before you finish
222
+
223
+ - No hex values, no `--ws-palette-*` in interface code, no fonts from elsewhere.
224
+ - It reads in both themes. Check with `data-theme="light"` on `<html>`.
225
+ - Nothing overflows sideways at 390 px.
226
+ - Every key hint works, every status has a word, every control can be reached and seen with the keyboard.
@@ -0,0 +1,10 @@
1
+ # Licenses of what the system builds on
2
+
3
+ | What | License | Where it is used | File |
4
+ | --- | --- | --- | --- |
5
+ | Rosé Pine palette, from `@rose-pine/palette` | MIT, Copyright (c) mvllow | The color values in `tokens/palette.tokens.json` and everything built from them | `rose-pine-palette.LICENSE` |
6
+ | JetBrains Mono | SIL Open Font License 1.1 | The mono face. The font files are copied from `@fontsource-variable/jetbrains-mono` into `dist/fonts/` at build time, with the license next to them. Text in the generated artwork is outlined from `@fontsource/jetbrains-mono` | `dist/fonts/jetbrains-mono.OFL.txt`, written by the build |
7
+ | Inter | SIL Open Font License 1.1 | The sans face. The font files are copied from `@fontsource-variable/inter` into `dist/fonts/` at build time, with the license next to them | `dist/fonts/inter.OFL.txt`, written by the build |
8
+ | Departure Mono | SIL Open Font License 1.1, Copyright 2022-2024 Helena Zhang | Pixel outlines of six glyphs, in `src/ghost/glyphs.ts`, for the speech bubble of the ghost | `departure-mono.OFL.txt` |
9
+
10
+ No font file is kept in this repository.
@@ -0,0 +1,93 @@
1
+ Copyright 2022–2024 Helena Zhang (helenazhang.com).
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) mvllow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,165 @@
1
1
  {
2
2
  "name": "@whatsaaaa/design-system",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Whatsaaaa's design system: brand identity, design tokens, typography, docs theme and asset kit",
5
+ "homepage": "https://github.com/whatsaaaa/design-system#readme",
6
+ "bugs": "https://github.com/whatsaaaa/design-system/issues",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "author": "Whatsaaaa",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/whatsaaaa/design-system.git"
12
+ },
13
+ "files": [
14
+ "assets",
15
+ "dist",
16
+ "docs/usage.md",
17
+ "licenses",
18
+ "src/vitepress",
19
+ "tokens"
20
+ ],
21
+ "type": "module",
22
+ "sideEffects": [
23
+ "**/*.css",
24
+ "./src/vitepress/**"
25
+ ],
26
+ "exports": {
27
+ "./index.css": "./dist/index.css",
28
+ "./tokens.css": "./dist/tokens.css",
29
+ "./fonts.css": "./dist/fonts.css",
30
+ "./css/*.css": "./dist/css/*.css",
31
+ "./fonts/*": "./dist/fonts/*",
32
+ "./tokens": {
33
+ "types": "./dist/tokens.d.ts",
34
+ "default": "./dist/tokens.js"
35
+ },
36
+ "./tokens/*.json": "./tokens/*.json",
37
+ "./ghost": {
38
+ "types": "./dist/ghost/index.d.ts",
39
+ "default": "./dist/ghost/index.js"
40
+ },
41
+ "./theme": {
42
+ "types": "./dist/theme/index.d.ts",
43
+ "default": "./dist/theme/index.js"
44
+ },
45
+ "./theme/init.js": "./dist/theme/init.js",
46
+ "./shortcuts": {
47
+ "types": "./dist/shortcuts/index.d.ts",
48
+ "default": "./dist/shortcuts/index.js"
49
+ },
50
+ "./shortcuts/init.js": "./dist/shortcuts/init.js",
51
+ "./shiki": {
52
+ "types": "./dist/shiki/index.d.ts",
53
+ "default": "./dist/shiki/index.js"
54
+ },
55
+ "./vitepress": {
56
+ "types": "./src/vitepress/theme.d.ts",
57
+ "default": "./src/vitepress/index.ts"
58
+ },
59
+ "./vitepress/config": {
60
+ "types": "./dist/vitepress-config/index.d.ts",
61
+ "default": "./dist/vitepress-config/index.js"
62
+ },
63
+ "./assets/*": "./assets/*",
64
+ "./package.json": "./package.json"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "dependencies": {
70
+ "@terrazzo/token-types": "2.10.0"
71
+ },
72
+ "devDependencies": {
73
+ "@changesets/changelog-github": "^1.0.1",
74
+ "@changesets/cli": "^3.0.3",
75
+ "@fontsource-variable/inter": "^5.3.0",
76
+ "@fontsource-variable/jetbrains-mono": "^5.3.0",
77
+ "@fontsource/jetbrains-mono": "^5.3.0",
78
+ "@playwright/test": "^1.65.0",
79
+ "@resvg/resvg-js": "^2.6.2",
80
+ "@rose-pine/palette": "^4.0.1",
81
+ "@terrazzo/cli": "^2.10.0",
82
+ "@terrazzo/plugin-css": "^2.10.0",
83
+ "@terrazzo/plugin-js": "^2.10.0",
84
+ "@tsconfig/node24": "^24.0.5",
85
+ "@types/culori": "^4.0.1",
86
+ "@types/fontkit": "^2.0.9",
87
+ "@types/node": "^24.19.2",
88
+ "@types/opentype.js": "^1.3.10",
89
+ "@vue/eslint-config-typescript": "^14.9.0",
90
+ "culori": "^4.0.2",
91
+ "eslint": "^10.14.0",
92
+ "eslint-config-prettier": "^10.1.8",
93
+ "eslint-plugin-oxlint": "^1.93.0",
94
+ "eslint-plugin-vue": "^10.12.1",
95
+ "fontkit": "^2.0.4",
96
+ "happy-dom": "^21.0.4",
97
+ "jiti": "^2.7.0",
98
+ "lightningcss": "^1.33.0",
99
+ "npm-run-all2": "^9.0.4",
100
+ "opentype.js": "^2.0.0",
101
+ "oxfmt": "^0.78.0",
102
+ "oxlint": "^1.93.0",
103
+ "png-to-ico": "^3.0.2",
104
+ "postcss-html": "^2.0.0",
105
+ "publint": "^0.3.25",
106
+ "stylelint": "^18.0.0",
107
+ "stylelint-config-standard": "^41.0.0",
108
+ "stylelint-value-no-unknown-custom-properties": "^6.1.1",
109
+ "typescript": "~6.0.3",
110
+ "vitepress": "^1.6.4",
111
+ "vitest": "^5.1.0",
112
+ "vue": "^3.5.45",
113
+ "vue-eslint-parser": "^10.4.2",
114
+ "vue-tsc": "^3.3.14",
115
+ "yaml": "^2.9.1"
116
+ },
117
+ "peerDependencies": {
118
+ "vitepress": "^1.6.4",
119
+ "vue": "^3.5.0"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "vitepress": {
123
+ "optional": true
124
+ },
125
+ "vue": {
126
+ "optional": true
127
+ }
128
+ },
129
+ "engines": {
130
+ "node": "^22.18.0 || >=24.12.0"
131
+ },
132
+ "scripts": {
133
+ "build": "run-s build:tokens build:fonts build:css build:js",
134
+ "build:tokens": "tz build",
135
+ "build:fonts": "node scripts/build-fonts.ts",
136
+ "build:css": "node scripts/build-css.ts",
137
+ "build:js": "tsc -p tsconfig.build.json && node scripts/build-head-scripts.ts",
138
+ "assets": "pnpm build:tokens && node scripts/generate-assets.ts",
139
+ "assets:check": "pnpm build:tokens && node scripts/generate-assets.ts --check",
140
+ "contrast": "pnpm build:tokens && node scripts/check-contrast.ts",
141
+ "styleguide:dev": "run-s build styleguide:prepare styleguide:serve",
142
+ "styleguide:build": "run-s build styleguide:prepare styleguide:compile",
143
+ "styleguide:preview": "vitepress preview styleguide",
144
+ "styleguide:prepare": "node scripts/prepare-styleguide.ts",
145
+ "styleguide:serve": "vitepress dev styleguide",
146
+ "styleguide:compile": "vitepress build styleguide",
147
+ "test": "run-s build test:unit",
148
+ "test:unit": "vitest run",
149
+ "test:browser": "run-s styleguide:build test:browser:run",
150
+ "test:browser:run": "playwright test",
151
+ "test:browser:docker": "sh scripts/browser-tests-in-docker.sh",
152
+ "test:browser:update": "sh scripts/browser-tests-in-docker.sh --update-snapshots",
153
+ "type-check": "run-s build type-check:ts type-check:vue",
154
+ "type-check:ts": "tsc --noEmit",
155
+ "type-check:vue": "vue-tsc --noEmit -p tsconfig.vue.json",
156
+ "lint": "run-s build lint:tokens lint:oxlint lint:eslint lint:css lint:package",
157
+ "lint:tokens": "tz check",
158
+ "lint:oxlint": "oxlint . --fix",
159
+ "lint:eslint": "eslint . --fix --cache",
160
+ "lint:css": "stylelint \"src/**/*.css\" \"styleguide/**/*.{css,vue}\" --fix",
161
+ "lint:package": "publint",
162
+ "format": "oxfmt .",
163
+ "format:check": "oxfmt --check ."
164
+ }
6
165
  }
@@ -0,0 +1,77 @@
1
+ <script setup lang="ts">
2
+ import { inBrowser, useData } from 'vitepress'
3
+ import DefaultTheme from 'vitepress/theme-without-fonts'
4
+ import { onMounted, onUnmounted, watchEffect } from 'vue'
5
+ import { defineGhost } from '../../dist/ghost/index.js'
6
+ import { enableShortcuts, isTyping, shortcutsOn } from '../../dist/shortcuts/index.js'
7
+ import Crumb from './components/Crumb.vue'
8
+ import NavGhost from './components/NavGhost.vue'
9
+ import NotFound from './components/NotFound.vue'
10
+ import StatusLine from './components/StatusLine.vue'
11
+
12
+ const { isDark } = useData()
13
+
14
+ /** The slots this layout fills itself. A site's content for them goes inside, next to the theme's. */
15
+ const OWN_SLOTS = ['nav-bar-content-after', 'doc-before', 'not-found', 'layout-bottom']
16
+
17
+ // VitePress marks dark with a class on <html>. The tokens read data-theme, so mirror it.
18
+ watchEffect(() => {
19
+ if (inBrowser) document.documentElement.dataset.theme = isDark.value ? 'dark' : 'light'
20
+ })
21
+
22
+ /**
23
+ * VitePress listens for / itself, on the window, and opens the search. With the keys
24
+ * switched off that key rests like the others, so it is stopped here on its way there.
25
+ */
26
+ function restSearchKey(event: KeyboardEvent) {
27
+ if (event.key !== '/' || shortcutsOn()) return
28
+ if (event.target instanceof Element && isTyping(event.target)) return
29
+ event.stopPropagation()
30
+ }
31
+
32
+ let disableShortcuts: (() => void) | undefined
33
+ onMounted(() => {
34
+ defineGhost()
35
+ // the tabs here are the links of the default theme's nav bar, numbered in nav.css
36
+ disableShortcuts = enableShortcuts({
37
+ tabs: '.VPNavBarMenu > .VPNavBarMenuLink, .VPNavBarMenu > .VPNavBarMenuGroup .button',
38
+ })
39
+ document.addEventListener('keydown', restSearchKey)
40
+ })
41
+ onUnmounted(() => {
42
+ disableShortcuts?.()
43
+ document.removeEventListener('keydown', restSearchKey)
44
+ })
45
+ </script>
46
+
47
+ <template>
48
+ <DefaultTheme.Layout>
49
+ <!-- every slot of the default theme stays open to a site that wraps this layout -->
50
+ <template
51
+ v-for="name in Object.keys($slots).filter((slot) => !OWN_SLOTS.includes(slot))"
52
+ :key="name"
53
+ #[name]="slotProps"
54
+ >
55
+ <slot :name="name" v-bind="slotProps ?? {}" />
56
+ </template>
57
+
58
+ <template #nav-bar-content-after>
59
+ <NavGhost />
60
+ <slot name="nav-bar-content-after" />
61
+ </template>
62
+
63
+ <template #doc-before>
64
+ <Crumb />
65
+ <slot name="doc-before" />
66
+ </template>
67
+
68
+ <template #not-found>
69
+ <slot name="not-found"><NotFound /></slot>
70
+ </template>
71
+
72
+ <template #layout-bottom>
73
+ <slot name="layout-bottom" />
74
+ <StatusLine />
75
+ </template>
76
+ </DefaultTheme.Layout>
77
+ </template>
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import { type DefaultTheme, useData } from 'vitepress'
3
+ import { useSidebar } from 'vitepress/theme-without-fonts'
4
+ import { computed } from 'vue'
5
+ import { isActiveLink } from '../support.ts'
6
+ import type { ThemeConfig } from '../../../dist/vitepress-config/types.js'
7
+
8
+ const { theme, page } = useData<ThemeConfig>()
9
+ const { sidebarGroups } = useSidebar()
10
+
11
+ /** The path to this page: its tab, its group in the sidebar, then the page itself. */
12
+ const trail = computed(() => {
13
+ const path = page.value.relativePath
14
+ const tab = (theme.value.nav ?? []).find(
15
+ (item): item is DefaultTheme.NavItemWithLink =>
16
+ 'link' in item && isActiveLink(path, item.activeMatch ?? item.link, !!item.activeMatch),
17
+ )
18
+ const group = sidebarGroups.value.find((candidate) =>
19
+ (candidate.items ?? []).some((item) => item.link && isActiveLink(path, item.link)),
20
+ )
21
+ // a tab and a group often share a name. The path is shown in lowercase, so compare that way
22
+ const parts = [tab?.text, group?.text, page.value.title].filter((part): part is string => !!part)
23
+ const lower = parts.map((part) => part.toLowerCase())
24
+ return parts.filter((_, index) => lower.indexOf(lower[index]!) === index)
25
+ })
26
+ </script>
27
+
28
+ <template>
29
+ <p v-if="trail.length > 1" class="ws-crumb WsCrumb">
30
+ <span v-for="part in trail" :key="part">{{ part }}</span>
31
+ </p>
32
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ import { useData } from 'vitepress'
3
+ import { computed, h } from 'vue'
4
+ import { ghostMarkup, ghostSvg } from '../../../dist/ghost/index.js'
5
+ import type { ThemeConfig } from '../../../dist/vitepress-config/types.js'
6
+
7
+ const { theme } = useData<ThemeConfig>()
8
+ const mode = computed(() => theme.value.whatsaaaa?.ghost ?? 'link')
9
+ /** The handle's site, where the ghost on a project's docs links to. */
10
+ const home = 'https://whatsaaaa.github.io/'
11
+
12
+ // <ws-ghost> is a custom element. Rendered with h() it needs no compiler option in the site's
13
+ // config, and its inner markup comes with the page so the ghost is there before any script runs.
14
+ const Egg = () => h('ws-ghost', { px: 2, bubble: 'below', innerHTML: ghostMarkup({ px: 2 }) })
15
+ </script>
16
+
17
+ <template>
18
+ <div class="WsNavGhost">
19
+ <Egg v-if="mode === 'egg'" />
20
+ <!-- eslint-disable-next-line vue/no-v-html -- markup built by the ghost module, no user input -->
21
+ <a v-else :href="home" aria-label="A whatsaaaa project" v-html="ghostSvg({ px: 2 })" />
22
+ </div>
23
+ </template>