@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 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
- Import `styles.css` to get all tokens as CSS variables on `:root`, usable anywhere in your app.
161
+ All tokens are also available as CSS variables:
136
162
 
137
163
  ```css
138
- .my-component {
139
- background-color: var(--color-brand-500);
140
- padding: var(--space-md);
141
- border-radius: var(--radius-lg);
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 { tokens, colors, spacing, radii } from '@techv/design-system';
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: tokens.color.brand[50], // '#EEF2FF'
159
- color: tokens.color.brand[700], // '#3730A3'
160
- padding: `${tokens.space.xs}px ${tokens.space.sm}px`, // '4px 8px'
161
- borderRadius: tokens.radius.full, // 9999
162
- fontSize: tokens.fontSize.caption, // '12px'
163
- fontFamily: tokens.font.text, // 'Inter'
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 { tokens, colors } from '@techv/design-system';
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 alertStyles: Record<AlertType, React.CSSProperties> = {
180
- success: {
181
- backgroundColor: tokens.color.success[50], // '#ECFDF5'
182
- color: tokens.color.success[500], // '#10B981'
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
- ...alertStyles[type],
203
- padding: `${tokens.space.sm}px ${tokens.space.md}px`, // '8px 16px'
204
- borderRadius: tokens.radius.md, // 6
205
- fontSize: tokens.fontSize.bodyMd, // '14px'
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" message="Something went wrong." />
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 { tokens } from '@techv/design-system';
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: tokens.semantic.surface, // '#FFFFFF'
229
- border: `1px solid ${tokens.semantic.border}`, // '#E5E7EB'
230
- borderRadius: tokens.radius['2xl'], // 16
231
- padding: tokens.space.xl, // 32
232
- boxShadow: tokens.shadow.md,
233
- maxWidth: '400px',
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: 0,
239
- fontSize: tokens.fontSize.h4, // '18px'
240
- color: tokens.semantic.textPrimary, // '#111827'
241
- marginBottom: tokens.space.sm, // 8
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: 0,
249
- fontSize: tokens.fontSize.bodyMd, // '14px'
250
- color: tokens.semantic.textSecondary, // '#6B7280'
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
- #### Using flat `colors` / `spacing` / `radii` exports
286
+ #### Tag
262
287
 
263
288
  ```tsx
264
- import { colors, spacing, radii } from '@techv/design-system';
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: colors.gray100, // '#F3F4F6'
271
- color: colors.gray700, // '#374151'
272
- padding: `${spacing.xs} ${spacing.sm}`, // '4px 8px'
273
- borderRadius: radii.sm, // '4px'
274
- border: `1px solid ${colors.border}`, // '#E5E7EB'
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 using duration + easing tokens
310
+ #### Animated element
284
311
 
285
312
  ```tsx
286
- import { tokens } from '@techv/design-system';
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: tokens.space.lg, // 24
293
- backgroundColor: tokens.color.brand[50],
294
- borderRadius: tokens.radius.xl, // 12
295
- transition: `opacity ${tokens.duration.normal}ms ${tokens.ease.standard}`,
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 { tokens, colors, spacing, radii } from '@techv/design-system';
309
-
310
- // tokens — full structured object
311
- tokens.color.brand[500] // '#4F46E5'
312
- tokens.color.gray[200] // '#E5E7EB'
313
- tokens.space.md // 16 (number, use as px)
314
- tokens.radius.lg // 8 (number, use as px)
315
- tokens.shadow.md // '0 4px 6px rgba(0,0,0,0.07)...'
316
- tokens.duration.normal // 200 (number, ms)
317
- tokens.ease.standard // 'cubic-bezier(0.4, 0, 0.2, 1)'
318
- tokens.font.text // 'Inter'
319
- tokens.fontSize.h1 // '36px'
320
- tokens.semantic.textPrimary // '#111827'
321
-
322
- // colors — flat convenience object
323
- colors.brand500 // '#4F46E5'
324
- colors.textPrimary // '#111827'
325
- colors.border // '#E5E7EB'
326
-
327
- // spacing — string values ready for CSS
328
- spacing.md // '16px'
329
- spacing.lg // '24px'
330
-
331
- // radii — string values ready for CSS
332
- radii.sm // '4px'
333
- radii.full // '9999px'
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 { tokens } from '@techv/design-system';
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: ${tokens.semantic.surface};
411
- border: 1px solid ${tokens.semantic.border};
412
- border-radius: ${tokens.radius.xl}px;
413
- padding: ${tokens.space.lg}px;
414
- box-shadow: ${tokens.shadow.md};
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}