@stratixlabs/core 1.7.1

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 Mikael Carrara
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 ADDED
@@ -0,0 +1,249 @@
1
+ # Substrata
2
+
3
+ Substrata is a framework-agnostic **design infrastructure** for tokens, schemas, and automation that transforms design decisions into **semantic contracts**. It serves as a stable foundation for semantic design governance, enabling automation, consistency, and long-term resilience across any platform or tech stack.
4
+
5
+ Unlike a UI library that couples design to components, Substrata provides the low-level *definitions* (design tokens and their canonical graph) that drive the UI, ensuring design intent is preserved from design tools to production code—even as frameworks change.
6
+
7
+ **[Documentation](https://mikaelcarrara.github.io/substrata)**
8
+
9
+ ---
10
+
11
+ ## Philosophy
12
+
13
+ Substrata is guided by a core set of architectural principles: tokens are the atomic foundation of design; infrastructure must outlive frameworks; and a single source of truth prevents divergence. We design for durability and longevity, achieving consistency through architecture, not discipline. Our focus is on defining the foundation, not the final UI surfaces.
14
+
15
+ See our policies on [**Governance**](./GOVERNANCE.md) and [**Contributing**](./CONTRIBUTING.md).
16
+
17
+ ---
18
+
19
+ ## Architecture
20
+
21
+ Substrata is architected as a system of independent layers. Each layer encapsulates a distinct responsibility and can evolve independently, enabling long-term scalability, resilience, and architectural clarity.
22
+
23
+ 1. **Tokens**: Define design decisions as CSS Variables—colors, spacing, typography, and core primitives. They are semantic, stable, versionable, and platform-agnostic.
24
+ 2. **Base Styles**: Apply tokens to native HTML elements, establishing predictable defaults and consistent rendering without adding abstractions or components.
25
+ 3. **Components**: Optional reference patterns for consuming tokens in real interfaces. They demonstrate usage, not prescribe a UI library.
26
+
27
+ This layered approach ensures that the core design system remains decoupled from any specific implementation.
28
+
29
+ ---
30
+
31
+ ## W3C Alignment
32
+
33
+ Substrata implements the "Source of Truth" layer in the W3C reference architecture:
34
+
35
+ 1. **Definition**: Design intent defined in design tools (e.g., Figma).
36
+ 2. **Transformation**: Raw data processed into usable artifacts.
37
+ 3. **Source of Truth (Substrata)**: The detailed, versioned, and semantic definition of all tokens (CSS variables, JSON).
38
+ 4. **Consumption**: Applications (React, Vue, iOS, Android) consuming these tokens.
39
+
40
+ Read more in [W3C Alignment](./docs/w3c-alignment.html).
41
+
42
+ ---
43
+
44
+ ## Choose Your Path
45
+
46
+ Substrata is designed to be used in three distinct ways depending on your goal.
47
+
48
+ | Path | Goal | Installation | Tool |
49
+ | :--- | :--- | :--- | :--- |
50
+ | **1. Consumer** | Use default tokens in your app | `npm install @stratixlabs/core` | NPM |
51
+ | **2. Author** | Manage your own design system | `npx @stratixlabs/core init` | CLI (NPX) |
52
+ | **3. Contributor** | Modify Substrata core/docs | `git clone ...` | Git |
53
+
54
+ ---
55
+
56
+ ### Path 1: Consumer (Recommended)
57
+ Best for developers who want to use the official Substrata tokens (colors, spacing, etc.) in their project.
58
+
59
+ ```bash
60
+ npm install @stratixlabs/core
61
+ ```
62
+ *See [Getting Started](https://mikaelcarrara.github.io/substrata/getting-started) for importing CSS/JSON.*
63
+
64
+ ### Path 2: Author & Automation
65
+ Best for architects building a custom design system using Substrata as the engine.
66
+
67
+ `init` scaffolds a **complete, production-ready** system:
68
+
69
+ **📦 Generated Structure:**
70
+ - `substrata.config.js` - Configuration file
71
+ - `src/tokens/` - **9 token files** (colors, spacing, typography, radius-and-borders, elevation, motion, opacity, breakpoints, semantic-aliases)
72
+ - `src/consumption/` - **3 framework examples** (Tailwind, styled-components, plain CSS)
73
+ - `scripts/` - Automation scripts (generate, validate, lint, breaking-change detection, token-aware code lint)
74
+ - `src/substrata.css` - Main entry point (imports all tokens)
75
+ - `src/base.css` - Typography reset and base styles
76
+
77
+ **📜 NPM Scripts Added:**
78
+ - `build:tokens` - Generate tokens.json from CSS
79
+ - `test:tokens` - Validate token structure
80
+ - `lint:tokens` - Check for hardcoded values
81
+ - `lint:code` - Enforce correct token usage in application code
82
+ - `detect:breaking` - Detect breaking changes between tokens.json versions
83
+
84
+ ```bash
85
+ # Set up complete design system infrastructure
86
+ npx @stratixlabs/core init
87
+
88
+ # Generate tokens.json
89
+ npm run build:tokens
90
+
91
+ # Validate tokens (optional)
92
+ npm run test:tokens
93
+ ```
94
+
95
+ Then import `src/substrata.css` in your app. Check `src/consumption/` for framework-specific integration examples.
96
+
97
+ *See [Authoring & Automation](https://mikaelcarrara.github.io/substrata/automation) for detailed guide.*
98
+
99
+ ### Path 3: Contributor
100
+ Best for those who want to improve Substrata itself or host their own fork.
101
+
102
+ ```bash
103
+ git clone https://github.com/mikaelcarrara/substrata.git
104
+ cd substrata
105
+ npm install
106
+ npm run build:tokens
107
+ ```
108
+
109
+ ### Manual Download
110
+
111
+ Clone or download from GitHub:
112
+
113
+ ```bash
114
+ git clone https://github.com/mikaelcarrara/substrata.git
115
+ ```
116
+
117
+ Or download directly and include in your project.
118
+
119
+ ## Usage
120
+
121
+ Substrata is designed to be consumed, not imposed. You can use it in multiple ways:
122
+
123
+ ### 1. Plain CSS
124
+ Import the full system or valid subsets from the package:
125
+ ```css
126
+ /* Import everything */
127
+ @import "@stratixlabs/core/substrata.css";
128
+
129
+ /* Or just tokens */
130
+ @import "@stratixlabs/core/src/tokens/colors.css";
131
+ ```
132
+
133
+ ### 2. Tailwind CSS
134
+ Substrata feeds Tailwind. It does not replace it.
135
+ ```css
136
+ @import "@stratixlabs/core/substrata.css";
137
+ @tailwind base;
138
+ @tailwind components;
139
+ @tailwind utilities;
140
+ ```
141
+ *See the [Next.js + Tailwind Quickstart](https://mikaelcarrara.github.io/substrata/getting-started#quickstart-next-tailwind) for a full app example, and [Consumption Strategies](./docs/consumption.html) for `tailwind.config.js` mapping.*
142
+
143
+ ### 3. JavaScript / TypeScript
144
+ Import tokens as a JSON object:
145
+ ```js
146
+ import tokens from '@stratixlabs/core';
147
+
148
+ const Button = styled.button`
149
+ padding: ${tokens.space[3].value} ${tokens.space[4].value};
150
+ background: ${tokens.color.brand[500].value};
151
+ border-radius: ${tokens.radius.md.value};
152
+ `;
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Documentation
158
+
159
+ Full documentation is available online. Key sections include [**Getting Started**](https://mikaelcarrara.github.io/substrata/getting-started), the [**Tokens Reference**](https://mikaelcarrara.github.io/substrata/tokens), [**Consumption Strategies**](https://mikaelcarrara.github.io/substrata/consumption), and guides on [**Automation**](https://mikaelcarrara.github.io/substrata/automation).
160
+
161
+ ---
162
+
163
+ ## Naming Conventions
164
+
165
+ Tokens use kebab-case and semantic grouping:
166
+ - Colors: `neutral-100`, `brand-500`, `color-surface`, `color-text-primary`
167
+ - Spacing: `space-1` ... `space-6`
168
+ - Typography: `font-size-sm`, `font-weight-bold`, `line-height-normal`
169
+ - Radius/Borders: `radius-sm`, `border-width`
170
+ - Motion/Elevation/Opacity: `duration-sm`, `shadow-sm`, `opacity-80`
171
+ - Breakpoints: `breakpoint-sm`, `breakpoint-md`, `breakpoint-lg`
172
+
173
+ Semantic aliases (see `src/tokens/semantic-aliases.css`) map raw tokens to intended usage, e.g.:
174
+ - Surface: `color-surface`
175
+ - Brand: `color-brand-primary`, `color-brand-hover`
176
+ - Text: `color-text-primary`, `color-text-inverse`
177
+
178
+ These aliases help preserve intent across frameworks and refactors.
179
+
180
+ ---
181
+
182
+ ## Core Artifacts
183
+
184
+ Substrata's architecture is defined by a few key artifacts that enable its semantic power:
185
+
186
+ - **`tokens.json`**: The canonical source of truth, containing all design tokens in a structured, machine-readable format.
187
+ - **JSON Schema**: A strict schema for `tokens.json` that enables validation, IDE autocompletion, and automated CI checks.
188
+ - **`substrata.d.ts`**: TypeScript declarations for type-safe token consumption in modern development workflows.
189
+
190
+ See the [**ROADMAP.md**](./ROADMAP.md) and [**ARCHITECTURE.md**](./ARCHITECTURE.md) for more details on our architectural evolution.
191
+
192
+ ---
193
+
194
+ ## Tooling & Scripts
195
+
196
+ - [detect-breaking-changes.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/detect-breaking-changes.js)
197
+ - What it does: Detects when tokens are removed or renamed
198
+ - Foundation: Basic validation, table stakes
199
+
200
+ - [figma-sync.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/figma-sync.js)
201
+ - What it does: Pull/push tokens to/from Figma
202
+ - Foundation: The design ↔ code bridge you want standard
203
+
204
+ - [generate-dts-from-tokens.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/generate-dts-from-tokens.js)
205
+ - What it does: Generates TypeScript definitions
206
+ - Why core: Basic DX expected in modern libraries
207
+
208
+ - [generate-tokens.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/generate-tokens.js)
209
+ - What it does: CSS → tokens.json
210
+ - Foundation: Fundamental build pipeline
211
+
212
+ - [lint-code.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/lint-code.js)
213
+ - What it does: Detects hardcoded values in code
214
+ - Foundation: Basic linting is expected
215
+
216
+ - [lint-hardcoded.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/lint-hardcoded.js)
217
+ - What it does: Similar, detects hardcoded values
218
+ - Foundation: Basic quality tooling
219
+
220
+ - [tokens-to-css.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/tokens-to-css.js)
221
+ - What it does: tokens.json → CSS variables
222
+ - Foundation: The bidirectional loop you promised
223
+
224
+ - [validate-tokens.js](file:///c:/Users/Usuario/Desktop/substrata/scripts/validate-tokens.js)
225
+ - What it does: Validates tokens.json against schema
226
+ - Foundation: Validation is fundamental
227
+
228
+ ---
229
+
230
+ ### Usage Snippets
231
+
232
+ ```bash
233
+ npm run detect:breaking
234
+ npm run sync:figma
235
+ FIGMA_SYNC_DIRECTION=push npm run sync:figma
236
+ FIGMA_TOKEN=... FIGMA_FILE_KEY=... npx @stratixlabs/core figma apply-preview
237
+ npm run build:types
238
+ npm run build:tokens
239
+ npm run lint:code
240
+ npm run lint:tokens
241
+ npm run build:css-from-tokens
242
+ npm run test:tokens
243
+ ```
244
+
245
+ ---
246
+
247
+ ## License
248
+
249
+ MIT © 2026 Mikael Carrara