@stachelock/ui 0.1.9 → 0.2.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/CUSTOMIZATION.md +325 -0
- package/dist/index.js +391 -188
- package/dist/index.js.map +1 -1
- package/dist/src/config/css-variables.d.ts +5 -0
- package/dist/src/config/css-variables.d.ts.map +1 -0
- package/dist/src/config/design-tokens.d.ts +52 -0
- package/dist/src/config/design-tokens.d.ts.map +1 -0
- package/dist/src/config/index.d.ts +3 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugin/configure.d.ts +28 -0
- package/dist/src/plugin/configure.d.ts.map +1 -0
- package/dist/src/plugin/index.d.ts +2 -0
- package/dist/src/plugin/index.d.ts.map +1 -0
- package/examples/custom-tokens.json +70 -0
- package/package.json +11 -3
- package/scripts/build-css.cjs +29 -0
- package/scripts/generate-config.cjs +83 -0
- package/scripts/generateRecursiveIndex.cjs +255 -0
package/CUSTOMIZATION.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Customizing Stachelock UI Design Tokens
|
|
2
|
+
|
|
3
|
+
Stachelock UI now supports customizing design tokens (colors, spacing, typography, etc.) to match your project's design system while maintaining the `sl-` prefixed utility classes.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The customization system allows you to:
|
|
8
|
+
- Override default colors, spacing, shadows, and typography
|
|
9
|
+
- Generate custom CSS variables and Tailwind configurations
|
|
10
|
+
- Maintain the `sl-` prefix to avoid conflicts with your existing styles
|
|
11
|
+
- Use both programmatic configuration and build-time generation
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### 1. Create a Custom Tokens File
|
|
16
|
+
|
|
17
|
+
Create a JSON file (e.g., `my-tokens.json`) with your custom design tokens:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"colors": {
|
|
22
|
+
"primary": {
|
|
23
|
+
"50": "#f0f9ff",
|
|
24
|
+
"100": "#e0f2fe",
|
|
25
|
+
"500": "#0ea5e9",
|
|
26
|
+
"600": "#0284c7",
|
|
27
|
+
"700": "#0369a1"
|
|
28
|
+
},
|
|
29
|
+
"stachelock": {
|
|
30
|
+
"600": "#dc2626",
|
|
31
|
+
"700": "#b91c1c"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"spacing": {
|
|
35
|
+
"18": "4.5rem",
|
|
36
|
+
"22": "5.5rem"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Generate Custom Configuration
|
|
42
|
+
|
|
43
|
+
Use the CLI tool to generate custom CSS variables and Tailwind config:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# From your project directory
|
|
47
|
+
npx @stachelock/ui generate-config ./my-tokens.json ./generated/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This will create:
|
|
51
|
+
- `stachelock-ui-variables.css` - CSS custom properties
|
|
52
|
+
- `stachelock-ui-tailwind.config.js` - Tailwind configuration
|
|
53
|
+
- `stachelock-ui-tokens.json` - Merged tokens for reference
|
|
54
|
+
|
|
55
|
+
### 3. Import and Use
|
|
56
|
+
|
|
57
|
+
In your main CSS file:
|
|
58
|
+
```css
|
|
59
|
+
@import "./generated/stachelock-ui-variables.css";
|
|
60
|
+
@import "@stachelock/ui/style.css";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
In your `tailwind.config.js`:
|
|
64
|
+
```javascript
|
|
65
|
+
const stachelockConfig = require('./generated/stachelock-ui-tailwind.config.js');
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
content: ["./src/**/*.{vue,js,ts,jsx,tsx}"],
|
|
69
|
+
theme: {
|
|
70
|
+
extend: {
|
|
71
|
+
...stachelockConfig.theme.extend
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Programmatic Configuration
|
|
78
|
+
|
|
79
|
+
### Using the Vue Plugin
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { createApp } from 'vue';
|
|
83
|
+
import { StachelockUI } from '@stachelock/ui';
|
|
84
|
+
import App from './App.vue';
|
|
85
|
+
|
|
86
|
+
const app = createApp(App);
|
|
87
|
+
|
|
88
|
+
app.use(StachelockUI, {
|
|
89
|
+
designTokens: {
|
|
90
|
+
colors: {
|
|
91
|
+
primary: {
|
|
92
|
+
600: '#0ea5e9',
|
|
93
|
+
700: '#0369a1'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
app.mount('#app');
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Advanced Plugin Usage
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { StachelockUI } from '@stachelock/ui';
|
|
106
|
+
|
|
107
|
+
// Configure after installation
|
|
108
|
+
StachelockUI.configure({
|
|
109
|
+
designTokens: {
|
|
110
|
+
colors: {
|
|
111
|
+
brand: {
|
|
112
|
+
500: '#ff6b6b',
|
|
113
|
+
600: '#ee5a52'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
prefix: 'sl-', // Keep default prefix
|
|
118
|
+
injectCSS: true // Automatically inject CSS variables
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Get current design tokens
|
|
122
|
+
const tokens = StachelockUI.getDesignTokens();
|
|
123
|
+
|
|
124
|
+
// Generate custom CSS
|
|
125
|
+
const css = StachelockUI.generateCSS();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Design Token Structure
|
|
129
|
+
|
|
130
|
+
### Colors
|
|
131
|
+
```typescript
|
|
132
|
+
colors: {
|
|
133
|
+
primary: {
|
|
134
|
+
50: '#f0f9ff', // Lightest
|
|
135
|
+
100: '#e0f2fe',
|
|
136
|
+
200: '#bae6fd',
|
|
137
|
+
300: '#7dd3fc',
|
|
138
|
+
400: '#38bdf8',
|
|
139
|
+
500: '#0ea5e9', // Base
|
|
140
|
+
600: '#0284c7',
|
|
141
|
+
700: '#0369a1',
|
|
142
|
+
800: '#075985',
|
|
143
|
+
900: '#0c4a6e' // Darkest
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Spacing
|
|
149
|
+
```typescript
|
|
150
|
+
spacing: {
|
|
151
|
+
'0': '0',
|
|
152
|
+
'1': '0.25rem',
|
|
153
|
+
'2': '0.5rem',
|
|
154
|
+
'4': '1rem',
|
|
155
|
+
'8': '2rem',
|
|
156
|
+
'16': '4rem',
|
|
157
|
+
'32': '8rem',
|
|
158
|
+
'64': '16rem'
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Border Radius
|
|
163
|
+
```typescript
|
|
164
|
+
borderRadius: {
|
|
165
|
+
'none': '0',
|
|
166
|
+
'sm': '0.125rem',
|
|
167
|
+
'DEFAULT': '0.25rem',
|
|
168
|
+
'md': '0.375rem',
|
|
169
|
+
'lg': '0.5rem',
|
|
170
|
+
'xl': '0.75rem',
|
|
171
|
+
'2xl': '1rem',
|
|
172
|
+
'full': '9999px'
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Shadows
|
|
177
|
+
```typescript
|
|
178
|
+
shadows: {
|
|
179
|
+
'sm': '0 1px 2px 0 rgb(0 0 0 / 0.05)',
|
|
180
|
+
'DEFAULT': '0 1px 3px 0 rgb(0 0 0 / 0.1)',
|
|
181
|
+
'md': '0 4px 6px -1px rgb(0 0 0 / 0.1)',
|
|
182
|
+
'lg': '0 10px 15px -3px rgb(0 0 0 / 0.1)',
|
|
183
|
+
'xl': '0 20px 25px -5px rgb(0 0 0 / 0.1)'
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Typography
|
|
188
|
+
```typescript
|
|
189
|
+
typography: {
|
|
190
|
+
fontFamily: {
|
|
191
|
+
sans: ['Inter', 'ui-sans-serif', 'system-ui', 'sans-serif'],
|
|
192
|
+
display: ['Poppins', 'ui-sans-serif', 'system-ui', 'sans-serif'],
|
|
193
|
+
mono: ['JetBrains Mono', 'ui-monospace', 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', 'monospace']
|
|
194
|
+
},
|
|
195
|
+
fontSize: {
|
|
196
|
+
'xs': '0.75rem',
|
|
197
|
+
'sm': '0.875rem',
|
|
198
|
+
'base': '1rem',
|
|
199
|
+
'lg': '1.125rem',
|
|
200
|
+
'xl': '1.25rem',
|
|
201
|
+
'2xl': '1.5rem',
|
|
202
|
+
'3xl': '1.875rem',
|
|
203
|
+
'4xl': '2.25rem'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Breakpoints
|
|
209
|
+
```typescript
|
|
210
|
+
breakpoints: {
|
|
211
|
+
'sm': '640px',
|
|
212
|
+
'md': '768px',
|
|
213
|
+
'lg': '1024px',
|
|
214
|
+
'xl': '1280px',
|
|
215
|
+
'2xl': '1536px',
|
|
216
|
+
'3xl': '1600px'
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Generated CSS Variables
|
|
221
|
+
|
|
222
|
+
The system generates CSS custom properties that you can use in your own CSS:
|
|
223
|
+
|
|
224
|
+
```css
|
|
225
|
+
:root {
|
|
226
|
+
--sl-color-primary-50: #f0f9ff;
|
|
227
|
+
--sl-color-primary-100: #e0f2fe;
|
|
228
|
+
--sl-color-primary-500: #0ea5e9;
|
|
229
|
+
--sl-color-primary-600: #0284c7;
|
|
230
|
+
--sl-color-primary-700: #0369a1;
|
|
231
|
+
|
|
232
|
+
--sl-spacing-18: 4.5rem;
|
|
233
|
+
--sl-spacing-22: 5.5rem;
|
|
234
|
+
|
|
235
|
+
--sl-border-radius-2xl: 1rem;
|
|
236
|
+
--sl-border-radius-3xl: 1.5rem;
|
|
237
|
+
|
|
238
|
+
--sl-shadow-glow: 0 0 20px rgba(59, 130, 246, 0.5);
|
|
239
|
+
--sl-shadow-glow-lg: 0 0 40px rgba(59, 130, 246, 0.3);
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Using Custom Tokens in Components
|
|
244
|
+
|
|
245
|
+
### In Vue Templates
|
|
246
|
+
```vue
|
|
247
|
+
<template>
|
|
248
|
+
<div class="sl-bg-primary-500 sl-text-white sl-p-18 sl-rounded-2xl sl-shadow-glow">
|
|
249
|
+
Custom styled content
|
|
250
|
+
</div>
|
|
251
|
+
</template>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### In CSS
|
|
255
|
+
```css
|
|
256
|
+
.my-custom-component {
|
|
257
|
+
background-color: var(--sl-color-primary-500);
|
|
258
|
+
padding: var(--sl-spacing-18);
|
|
259
|
+
border-radius: var(--sl-border-radius-2xl);
|
|
260
|
+
box-shadow: var(--sl-shadow-glow);
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Migration from Previous Versions
|
|
265
|
+
|
|
266
|
+
If you're upgrading from a previous version:
|
|
267
|
+
|
|
268
|
+
1. **No breaking changes** - existing `sl-` classes continue to work
|
|
269
|
+
2. **New customization options** - you can now override design tokens
|
|
270
|
+
3. **Backward compatibility** - all existing functionality is preserved
|
|
271
|
+
|
|
272
|
+
## Best Practices
|
|
273
|
+
|
|
274
|
+
### 1. Token Naming
|
|
275
|
+
- Use semantic names (e.g., `primary`, `secondary`, `accent`)
|
|
276
|
+
- Follow the 50-900 scale for colors
|
|
277
|
+
- Use consistent naming across your design system
|
|
278
|
+
|
|
279
|
+
### 2. Color Selection
|
|
280
|
+
- Ensure sufficient contrast for accessibility
|
|
281
|
+
- Test colors in both light and dark modes
|
|
282
|
+
- Consider using tools like [Coolors](https://coolors.co/) for color generation
|
|
283
|
+
|
|
284
|
+
### 3. Spacing Scale
|
|
285
|
+
- Use consistent spacing increments
|
|
286
|
+
- Consider your design system's needs
|
|
287
|
+
- Common scales: 4px (0.25rem), 8px (0.5rem), 16px (1rem)
|
|
288
|
+
|
|
289
|
+
### 4. Typography
|
|
290
|
+
- Choose fonts that complement your brand
|
|
291
|
+
- Ensure good readability across devices
|
|
292
|
+
- Consider loading performance for custom fonts
|
|
293
|
+
|
|
294
|
+
## Troubleshooting
|
|
295
|
+
|
|
296
|
+
### Common Issues
|
|
297
|
+
|
|
298
|
+
**CSS variables not loading**
|
|
299
|
+
- Check that the CSS file is imported before other styles
|
|
300
|
+
- Verify the file path is correct
|
|
301
|
+
- Ensure the build process completed successfully
|
|
302
|
+
|
|
303
|
+
**Tailwind classes not working**
|
|
304
|
+
- Verify the Tailwind config is properly merged
|
|
305
|
+
- Check that content paths include your components
|
|
306
|
+
- Ensure the prefix is set to `sl-`
|
|
307
|
+
|
|
308
|
+
**Build errors**
|
|
309
|
+
- Check that all required dependencies are installed
|
|
310
|
+
- Verify the JSON syntax in your tokens file
|
|
311
|
+
- Ensure the output directory is writable
|
|
312
|
+
|
|
313
|
+
### Getting Help
|
|
314
|
+
|
|
315
|
+
- Check the [main README](../README.md) for general usage
|
|
316
|
+
- Review the [examples](../examples/) directory for sample configurations
|
|
317
|
+
- Open an issue on GitHub for bugs or feature requests
|
|
318
|
+
|
|
319
|
+
## Examples
|
|
320
|
+
|
|
321
|
+
See the [examples](../examples/) directory for complete working examples:
|
|
322
|
+
|
|
323
|
+
- `custom-tokens.json` - Sample token configuration
|
|
324
|
+
- `vue-app/` - Complete Vue application with custom tokens
|
|
325
|
+
- `react-app/` - Complete React application with custom tokens
|