@mindvalley/design-system 3.4.0 → 4.0.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/CHANGELOG.md +283 -6
- package/dist/b2b.d.ts +115 -51
- package/dist/b2b.d.ts.map +1 -1
- package/dist/b2b.js +1 -1
- package/dist/b2b.js.map +1 -1
- package/dist/helpers/casing.d.ts.map +1 -1
- package/dist/helpers/casing.js +21 -23
- package/dist/helpers/dimens.d.ts +1 -0
- package/dist/helpers/dimens.d.ts.map +1 -1
- package/dist/helpers/dimens.js +11 -2
- package/dist/helpers/regex.d.ts.map +1 -1
- package/dist/index.d.ts +98 -83
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tailwind/plugins/tokens/b2b/typography.d.ts.map +1 -1
- package/dist/tailwind/plugins/tokens/b2b/typography.js +25 -26
- package/dist/tailwind/plugins/tokens/mindvalley/typography.d.ts.map +1 -1
- package/dist/tailwind/plugins/tokens/mindvalley/typography.js +60 -67
- package/dist/tailwind/plugins/typography.d.ts.map +1 -1
- package/dist/tailwind/plugins/typography.js +25 -15
- package/dist/typography/b2b/fonts.css +19 -0
- package/dist/typography/b2b/fonts.d.ts +8 -0
- package/dist/typography/b2b/fonts.js +30 -0
- package/dist/typography/mindvalley/fonts.css +43 -0
- package/dist/typography/mindvalley/fonts.d.ts +8 -0
- package/dist/typography/mindvalley/fonts.js +54 -0
- package/docs/CONTRIBUTION.md +3 -3
- package/docs/RELEASING.md +12 -7
- package/docs/USAGE.md +121 -76
- package/docs/typography-fonts.md +552 -0
- package/docs/typography-token-pipeline-b2b.md +156 -0
- package/package.json +31 -23
- package/docs/token-validation.md +0 -298
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindvalley/design-system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Resources, components, design guidelines and tooling for Mindvalley's design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design-system",
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"types": "./dist/tailwind/*.d.ts",
|
|
43
43
|
"default": "./dist/tailwind/*.js"
|
|
44
44
|
},
|
|
45
|
+
"./typography/*": {
|
|
46
|
+
"types": "./dist/typography/*.d.ts",
|
|
47
|
+
"default": "./dist/typography/*"
|
|
48
|
+
},
|
|
45
49
|
"./dist/*": "./dist/*"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
@@ -57,57 +61,60 @@
|
|
|
57
61
|
"build:figma:wordmarks": "tsx ./node_modules/@figma-export/cli/bin/run use-config ./src/utilities/svg-import/.figma_wordmarks.ts",
|
|
58
62
|
"build:styledictionary": "ts-node ./build.ts",
|
|
59
63
|
"clean:docs": "rimraf 'src/assets/**/docs' --glob",
|
|
60
|
-
"commit": "
|
|
64
|
+
"commit": "czg",
|
|
61
65
|
"commitlint": "commitlint --edit",
|
|
62
66
|
"prepare": "husky install",
|
|
63
|
-
"release": "semantic-release --debug",
|
|
67
|
+
"release": "semantic-release --debug --config release.config.js",
|
|
64
68
|
"test": "jest --verbose",
|
|
65
69
|
"test:watch": "jest --watch",
|
|
66
70
|
"watch": "webpack --mode development --watch",
|
|
67
71
|
"type-check": "tsc --noEmit",
|
|
68
|
-
"build:types": "tsc --emitDeclarationOnly"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
73
|
+
"format": "biome format --write ./src",
|
|
74
|
+
"format:check": "biome format ./src",
|
|
75
|
+
"lint": "biome lint ./src",
|
|
76
|
+
"lint:fix": "biome lint --write ./src",
|
|
77
|
+
"check": "biome check --write ./src",
|
|
78
|
+
"check:ci": "biome ci ./src",
|
|
79
|
+
"check:staged": "biome check --staged",
|
|
80
|
+
"check:changed": "biome check --changed"
|
|
76
81
|
},
|
|
77
82
|
"devDependencies": {
|
|
78
83
|
"@babel/core": "^7.22.9",
|
|
79
84
|
"@babel/preset-env": "^7.22.9",
|
|
80
85
|
"@babel/preset-typescript": "^7.27.1",
|
|
86
|
+
"@biomejs/biome": "^2.3.4",
|
|
81
87
|
"@commitlint/cli": "^17.7.1",
|
|
82
88
|
"@commitlint/config-conventional": "^17.7.0",
|
|
83
|
-
"@figma-export/cli": "^
|
|
84
|
-
"@figma-export/output-components-as-svg": "^
|
|
85
|
-
"@figma-export/transform-svg-with-svgo": "^
|
|
86
|
-
"@figma-export/types": "^6.2.
|
|
89
|
+
"@figma-export/cli": "^6.2.3",
|
|
90
|
+
"@figma-export/output-components-as-svg": "^6.2.3",
|
|
91
|
+
"@figma-export/transform-svg-with-svgo": "^6.2.3",
|
|
92
|
+
"@figma-export/types": "^6.2.3",
|
|
87
93
|
"@semantic-release/changelog": "^6.0.3",
|
|
88
|
-
"@types/jest": "^
|
|
94
|
+
"@types/jest": "^30.0.0",
|
|
89
95
|
"@types/lodash.kebabcase": "^4.1.9",
|
|
90
96
|
"@types/node": "^24.1.0",
|
|
97
|
+
"@types/svg-sprite": "^0.0.39",
|
|
91
98
|
"@types/tailwindcss": "^3.0.11",
|
|
92
99
|
"@types/tinycolor2": "^1.4.6",
|
|
93
|
-
"babel-jest": "^
|
|
100
|
+
"babel-jest": "^30.1.2",
|
|
94
101
|
"babel-loader": "^8.2.2",
|
|
95
102
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
96
|
-
"commitizen": "^4.3.0",
|
|
97
103
|
"copy-webpack-plugin": "^11.0.0",
|
|
98
|
-
"cz-
|
|
104
|
+
"cz-git": "^1.12.0",
|
|
105
|
+
"czg": "^1.12.0",
|
|
99
106
|
"dotenv": "^16.3.1",
|
|
100
107
|
"husky": "^8.0.3",
|
|
101
|
-
"jest": "^
|
|
108
|
+
"jest": "^30.1.3",
|
|
102
109
|
"lodash.kebabcase": "^4.1.1",
|
|
103
110
|
"npm-run-all": "^4.1.5",
|
|
104
111
|
"plugin": "^0.0.15",
|
|
105
112
|
"resolve-tspaths": "^0.8.23",
|
|
106
113
|
"rimraf": "^6.0.1",
|
|
107
|
-
"semantic-release": "^
|
|
114
|
+
"semantic-release": "^25.0.1",
|
|
108
115
|
"semantic-release-github-pullrequest": "github:njausteve/semantic-release-github-pullrequest",
|
|
109
116
|
"semantic-release-unsquash": "^0.1.2",
|
|
110
|
-
"style-dictionary": "^
|
|
117
|
+
"style-dictionary": "^5.0.4",
|
|
111
118
|
"svg-sprite": "^2.0.2",
|
|
112
119
|
"tailwindcss": "^3.4.17",
|
|
113
120
|
"tinycolor2": "^1.6.0",
|
|
@@ -122,5 +129,6 @@
|
|
|
122
129
|
"publishConfig": {
|
|
123
130
|
"access": "public",
|
|
124
131
|
"registry": "https://registry.npmjs.org/"
|
|
125
|
-
}
|
|
132
|
+
},
|
|
133
|
+
"packageManager": "npm@11.5.1"
|
|
126
134
|
}
|
package/docs/token-validation.md
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# Design Token Validation with Zod
|
|
2
|
-
|
|
3
|
-
This document describes the **internal** token validation system implemented using Zod for runtime validation and TypeScript type inference. These utilities are used during the build process and are not exported to package consumers.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The Mindvalley Design System uses Supernova to manage design tokens. These tokens are automatically pushed to the repository in JSON format. To ensure type safety and catch issues early, we've implemented a validation system using Zod that:
|
|
8
|
-
|
|
9
|
-
- Validates token structure at build time
|
|
10
|
-
- Provides TypeScript types derived from the same schemas
|
|
11
|
-
- Offers clear error messages when tokens don't match expected structure
|
|
12
|
-
- Handles the complex, nested structures that Supernova generates
|
|
13
|
-
|
|
14
|
-
## Architecture
|
|
15
|
-
|
|
16
|
-
### Core Files
|
|
17
|
-
|
|
18
|
-
- `src/types/token-schemas.ts` - Zod schemas defining token structure
|
|
19
|
-
- `src/types/token-validation.ts` - Validation utilities and functions
|
|
20
|
-
- `src/types/index.d.ts` - TypeScript type exports
|
|
21
|
-
|
|
22
|
-
### Token Structure
|
|
23
|
-
|
|
24
|
-
Supernova generates tokens with varying levels of nesting:
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"color": {
|
|
29
|
-
"primary": {
|
|
30
|
-
"500": {
|
|
31
|
-
"value": "#ff0000ff",
|
|
32
|
-
"type": "color"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"black": {
|
|
36
|
-
"value": "#000000ff",
|
|
37
|
-
"type": "color"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## For Package Consumers
|
|
44
|
-
|
|
45
|
-
If you're using the `@mindvalley/design-system` npm package, the validation happens at build time and you receive:
|
|
46
|
-
|
|
47
|
-
- Type-safe `ColorTokens` interface for the colors object
|
|
48
|
-
- `TypographyToken` and `TypographySet` types from the Tailwind plugin
|
|
49
|
-
- Pre-validated, transformed tokens ready for use
|
|
50
|
-
|
|
51
|
-
The examples below are for **contributors and maintainers** working on the design system itself.
|
|
52
|
-
|
|
53
|
-
## Usage Guide (Internal Development)
|
|
54
|
-
|
|
55
|
-
### 1. Basic Validation
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { validateTokenFile } from './types/token-validation';
|
|
59
|
-
|
|
60
|
-
const result = validateTokenFile('src/tokens/brands/mindvalley/colors.json');
|
|
61
|
-
if (result.success) {
|
|
62
|
-
console.log('Tokens are valid!', result.data);
|
|
63
|
-
} else {
|
|
64
|
-
console.error('Validation failed:', result.errors);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 2. Type-Safe Token Access
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { ColorToken } from './types/token-schemas';
|
|
72
|
-
import { validateColorToken } from './types/token-validation';
|
|
73
|
-
|
|
74
|
-
// Runtime validation with automatic type inference
|
|
75
|
-
try {
|
|
76
|
-
const token: ColorToken = validateColorToken(unknownData);
|
|
77
|
-
// TypeScript knows token.value is a hex string
|
|
78
|
-
console.log(token.value);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error('Invalid color token:', error);
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 3. Batch Validation
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import { validateAllTokens, getValidationSummary } from './types/token-validation';
|
|
88
|
-
|
|
89
|
-
// Validate all tokens in the project
|
|
90
|
-
const summary = getValidationSummary('./src/tokens');
|
|
91
|
-
console.log(`Valid: ${summary.valid}, Invalid: ${summary.invalid}`);
|
|
92
|
-
|
|
93
|
-
if (summary.invalid > 0) {
|
|
94
|
-
summary.errors.forEach(error => {
|
|
95
|
-
console.error(`❌ ${error.file}:`, error.errors);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### 4. CI/CD Integration
|
|
101
|
-
|
|
102
|
-
Add to your `package.json`:
|
|
103
|
-
|
|
104
|
-
```json
|
|
105
|
-
{
|
|
106
|
-
"scripts": {
|
|
107
|
-
"validate-tokens": "ts-node src/scripts/validate-tokens.ts",
|
|
108
|
-
"prebuild": "npm run validate-tokens"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Create `src/scripts/validate-tokens.ts`:
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
import { getValidationSummary } from '../types/token-validation';
|
|
117
|
-
|
|
118
|
-
const summary = getValidationSummary('./src/tokens');
|
|
119
|
-
|
|
120
|
-
if (summary.invalid > 0) {
|
|
121
|
-
console.error('Token validation failed!');
|
|
122
|
-
summary.errors.forEach(error => {
|
|
123
|
-
console.error(`❌ ${error.file}:`, error.errors.join('\n '));
|
|
124
|
-
});
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
console.log('✅ All tokens validated successfully!');
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 5. Type Guards
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
import { isColorToken, isTypographyToken } from './types/token-validation';
|
|
135
|
-
|
|
136
|
-
function processToken(token: unknown) {
|
|
137
|
-
if (isColorToken(token)) {
|
|
138
|
-
// TypeScript knows this is a ColorToken
|
|
139
|
-
return createColorVariable(token.value);
|
|
140
|
-
} else if (isTypographyToken(token)) {
|
|
141
|
-
// TypeScript knows this is a TypographyToken
|
|
142
|
-
return createTypographyStyles(token.value);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### 6. Error Handling
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
import { safeValidate, ColorFileSchema, formatZodError } from './types/token-validation';
|
|
151
|
-
|
|
152
|
-
function handleSupernovaWebhook(payload: unknown) {
|
|
153
|
-
const result = safeValidate(ColorFileSchema, payload);
|
|
154
|
-
|
|
155
|
-
if (!result.success) {
|
|
156
|
-
const errors = formatZodError(result.errors);
|
|
157
|
-
|
|
158
|
-
// Log structured errors
|
|
159
|
-
console.error('Token validation failed:', {
|
|
160
|
-
errors,
|
|
161
|
-
timestamp: new Date().toISOString(),
|
|
162
|
-
source: 'supernova-webhook'
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Alert team
|
|
166
|
-
notifySlack({
|
|
167
|
-
channel: '#design-system',
|
|
168
|
-
message: `Token validation failed: ${errors.join(', ')}`
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Process valid tokens
|
|
175
|
-
updateTokens(result.data);
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Testing
|
|
180
|
-
|
|
181
|
-
### Unit Tests
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
import { ColorTokenSchema } from './types/token-schemas';
|
|
185
|
-
|
|
186
|
-
describe('Color Token Validation', () => {
|
|
187
|
-
it('should accept valid color tokens', () => {
|
|
188
|
-
const validToken = {
|
|
189
|
-
value: '#ff0000ff',
|
|
190
|
-
type: 'color'
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
expect(() => ColorTokenSchema.parse(validToken)).not.toThrow();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('should reject invalid hex values', () => {
|
|
197
|
-
const invalidToken = {
|
|
198
|
-
value: 'not-a-color',
|
|
199
|
-
type: 'color'
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
expect(() => ColorTokenSchema.parse(invalidToken)).toThrow();
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Integration Tests
|
|
208
|
-
|
|
209
|
-
```typescript
|
|
210
|
-
import { validateAllTokens } from './types/token-validation';
|
|
211
|
-
|
|
212
|
-
describe('Token File Validation', () => {
|
|
213
|
-
it('should validate all production tokens', () => {
|
|
214
|
-
const results = validateAllTokens('./src/tokens');
|
|
215
|
-
const failures = results.filter(r => !r.success);
|
|
216
|
-
|
|
217
|
-
expect(failures).toHaveLength(0);
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Schema Flexibility
|
|
223
|
-
|
|
224
|
-
The schemas are designed to handle Supernova's complex output:
|
|
225
|
-
|
|
226
|
-
- **Nested structures**: Tokens can be nested at varying levels
|
|
227
|
-
- **Optional properties**: Some tokens have optional fields like `comment`
|
|
228
|
-
- **Mixed structures**: Different brands may have slightly different structures
|
|
229
|
-
- **Type variations**: Properties like `textCase` can be strings or objects
|
|
230
|
-
|
|
231
|
-
## Extending the System
|
|
232
|
-
|
|
233
|
-
### Adding New Token Types
|
|
234
|
-
|
|
235
|
-
1. Add the schema in `token-schemas.ts`:
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
export const NewTokenSchema = z.object({
|
|
239
|
-
value: z.string(),
|
|
240
|
-
type: z.literal('newtype'),
|
|
241
|
-
metadata: z.object({
|
|
242
|
-
// Define metadata structure
|
|
243
|
-
}).optional()
|
|
244
|
-
});
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
2. Add to file schema mapping in `token-validation.ts`:
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
const FILE_SCHEMA_MAP = {
|
|
251
|
-
// existing mappings...
|
|
252
|
-
'newtokens.json': NewTokenFileSchema
|
|
253
|
-
};
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### Custom Validation Rules
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
const CustomColorSchema = ColorTokenSchema.refine(
|
|
260
|
-
(token) => token.value.length === 9, // RGBA with alpha
|
|
261
|
-
{ message: 'Colors must include alpha channel' }
|
|
262
|
-
);
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
## Troubleshooting
|
|
266
|
-
|
|
267
|
-
### Common Issues
|
|
268
|
-
|
|
269
|
-
1. **"Invalid input" errors**: Check if Supernova changed the token structure
|
|
270
|
-
2. **Missing properties**: Some tokens may have optional fields
|
|
271
|
-
3. **Type mismatches**: Use the flexible schemas that accept `z.any()` for complex nested structures
|
|
272
|
-
|
|
273
|
-
### Debugging
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
import { validateTokenFile, getErrorReport } from './types/token-validation';
|
|
277
|
-
|
|
278
|
-
const result = validateTokenFile('path/to/tokens.json');
|
|
279
|
-
if (!result.success) {
|
|
280
|
-
// Get detailed error report
|
|
281
|
-
console.log(getErrorReport(result.errors));
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Best Practices
|
|
286
|
-
|
|
287
|
-
1. **Run validation in CI/CD**: Catch issues before they reach production
|
|
288
|
-
2. **Validate after Supernova updates**: Add webhook handlers that validate incoming tokens
|
|
289
|
-
3. **Use type guards**: Leverage TypeScript's type narrowing with `isColorToken()` etc.
|
|
290
|
-
4. **Keep schemas updated**: When Supernova changes output format, update schemas accordingly
|
|
291
|
-
5. **Test with real data**: Always test schemas against actual token files
|
|
292
|
-
|
|
293
|
-
## Future Improvements
|
|
294
|
-
|
|
295
|
-
- Add schema versioning to handle Supernova format changes
|
|
296
|
-
- Create a CLI tool for token validation
|
|
297
|
-
- Add visual regression tests for token changes
|
|
298
|
-
- Implement token transformation pipelines with validation
|