@noix-dev/brix-tokens 0.0.0-stage → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NoiX
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/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @noix-dev/brix-tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The CSS half of Brix, a small design system for Vue 3 and Tailwind CSS 4
4
+ applications: a contract of 71 role tokens bound in light and dark, three
5
+ themes, the two density axes, and the Tailwind wiring that turns the roles into
6
+ utilities such as `bg-primary` and `text-muted-foreground`.
7
+
8
+ No JavaScript and no build step — the package ships CSS, and your application's
9
+ Tailwind compiles it.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add @noix-dev/brix-tokens tailwindcss
15
+ ```
16
+
17
+ Tailwind CSS 4 is a peer dependency; this package imports it for you.
18
+
19
+ ## Use
20
+
21
+ Three lines, and a theme is one of them. Put them in your Tailwind entry
22
+ stylesheet, **in place of your own `@import 'tailwindcss'`**:
23
+
24
+ ```css
25
+ /* src/app.css */
26
+ @import '@noix-dev/brix-tokens';
27
+ @import '@noix-dev/brix-tokens/themes/kingfisher.css';
28
+ ```
29
+
30
+ Then pick the theme on the root element. Dark is a mode of every theme and is
31
+ switched with the `dark` class:
32
+
33
+ ```html
34
+ <html data-brix-theme="kingfisher" class="dark"></html>
35
+ ```
36
+
37
+ `graphite` (neutral greys, the one to copy when starting a palette), `noix`
38
+ (cyan on cool greys) and `kingfisher` (deep teal and orange) ship with the
39
+ package. No theme is imported for you: the contract says which roles exist, a
40
+ theme says what they look like.
41
+
42
+ Density is a user preference, never part of a theme: `data-brix-table-density` for tables
43
+ and `data-brix-page-density` for pages, both on the root element, where the value
44
+ `normal` sets no attribute at all.
45
+
46
+ A theme names a font family in `--font-sans` and nothing fetches it. For the
47
+ shortcut, `@import '@noix-dev/brix-tokens/fonts.css'` fetches the family the shipped
48
+ themes name.
49
+
50
+ ## Components
51
+
52
+ `@noix-dev/brix-vue` holds the Vue components built on these roles, and
53
+ `@noix-dev/brix-core` applies a theme, a colour mode and the densities to the
54
+ document. Using the components means one more import line, in the **same** CSS
55
+ file — see their READMEs.
56
+
57
+ ## Repository
58
+
59
+ <https://github.com/NoiXdev/noix-brix> — MIT.
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "@noix-dev/brix-tokens",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "The Brix token contract: role tokens in light and dark, density rules, themes and the Tailwind wiring",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "sideEffects": [
8
+ "**/*.css"
9
+ ],
10
+ "exports": {
11
+ ".": "./src/index.css",
12
+ "./themes/*.css": "./src/themes/*.css",
13
+ "./fonts.css": "./src/fonts.css",
14
+ "./contrast": "./src/contrast.ts",
15
+ "./canvasColor": "./src/canvasColor.ts",
16
+ "./perceptual": "./src/perceptual.ts",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "src"
21
+ ],
22
+ "dependencies": {
23
+ "tw-animate-css": "^1.4.0"
24
+ },
25
+ "peerDependencies": {
26
+ "tailwindcss": "^4.3.4"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^26.6.6",
30
+ "typescript": "~5.8.3",
31
+ "vite": "^7.3.7",
32
+ "vitest": "^4.1.12"
33
+ },
34
+ "scripts": {
35
+ "lint": "eslint . --max-warnings 0",
36
+ "typecheck": "tsc -p tsconfig.json --noEmit",
37
+ "test": "vitest run"
38
+ }
6
39
  }
@@ -0,0 +1,39 @@
1
+ import { formatHex, parseColor, wash } from './contrast';
2
+
3
+ /**
4
+ * The colour a `<canvas>` paints with, read out of a role's declared value.
5
+ *
6
+ * A canvas cannot take a colour from CSS, so the value has to be handed over as a string,
7
+ * and chart.js's parser rejects every `oklab()` and `oklch()` form. It answers `undefined`
8
+ * and throws nothing, so a canvas silently keeps its previous fill. This function is the
9
+ * one place that turns a declared role into a string the canvas accepts, and it refuses
10
+ * rather than hands over something that would draw the wrong colour.
11
+ *
12
+ * An opaque role comes back as `#rrggbb`. A translucent role is composited over the
13
+ * opaque `ground` it is drawn on, with `wash(declared, ground, 1)`. The mix is `1` on
14
+ * purpose: `wash` already multiplies the mix by the layer's own alpha, so passing the alpha
15
+ * as the mix would spend it twice and thin a 10% border down to 1%.
16
+ *
17
+ * An empty `declared` is refused before parsing. `getComputedStyle` answers an empty string
18
+ * for a role no theme declares, and the message `parseColor` gives for `''` names which
19
+ * colour syntaxes are supported, not which role was missing.
20
+ *
21
+ * `ground` IS ONLY LOOKED AT ON THE TRANSLUCENT PATH. An opaque `declared` returns before the
22
+ * ground is read, so a malformed, empty or itself-translucent ground passes unnoticed for
23
+ * every opaque role and is refused the moment one translucent role is handed over — the same
24
+ * call site, failing on a different theme or mode. A caller that wants the ground checked for
25
+ * its own sake has to check it itself; this function refuses what it uses.
26
+ */
27
+ export function canvasColor(declared: string, ground: string): string {
28
+ if (declared.trim() === '') {
29
+ throw new Error(
30
+ 'cannot paint a canvas: the declared value is empty, so the role it was read for ' +
31
+ 'is not declared by the active theme',
32
+ );
33
+ }
34
+ const color = parseColor(declared);
35
+ if (color.alpha === 1) {
36
+ return formatHex(color);
37
+ }
38
+ return wash(declared, ground, 1);
39
+ }