@techv/design-system 0.1.3 → 0.1.4
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/README.md +138 -99
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tokens/dist/esm/index.js +187 -130
- package/dist/cjs/tokens/dist/esm/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/tokens/dist/esm/index.js +174 -131
- package/dist/esm/tokens/dist/esm/index.js.map +1 -1
- package/dist/styles.css +115 -52
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,7 +27,6 @@ pnpm add @techv/design-system styled-components
|
|
|
27
27
|
Import the global CSS in your app entry point. This loads the CSS custom properties (design tokens) and dark mode support.
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
|
-
// index.tsx or App.tsx
|
|
31
30
|
import '@techv/design-system/styles.css';
|
|
32
31
|
```
|
|
33
32
|
|
|
@@ -130,16 +129,54 @@ import { IconButton } from '@techv/design-system';
|
|
|
130
129
|
|
|
131
130
|
## Design Tokens
|
|
132
131
|
|
|
132
|
+
### Setup
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import '@techv/design-system/styles.css';
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Available exports
|
|
139
|
+
|
|
140
|
+
| Export | Purpose | Example |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `colors` | Full color palette | `colors.red[500]` → `'#EF4444'` |
|
|
143
|
+
| `bg` | Background colors (alias of colors) | `bg.indigo[50]` → `'#EEF2FF'` |
|
|
144
|
+
| `tx` | Text colors (alias of colors) | `tx.gray[700]` → `'#374151'` |
|
|
145
|
+
| `bd` | Border colors (alias of colors) | `bd.gray[200]` → `'#E5E7EB'` |
|
|
146
|
+
| `fl` | SVG fill colors (alias of colors) | `fl.green[400]` → `'#4ADE80'` |
|
|
147
|
+
| `spacing` | 4px-base numeric scale | `spacing[4]` → `'16px'` |
|
|
148
|
+
| `fs` | Font sizes | `fs.sm` → `'14px'` |
|
|
149
|
+
| `fw` | Font weights | `fw[7]` → `'700'` |
|
|
150
|
+
| `lh` | Line heights | `lh.base` → `1.5` |
|
|
151
|
+
| `ta` | Text alignment | `ta.c` → `'center'` |
|
|
152
|
+
| `br` | Border radius | `br.full` → `'9999px'` |
|
|
153
|
+
| `bw` | Border widths | `bw[1]` → `'1px'` |
|
|
154
|
+
| `sh` | Shadows | `sh[3]` → md elevation |
|
|
155
|
+
| `op` | Opacity | `op[50]` → `'0.5'` |
|
|
156
|
+
| `duration` | Animation durations | `duration.normal` → `'200ms'` |
|
|
157
|
+
| `ease` | Easing curves | `ease.standard` |
|
|
158
|
+
|
|
133
159
|
### CSS Custom Properties
|
|
134
160
|
|
|
135
|
-
|
|
161
|
+
All tokens are also available as CSS variables:
|
|
136
162
|
|
|
137
163
|
```css
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
164
|
+
/* Colors */
|
|
165
|
+
background-color: var(--indigo-500);
|
|
166
|
+
color: var(--gray-700);
|
|
167
|
+
border-color: var(--red-200);
|
|
168
|
+
|
|
169
|
+
/* Spacing */
|
|
170
|
+
padding: var(--spacing-4); /* 16px */
|
|
171
|
+
gap: var(--spacing-2); /* 8px */
|
|
172
|
+
|
|
173
|
+
/* Typography */
|
|
174
|
+
font-size: var(--fs-lg); /* 18px */
|
|
175
|
+
font-weight: var(--fw-6); /* 600 */
|
|
176
|
+
|
|
177
|
+
/* Border radius / shadow */
|
|
178
|
+
border-radius: var(--br-lg); /* 8px */
|
|
179
|
+
box-shadow: var(--sh-3);
|
|
143
180
|
```
|
|
144
181
|
|
|
145
182
|
### JavaScript Tokens
|
|
@@ -149,18 +186,18 @@ Import `styles.css` to get all tokens as CSS variables on `:root`, usable anywhe
|
|
|
149
186
|
Use tokens directly in React `style` props:
|
|
150
187
|
|
|
151
188
|
```tsx
|
|
152
|
-
import {
|
|
189
|
+
import { bg, tx, spacing, br, fs, fw } from '@techv/design-system';
|
|
153
190
|
|
|
154
191
|
function Badge({ children }: { children: React.ReactNode }) {
|
|
155
192
|
return (
|
|
156
193
|
<span
|
|
157
194
|
style={{
|
|
158
|
-
backgroundColor:
|
|
159
|
-
color:
|
|
160
|
-
padding:
|
|
161
|
-
borderRadius:
|
|
162
|
-
fontSize:
|
|
163
|
-
|
|
195
|
+
backgroundColor: bg.indigo[50],
|
|
196
|
+
color: tx.indigo[700],
|
|
197
|
+
padding: `${spacing[1]} ${spacing[2]}`,
|
|
198
|
+
borderRadius: br.full,
|
|
199
|
+
fontSize: fs.xs,
|
|
200
|
+
fontWeight: fw[5],
|
|
164
201
|
}}
|
|
165
202
|
>
|
|
166
203
|
{children}
|
|
@@ -172,26 +209,14 @@ function Badge({ children }: { children: React.ReactNode }) {
|
|
|
172
209
|
#### Alert / status banner
|
|
173
210
|
|
|
174
211
|
```tsx
|
|
175
|
-
import {
|
|
212
|
+
import { bg, tx, bd, spacing, br, fs, bw } from '@techv/design-system';
|
|
176
213
|
|
|
177
214
|
type AlertType = 'success' | 'danger' | 'warning';
|
|
178
215
|
|
|
179
|
-
const
|
|
180
|
-
success: {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
border: `1px solid ${tokens.color.success[500]}`,
|
|
184
|
-
},
|
|
185
|
-
danger: {
|
|
186
|
-
backgroundColor: tokens.color.danger[50], // '#FEF2F2'
|
|
187
|
-
color: tokens.color.danger[500], // '#EF4444'
|
|
188
|
-
border: `1px solid ${tokens.color.danger[500]}`,
|
|
189
|
-
},
|
|
190
|
-
warning: {
|
|
191
|
-
backgroundColor: tokens.color.warning[50], // '#FFFBEB'
|
|
192
|
-
color: tokens.color.warning[500], // '#F59E0B'
|
|
193
|
-
border: `1px solid ${tokens.color.warning[500]}`,
|
|
194
|
-
},
|
|
216
|
+
const alertMap: Record<AlertType, React.CSSProperties> = {
|
|
217
|
+
success: { backgroundColor: bg.green[50], color: tx.green[700], border: `${bw[1]} solid ${bd.green[300]}` },
|
|
218
|
+
danger: { backgroundColor: bg.red[50], color: tx.red[700], border: `${bw[1]} solid ${bd.red[300]}` },
|
|
219
|
+
warning: { backgroundColor: bg.amber[50], color: tx.amber[700], border: `${bw[1]} solid ${bd.amber[300]}` },
|
|
195
220
|
};
|
|
196
221
|
|
|
197
222
|
function Alert({ type, message }: { type: AlertType; message: string }) {
|
|
@@ -199,10 +224,10 @@ function Alert({ type, message }: { type: AlertType; message: string }) {
|
|
|
199
224
|
<div
|
|
200
225
|
role="alert"
|
|
201
226
|
style={{
|
|
202
|
-
...
|
|
203
|
-
padding:
|
|
204
|
-
borderRadius:
|
|
205
|
-
fontSize:
|
|
227
|
+
...alertMap[type],
|
|
228
|
+
padding: `${spacing[2]} ${spacing[4]}`,
|
|
229
|
+
borderRadius: br.md,
|
|
230
|
+
fontSize: fs.sm,
|
|
206
231
|
}}
|
|
207
232
|
>
|
|
208
233
|
{message}
|
|
@@ -210,44 +235,44 @@ function Alert({ type, message }: { type: AlertType; message: string }) {
|
|
|
210
235
|
);
|
|
211
236
|
}
|
|
212
237
|
|
|
213
|
-
// Usage
|
|
214
238
|
<Alert type="success" message="Profile saved!" />
|
|
215
|
-
<Alert type="danger"
|
|
239
|
+
<Alert type="danger" message="Something went wrong." />
|
|
216
240
|
<Alert type="warning" message="Your session expires soon." />
|
|
217
241
|
```
|
|
218
242
|
|
|
219
243
|
#### Card component
|
|
220
244
|
|
|
221
245
|
```tsx
|
|
222
|
-
import {
|
|
246
|
+
import { bg, tx, bd, spacing, br, sh, fs, fw, bw } from '@techv/design-system';
|
|
223
247
|
|
|
224
248
|
function Card({ title, body }: { title: string; body: string }) {
|
|
225
249
|
return (
|
|
226
250
|
<div
|
|
227
251
|
style={{
|
|
228
|
-
backgroundColor:
|
|
229
|
-
border:
|
|
230
|
-
borderRadius:
|
|
231
|
-
padding:
|
|
232
|
-
boxShadow:
|
|
233
|
-
maxWidth:
|
|
252
|
+
backgroundColor: bg.white,
|
|
253
|
+
border: `${bw[1]} solid ${bd.gray[200]}`,
|
|
254
|
+
borderRadius: br['2xl'],
|
|
255
|
+
padding: spacing[8],
|
|
256
|
+
boxShadow: sh[3],
|
|
257
|
+
maxWidth: '400px',
|
|
234
258
|
}}
|
|
235
259
|
>
|
|
236
260
|
<h2
|
|
237
261
|
style={{
|
|
238
|
-
margin:
|
|
239
|
-
fontSize:
|
|
240
|
-
|
|
241
|
-
|
|
262
|
+
margin: 0,
|
|
263
|
+
fontSize: fs.lg,
|
|
264
|
+
fontWeight: fw[6],
|
|
265
|
+
color: tx.gray[900],
|
|
266
|
+
marginBottom: spacing[2],
|
|
242
267
|
}}
|
|
243
268
|
>
|
|
244
269
|
{title}
|
|
245
270
|
</h2>
|
|
246
271
|
<p
|
|
247
272
|
style={{
|
|
248
|
-
margin:
|
|
249
|
-
fontSize:
|
|
250
|
-
color:
|
|
273
|
+
margin: 0,
|
|
274
|
+
fontSize: fs.sm,
|
|
275
|
+
color: tx.gray[500],
|
|
251
276
|
lineHeight: 1.6,
|
|
252
277
|
}}
|
|
253
278
|
>
|
|
@@ -258,20 +283,22 @@ function Card({ title, body }: { title: string; body: string }) {
|
|
|
258
283
|
}
|
|
259
284
|
```
|
|
260
285
|
|
|
261
|
-
####
|
|
286
|
+
#### Tag
|
|
262
287
|
|
|
263
288
|
```tsx
|
|
264
|
-
import {
|
|
289
|
+
import { bg, tx, bd, spacing, br, fs, fw, bw } from '@techv/design-system';
|
|
265
290
|
|
|
266
291
|
function Tag({ label }: { label: string }) {
|
|
267
292
|
return (
|
|
268
293
|
<span
|
|
269
294
|
style={{
|
|
270
|
-
backgroundColor:
|
|
271
|
-
color:
|
|
272
|
-
padding:
|
|
273
|
-
borderRadius:
|
|
274
|
-
border:
|
|
295
|
+
backgroundColor: bg.gray[100],
|
|
296
|
+
color: tx.gray[700],
|
|
297
|
+
padding: `${spacing[1]} ${spacing[2]}`,
|
|
298
|
+
borderRadius: br.md,
|
|
299
|
+
border: `${bw[1]} solid ${bd.gray[200]}`,
|
|
300
|
+
fontSize: fs.xs,
|
|
301
|
+
fontWeight: fw[5],
|
|
275
302
|
}}
|
|
276
303
|
>
|
|
277
304
|
{label}
|
|
@@ -280,20 +307,19 @@ function Tag({ label }: { label: string }) {
|
|
|
280
307
|
}
|
|
281
308
|
```
|
|
282
309
|
|
|
283
|
-
#### Animated element
|
|
310
|
+
#### Animated element
|
|
284
311
|
|
|
285
312
|
```tsx
|
|
286
|
-
import {
|
|
313
|
+
import { bg, br, spacing, duration, ease } from '@techv/design-system';
|
|
287
314
|
|
|
288
315
|
function FadeInBox({ children }: { children: React.ReactNode }) {
|
|
289
316
|
return (
|
|
290
317
|
<div
|
|
291
318
|
style={{
|
|
292
|
-
padding:
|
|
293
|
-
backgroundColor:
|
|
294
|
-
borderRadius:
|
|
295
|
-
transition:
|
|
296
|
-
// 200ms cubic-bezier(0.4, 0, 0.2, 1)
|
|
319
|
+
padding: spacing[6],
|
|
320
|
+
backgroundColor: bg.indigo[50],
|
|
321
|
+
borderRadius: br.xl,
|
|
322
|
+
transition: `opacity ${duration.normal} ${ease.standard}`,
|
|
297
323
|
}}
|
|
298
324
|
>
|
|
299
325
|
{children}
|
|
@@ -305,32 +331,36 @@ function FadeInBox({ children }: { children: React.ReactNode }) {
|
|
|
305
331
|
#### Quick reference
|
|
306
332
|
|
|
307
333
|
```tsx
|
|
308
|
-
import {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
+
import { bg, tx, bd, fl, spacing, fs, fw, lh, ta, br, bw, sh, op, duration, ease } from '@techv/design-system';
|
|
335
|
+
|
|
336
|
+
bg.indigo[50]
|
|
337
|
+
tx.gray[700]
|
|
338
|
+
bd.gray[200]
|
|
339
|
+
fl.green[400]
|
|
340
|
+
bg.red[500]
|
|
341
|
+
bg.white
|
|
342
|
+
bg.black
|
|
343
|
+
|
|
344
|
+
spacing[1]
|
|
345
|
+
spacing[2]
|
|
346
|
+
spacing[4]
|
|
347
|
+
spacing[6]
|
|
348
|
+
spacing[8]
|
|
349
|
+
spacing.full
|
|
350
|
+
|
|
351
|
+
fs.xs
|
|
352
|
+
fs.lg
|
|
353
|
+
fw[4]
|
|
354
|
+
lh.tight
|
|
355
|
+
ta.c
|
|
356
|
+
|
|
357
|
+
br.sm
|
|
358
|
+
bw[1]
|
|
359
|
+
sh[1]
|
|
360
|
+
op[50]
|
|
361
|
+
|
|
362
|
+
duration.fast
|
|
363
|
+
ease.standard
|
|
334
364
|
```
|
|
335
365
|
|
|
336
366
|
### Token Reference
|
|
@@ -379,10 +409,8 @@ radii.full // '9999px'
|
|
|
379
409
|
The library ships with a built-in dark mode. Toggle it by setting `data-theme="dark"` on any ancestor element (typically `<html>` or `<body>`).
|
|
380
410
|
|
|
381
411
|
```tsx
|
|
382
|
-
// Enable dark mode
|
|
383
412
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
384
413
|
|
|
385
|
-
// Disable dark mode
|
|
386
414
|
document.documentElement.removeAttribute('data-theme');
|
|
387
415
|
```
|
|
388
416
|
|
|
@@ -404,13 +432,24 @@ import type { ButtonProps, IconButtonProps } from '@techv/design-system';
|
|
|
404
432
|
|
|
405
433
|
```tsx
|
|
406
434
|
import styled from 'styled-components';
|
|
407
|
-
import {
|
|
435
|
+
import { bg, bd, tx, spacing, br, sh, fs, fw, bw } from '@techv/design-system';
|
|
408
436
|
|
|
409
437
|
const Card = styled.div`
|
|
410
|
-
background:
|
|
411
|
-
border:
|
|
412
|
-
border-radius: ${
|
|
413
|
-
padding:
|
|
414
|
-
box-shadow:
|
|
438
|
+
background: ${bg.white};
|
|
439
|
+
border: ${bw[1]} solid ${bd.gray[200]};
|
|
440
|
+
border-radius: ${br['2xl']};
|
|
441
|
+
padding: ${spacing[8]};
|
|
442
|
+
box-shadow: ${sh[3]};
|
|
443
|
+
`;
|
|
444
|
+
|
|
445
|
+
const Heading = styled.h2`
|
|
446
|
+
font-size: ${fs.lg};
|
|
447
|
+
font-weight: ${fw[6]};
|
|
448
|
+
color: ${tx.gray[900]};
|
|
449
|
+
`;
|
|
450
|
+
|
|
451
|
+
const Body = styled.p`
|
|
452
|
+
font-size: ${fs.sm};
|
|
453
|
+
color: ${tx.gray[500]};
|
|
415
454
|
`;
|
|
416
455
|
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,10 +5,24 @@ var Button = require('./ui/dist/esm/components/Button/Button.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
exports.bd = index.bd;
|
|
9
|
+
exports.bg = index.bg;
|
|
10
|
+
exports.br = index.br;
|
|
11
|
+
exports.bw = index.bw;
|
|
8
12
|
exports.colors = index.colors;
|
|
13
|
+
exports.duration = index.duration;
|
|
14
|
+
exports.ease = index.ease;
|
|
15
|
+
exports.fl = index.fl;
|
|
16
|
+
exports.fs = index.fs;
|
|
17
|
+
exports.fw = index.fw;
|
|
18
|
+
exports.lh = index.lh;
|
|
19
|
+
exports.op = index.op;
|
|
9
20
|
exports.radii = index.radii;
|
|
21
|
+
exports.sh = index.sh;
|
|
10
22
|
exports.spacing = index.spacing;
|
|
23
|
+
exports.ta = index.ta;
|
|
11
24
|
exports.tokens = index.tokens;
|
|
25
|
+
exports.tx = index.tx;
|
|
12
26
|
exports.Button = Button.Button;
|
|
13
27
|
exports.IconButton = Button.IconButton;
|
|
14
28
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|