@techv/design-system 0.1.3 → 0.1.5

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,10 +27,15 @@ 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
 
33
+ To use utility classes (className-based styling), also import:
34
+
35
+ ```tsx
36
+ import '@techv/design-system/utility.css';
37
+ ```
38
+
34
39
  ---
35
40
 
36
41
  ## Components
@@ -128,249 +133,253 @@ import { IconButton } from '@techv/design-system';
128
133
 
129
134
  ---
130
135
 
131
- ## Design Tokens
132
-
133
- ### CSS Custom Properties
134
-
135
- Import `styles.css` to get all tokens as CSS variables on `:root`, usable anywhere in your app.
136
-
137
- ```css
138
- .my-component {
139
- background-color: var(--color-brand-500);
140
- padding: var(--space-md);
141
- border-radius: var(--radius-lg);
142
- }
143
- ```
136
+ ## Utility Classes
144
137
 
145
- ### JavaScript Tokens
138
+ Import `@techv/design-system/utility.css` to use className-based styling. Classes map directly to design tokens.
146
139
 
147
- #### Inline styles
148
-
149
- Use tokens directly in React `style` props:
140
+ ### Badge
150
141
 
151
142
  ```tsx
152
- import { tokens, colors, spacing, radii } from '@techv/design-system';
153
-
154
- function Badge({ children }: { children: React.ReactNode }) {
155
- return (
156
- <span
157
- 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'
164
- }}
165
- >
166
- {children}
167
- </span>
168
- );
169
- }
143
+ <span className="bg-indigo-50 tx-indigo-700 px-2 py-1 br-full fs-xs fw-5">
144
+ New
145
+ </span>
170
146
  ```
171
147
 
172
- #### Alert / status banner
148
+ ### Alert / status banner
173
149
 
174
150
  ```tsx
175
- import { tokens, colors } from '@techv/design-system';
176
-
177
- type AlertType = 'success' | 'danger' | 'warning';
178
-
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
- },
195
- };
196
-
197
- function Alert({ type, message }: { type: AlertType; message: string }) {
151
+ function Alert({ type, message }: { type: 'success' | 'danger' | 'warning'; message: string }) {
152
+ const styles = {
153
+ success: 'bg-green-50 tx-green-700 bd-green-300 border bw-1',
154
+ danger: 'bg-red-50 tx-red-700 bd-red-300 border bw-1',
155
+ warning: 'bg-amber-50 tx-amber-700 bd-amber-300 border bw-1',
156
+ };
157
+
198
158
  return (
199
- <div
200
- role="alert"
201
- 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'
206
- }}
207
- >
159
+ <div role="alert" className={`${styles[type]} px-4 py-2 br-md fs-sm`}>
208
160
  {message}
209
161
  </div>
210
162
  );
211
163
  }
212
164
 
213
- // Usage
214
165
  <Alert type="success" message="Profile saved!" />
215
- <Alert type="danger" message="Something went wrong." />
166
+ <Alert type="danger" message="Something went wrong." />
216
167
  <Alert type="warning" message="Your session expires soon." />
217
168
  ```
218
169
 
219
- #### Card component
170
+ ### Card
220
171
 
221
172
  ```tsx
222
- import { tokens } from '@techv/design-system';
223
-
224
173
  function Card({ title, body }: { title: string; body: string }) {
225
174
  return (
226
- <div
227
- 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',
234
- }}
235
- >
236
- <h2
237
- style={{
238
- margin: 0,
239
- fontSize: tokens.fontSize.h4, // '18px'
240
- color: tokens.semantic.textPrimary, // '#111827'
241
- marginBottom: tokens.space.sm, // 8
242
- }}
243
- >
244
- {title}
245
- </h2>
246
- <p
247
- style={{
248
- margin: 0,
249
- fontSize: tokens.fontSize.bodyMd, // '14px'
250
- color: tokens.semantic.textSecondary, // '#6B7280'
251
- lineHeight: 1.6,
252
- }}
253
- >
254
- {body}
255
- </p>
175
+ <div className="bg-white bd-gray-200 border bw-1 br-2xl p-8 sh-3">
176
+ <h2 className="fs-lg fw-6 tx-gray-900 mb-2">{title}</h2>
177
+ <p className="fs-sm tx-gray-500 lh-relaxed">{body}</p>
256
178
  </div>
257
179
  );
258
180
  }
259
181
  ```
260
182
 
261
- #### Using flat `colors` / `spacing` / `radii` exports
183
+ ### Tag
262
184
 
263
185
  ```tsx
264
- import { colors, spacing, radii } from '@techv/design-system';
265
-
266
186
  function Tag({ label }: { label: string }) {
267
187
  return (
268
- <span
269
- 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'
275
- }}
276
- >
188
+ <span className="bg-gray-100 tx-gray-700 px-2 py-1 br-md bd-gray-200 border bw-1 fs-xs fw-5">
277
189
  {label}
278
190
  </span>
279
191
  );
280
192
  }
281
193
  ```
282
194
 
283
- #### Animated element using duration + easing tokens
195
+ ### Flex layout
284
196
 
285
197
  ```tsx
286
- import { tokens } from '@techv/design-system';
198
+ <div className="flex items-center gap-4 px-4 py-2">
199
+ <span className="fw-6 tx-gray-900">Title</span>
200
+ <span className="tx-gray-500 fs-sm">Subtitle</span>
201
+ </div>
202
+ ```
287
203
 
288
- function FadeInBox({ children }: { children: React.ReactNode }) {
289
- return (
290
- <div
291
- 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)
297
- }}
298
- >
299
- {children}
300
- </div>
301
- );
302
- }
204
+ ---
205
+
206
+ ## Class Reference
207
+
208
+ ### Colors
209
+
210
+ | Pattern | Example | Property |
211
+ |---|---|---|
212
+ | `bg-{color}-{weight}` | `bg-indigo-500` | `background-color` |
213
+ | `tx-{color}-{weight}` | `tx-gray-700` | `color` |
214
+ | `bd-{color}-{weight}` | `bd-gray-200` | `border-color` |
215
+ | `bg-white` / `bg-black` | — | `background-color` |
216
+ | `tx-white` / `tx-black` | — | `color` |
217
+
218
+ Available colors: `red` `orange` `amber` `yellow` `lime` `green` `teal` `cyan` `sky` `blue` `indigo` `violet` `purple` `pink` `rose` `slate` `gray` `zinc`
219
+
220
+ Weights: `50` `100` `200` `300` `400` `500` `600` `700` `800` `900`
221
+
222
+ ### Spacing
223
+
224
+ | Pattern | Example | Values |
225
+ |---|---|---|
226
+ | `p-{n}` | `p-4` → 16px | 0–32 |
227
+ | `px-{n}` | `px-2` → 8px | 0–32 |
228
+ | `py-{n}` | `py-1` → 4px | 0–32 |
229
+ | `pt/pb/pl/pr-{n}` | `pt-2` | 0–32 |
230
+ | `m-{n}` | `m-4` | 0–32 |
231
+ | `mx-{n}` / `my-{n}` | `mx-auto` | 0–32 + auto |
232
+ | `mt/mb/ml/mr-{n}` | `mb-2` | 0–32 |
233
+ | `gap-{n}` / `gap-x-{n}` / `gap-y-{n}` | `gap-4` | 0–32 |
234
+
235
+ Spacing values: 0=0px · 0.5=2px · 1=4px · 1.5=6px · 2=8px · 2.5=10px · 3=12px · 4=16px · 5=20px · 6=24px · 8=32px · 10=40px · 12=48px · 16=64px
236
+
237
+ ### Typography
238
+
239
+ | Class | Value |
240
+ |---|---|
241
+ | `fs-xs` | 12px |
242
+ | `fs-sm` | 14px |
243
+ | `fs-md` | 16px |
244
+ | `fs-lg` | 18px |
245
+ | `fs-xl` | 20px |
246
+ | `fs-2xl` | 24px |
247
+ | `fs-3xl` | 30px |
248
+ | `fs-4xl` | 36px |
249
+ | `fs-5xl` | 48px |
250
+ | `fw-3` | 300 |
251
+ | `fw-4` | 400 |
252
+ | `fw-5` | 500 |
253
+ | `fw-6` | 600 |
254
+ | `fw-7` | 700 |
255
+ | `fw-8` | 800 |
256
+ | `fw-9` | 900 |
257
+ | `lh-tight` | 1.25 |
258
+ | `lh-base` | 1.5 |
259
+ | `lh-relaxed` | 1.625 |
260
+ | `ta-l` / `ta-c` / `ta-r` | text-align |
261
+
262
+ ### Border
263
+
264
+ | Class | Value |
265
+ |---|---|
266
+ | `border` | `border-style: solid` |
267
+ | `border-t/b/l/r` | per-side solid border |
268
+ | `bw-1` | 1px |
269
+ | `bw-2` | 2px |
270
+ | `bw-4` | 4px |
271
+ | `br-none` | 0px |
272
+ | `br-sm` | 2px |
273
+ | `br-md` | 4px |
274
+ | `br-lg` | 8px |
275
+ | `br-xl` | 12px |
276
+ | `br-2xl` | 16px |
277
+ | `br-full` | 9999px |
278
+
279
+ ### Shadow & Opacity
280
+
281
+ | Class | Description |
282
+ |---|---|
283
+ | `sh-1` – `sh-5` | Elevation levels |
284
+ | `sh-none` | No shadow |
285
+ | `op-0` – `op-100` | Opacity (0–1) |
286
+
287
+ ### Layout
288
+
289
+ | Class | Value |
290
+ |---|---|
291
+ | `flex` | `display: flex` |
292
+ | `inline-flex` | `display: inline-flex` |
293
+ | `block` | `display: block` |
294
+ | `hidden` | `display: none` |
295
+ | `flex-row` | `flex-direction: row` |
296
+ | `flex-col` | `flex-direction: column` |
297
+ | `flex-wrap` | `flex-wrap: wrap` |
298
+ | `items-center` | `align-items: center` |
299
+ | `items-start` | `align-items: flex-start` |
300
+ | `justify-center` | `justify-content: center` |
301
+ | `justify-between` | `justify-content: space-between` |
302
+ | `justify-end` | `justify-content: flex-end` |
303
+ | `relative` | `position: relative` |
304
+ | `absolute` | `position: absolute` |
305
+ | `w-full` | `width: 100%` |
306
+ | `h-full` | `height: 100%` |
307
+
308
+ ---
309
+
310
+ ## CSS Custom Properties
311
+
312
+ All tokens are also available as CSS variables:
313
+
314
+ ```css
315
+ background-color: var(--indigo-500);
316
+ color: var(--gray-700);
317
+ border-color: var(--red-200);
318
+
319
+ padding: var(--spacing-4); /* 16px */
320
+ gap: var(--spacing-2); /* 8px */
321
+
322
+ font-size: var(--fs-lg); /* 18px */
323
+ font-weight: var(--fw-6); /* 600 */
324
+
325
+ border-radius: var(--br-lg); /* 8px */
326
+ box-shadow: var(--sh-3);
303
327
  ```
304
328
 
305
- #### Quick reference
329
+ ---
330
+
331
+ ## JavaScript Tokens
332
+
333
+ Import token values for use in styled-components or dynamic styles:
306
334
 
307
335
  ```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'
336
+ import { bg, tx, bd, fl, spacing, fs, fw, lh, ta, br, bw, sh, op, duration, ease } from '@techv/design-system';
334
337
  ```
335
338
 
336
- ### Token Reference
339
+ | Export | Purpose | Example |
340
+ |---|---|---|
341
+ | `colors` | Full color palette | `colors.red[500]` → `'#EF4444'` |
342
+ | `bg` | Background colors (alias of colors) | `bg.indigo[50]` → `'#EEF2FF'` |
343
+ | `tx` | Text colors (alias of colors) | `tx.gray[700]` → `'#374151'` |
344
+ | `bd` | Border colors (alias of colors) | `bd.gray[200]` → `'#E5E7EB'` |
345
+ | `fl` | SVG fill colors (alias of colors) | `fl.green[400]` → `'#4ADE80'` |
346
+ | `spacing` | 4px-base numeric scale | `spacing[4]` → `'16px'` |
347
+ | `fs` | Font sizes | `fs.sm` → `'14px'` |
348
+ | `fw` | Font weights | `fw[7]` → `'700'` |
349
+ | `lh` | Line heights | `lh.base` → `1.5` |
350
+ | `ta` | Text alignment | `ta.c` → `'center'` |
351
+ | `br` | Border radius | `br.full` → `'9999px'` |
352
+ | `bw` | Border widths | `bw[1]` → `'1px'` |
353
+ | `sh` | Shadows | `sh[3]` → md elevation |
354
+ | `op` | Opacity | `op[50]` → `'0.5'` |
355
+ | `duration` | Animation durations | `duration.normal` → `'200ms'` |
356
+ | `ease` | Easing curves | `ease.standard` |
357
+
358
+ ### Using tokens in styled-components
337
359
 
338
- #### Colors
360
+ ```tsx
361
+ import styled from 'styled-components';
362
+ import { bg, bd, tx, spacing, br, sh, fs, fw, bw } from '@techv/design-system';
339
363
 
340
- | Token | Value |
341
- |---|---|
342
- | `brand 50–900` | Indigo scale |
343
- | `success 50, 500` | Green |
344
- | `danger 50, 500` | Red |
345
- | `warning 50, 500` | Amber |
346
- | `info 50, 500` | Blue |
347
- | `gray 50–900` | Neutral gray scale |
364
+ const Card = styled.div`
365
+ background: ${bg.white};
366
+ border: ${bw[1]} solid ${bd.gray[200]};
367
+ border-radius: ${br['2xl']};
368
+ padding: ${spacing[8]};
369
+ box-shadow: ${sh[3]};
370
+ `;
348
371
 
349
- #### Spacing
372
+ const Heading = styled.h2`
373
+ font-size: ${fs.lg};
374
+ font-weight: ${fw[6]};
375
+ color: ${tx.gray[900]};
376
+ `;
350
377
 
351
- | Token | Value |
352
- |---|---|
353
- | `2xs` | 2px |
354
- | `xs` | 4px |
355
- | `sm` | 8px |
356
- | `md` | 16px |
357
- | `lg` | 24px |
358
- | `xl` | 32px |
359
- | `2xl` | 48px |
360
- | `3xl` | 64px |
361
-
362
- #### Border radius
363
-
364
- | Token | Value |
365
- |---|---|
366
- | `none` | 0 |
367
- | `xs` | 2px |
368
- | `sm` | 4px |
369
- | `md` | 6px |
370
- | `lg` | 8px |
371
- | `xl` | 12px |
372
- | `2xl` | 16px |
373
- | `full` | 9999px |
378
+ const Body = styled.p`
379
+ font-size: ${fs.sm};
380
+ color: ${tx.gray[500]};
381
+ `;
382
+ ```
374
383
 
375
384
  ---
376
385
 
@@ -379,10 +388,8 @@ radii.full // '9999px'
379
388
  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
389
 
381
390
  ```tsx
382
- // Enable dark mode
383
391
  document.documentElement.setAttribute('data-theme', 'dark');
384
392
 
385
- // Disable dark mode
386
393
  document.documentElement.removeAttribute('data-theme');
387
394
  ```
388
395
 
@@ -397,20 +404,3 @@ Full TypeScript support is included. All component props and token types are exp
397
404
  ```tsx
398
405
  import type { ButtonProps, IconButtonProps } from '@techv/design-system';
399
406
  ```
400
-
401
- ---
402
-
403
- ## Using tokens in styled-components
404
-
405
- ```tsx
406
- import styled from 'styled-components';
407
- import { tokens } from '@techv/design-system';
408
-
409
- 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};
415
- `;
416
- ```
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":";;;;;;;;;;;;;;;;;;;;;;;;;;"}