@techv/design-system 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +253 -0
  2. package/package.json +5 -4
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # @techv/design-system
2
+
3
+ A React component library and design token system. Single package — install once and get both UI components and design tokens.
4
+
5
+ ## Requirements
6
+
7
+ | Peer dependency | Version |
8
+ |---|---|
9
+ | react | ^18.0.0 |
10
+ | react-dom | ^18.0.0 |
11
+ | styled-components | ^6.1.0 |
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @techv/design-system styled-components
17
+ ```
18
+ ```bash
19
+ yarn add @techv/design-system styled-components
20
+ ```
21
+ ```bash
22
+ pnpm add @techv/design-system styled-components
23
+ ```
24
+
25
+ ## Setup
26
+
27
+ Import the global CSS in your app entry point. This loads the CSS custom properties (design tokens) and dark mode support.
28
+
29
+ ```tsx
30
+ // index.tsx or App.tsx
31
+ import '@techv/design-system/styles.css';
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Components
37
+
38
+ ### Button
39
+
40
+ ```tsx
41
+ import { Button } from '@techv/design-system';
42
+
43
+ export default function App() {
44
+ return <Button>Click me</Button>;
45
+ }
46
+ ```
47
+
48
+ #### Props
49
+
50
+ | Prop | Type | Default | Description |
51
+ |---|---|---|---|
52
+ | `variant` | `solid` \| `outline` \| `ghost` \| `soft` \| `link` | `solid` | Visual style |
53
+ | `color` | `brand` \| `danger` \| `success` \| `warning` \| `neutral` | `brand` | Color scheme |
54
+ | `size` | `xs` \| `sm` \| `md` \| `lg` \| `xl` | `md` | Button size |
55
+ | `isLoading` | `boolean` | `false` | Shows a spinner and disables the button |
56
+ | `leftIcon` | `ReactNode` | — | Icon rendered before the label |
57
+ | `rightIcon` | `ReactNode` | — | Icon rendered after the label |
58
+ | `disabled` | `boolean` | `false` | Disables the button |
59
+
60
+ Accepts all standard HTML `<button>` attributes.
61
+
62
+ #### Variants
63
+
64
+ ```tsx
65
+ <Button variant="solid">Solid</Button>
66
+ <Button variant="outline">Outline</Button>
67
+ <Button variant="ghost">Ghost</Button>
68
+ <Button variant="soft">Soft</Button>
69
+ <Button variant="link">Link</Button>
70
+ ```
71
+
72
+ #### Colors
73
+
74
+ ```tsx
75
+ <Button color="brand">Brand</Button>
76
+ <Button color="danger">Danger</Button>
77
+ <Button color="success">Success</Button>
78
+ <Button color="warning">Warning</Button>
79
+ <Button color="neutral">Neutral</Button>
80
+ ```
81
+
82
+ #### Sizes
83
+
84
+ ```tsx
85
+ <Button size="xs">Extra Small</Button>
86
+ <Button size="sm">Small</Button>
87
+ <Button size="md">Medium</Button>
88
+ <Button size="lg">Large</Button>
89
+ <Button size="xl">Extra Large</Button>
90
+ ```
91
+
92
+ #### With icons
93
+
94
+ ```tsx
95
+ <Button leftIcon={<SearchIcon />}>Search</Button>
96
+ <Button rightIcon={<ArrowRightIcon />}>Next</Button>
97
+ ```
98
+
99
+ #### Loading state
100
+
101
+ ```tsx
102
+ <Button isLoading>Saving...</Button>
103
+ ```
104
+
105
+ ---
106
+
107
+ ### IconButton
108
+
109
+ A square button that holds a single icon. Requires `aria-label` for accessibility.
110
+
111
+ ```tsx
112
+ import { IconButton } from '@techv/design-system';
113
+
114
+ <IconButton icon={<SearchIcon />} aria-label="Search" />
115
+ ```
116
+
117
+ #### Props
118
+
119
+ | Prop | Type | Default | Description |
120
+ |---|---|---|---|
121
+ | `icon` | `ReactNode` | **required** | The icon to display |
122
+ | `aria-label` | `string` | **required** | Accessible label |
123
+ | `variant` | `solid` \| `outline` \| `ghost` \| `soft` \| `link` | `solid` | Visual style |
124
+ | `color` | `brand` \| `danger` \| `success` \| `warning` \| `neutral` | `brand` | Color scheme |
125
+ | `size` | `xs` \| `sm` \| `md` \| `lg` \| `xl` | `md` | Button size |
126
+ | `isLoading` | `boolean` | `false` | Shows a spinner |
127
+ | `disabled` | `boolean` | `false` | Disables the button |
128
+
129
+ ---
130
+
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
+ ```
144
+
145
+ ### JavaScript Tokens
146
+
147
+ Use typed token values directly in styled-components or inline styles.
148
+
149
+ ```tsx
150
+ import { tokens, colors, spacing, radii } from '@techv/design-system';
151
+
152
+ // Full structured token object
153
+ tokens.color.brand[500] // '#4F46E5'
154
+ tokens.space.md // 16
155
+ tokens.radius.lg // 8
156
+ tokens.shadow.md // '0 4px 6px rgba(0,0,0,0.07)...'
157
+ tokens.duration.normal // 200
158
+ tokens.font.text // 'Inter'
159
+ tokens.fontSize.h1 // '36px'
160
+
161
+ // Flat named exports (convenience)
162
+ colors.brand500 // '#4F46E5'
163
+ colors.textPrimary // '#111827'
164
+ colors.border // '#E5E7EB'
165
+
166
+ spacing.md // '16px'
167
+ spacing.lg // '24px'
168
+
169
+ radii.sm // '4px'
170
+ radii.full // '9999px'
171
+ ```
172
+
173
+ ### Token Reference
174
+
175
+ #### Colors
176
+
177
+ | Token | Value |
178
+ |---|---|
179
+ | `brand 50–900` | Indigo scale |
180
+ | `success 50, 500` | Green |
181
+ | `danger 50, 500` | Red |
182
+ | `warning 50, 500` | Amber |
183
+ | `info 50, 500` | Blue |
184
+ | `gray 50–900` | Neutral gray scale |
185
+
186
+ #### Spacing
187
+
188
+ | Token | Value |
189
+ |---|---|
190
+ | `2xs` | 2px |
191
+ | `xs` | 4px |
192
+ | `sm` | 8px |
193
+ | `md` | 16px |
194
+ | `lg` | 24px |
195
+ | `xl` | 32px |
196
+ | `2xl` | 48px |
197
+ | `3xl` | 64px |
198
+
199
+ #### Border radius
200
+
201
+ | Token | Value |
202
+ |---|---|
203
+ | `none` | 0 |
204
+ | `xs` | 2px |
205
+ | `sm` | 4px |
206
+ | `md` | 6px |
207
+ | `lg` | 8px |
208
+ | `xl` | 12px |
209
+ | `2xl` | 16px |
210
+ | `full` | 9999px |
211
+
212
+ ---
213
+
214
+ ## Dark mode
215
+
216
+ The library ships with a built-in dark mode. Toggle it by setting `data-theme="dark"` on any ancestor element (typically `<html>` or `<body>`).
217
+
218
+ ```tsx
219
+ // Enable dark mode
220
+ document.documentElement.setAttribute('data-theme', 'dark');
221
+
222
+ // Disable dark mode
223
+ document.documentElement.removeAttribute('data-theme');
224
+ ```
225
+
226
+ All components and CSS custom properties respond automatically.
227
+
228
+ ---
229
+
230
+ ## TypeScript
231
+
232
+ Full TypeScript support is included. All component props and token types are exported.
233
+
234
+ ```tsx
235
+ import type { ButtonProps, IconButtonProps } from '@techv/design-system';
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Using tokens in styled-components
241
+
242
+ ```tsx
243
+ import styled from 'styled-components';
244
+ import { tokens } from '@techv/design-system';
245
+
246
+ const Card = styled.div`
247
+ background: ${tokens.semantic.surface};
248
+ border: 1px solid ${tokens.semantic.border};
249
+ border-radius: ${tokens.radius.xl}px;
250
+ padding: ${tokens.space.lg}px;
251
+ box-shadow: ${tokens.shadow.md};
252
+ `;
253
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techv/design-system",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "author": "Pranav V K <pranavvk@techversantinfotech.com>",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",
@@ -20,7 +20,8 @@
20
20
  "./styles.css": "./dist/styles.css"
21
21
  },
22
22
  "files": [
23
- "dist"
23
+ "dist",
24
+ "README.md"
24
25
  ],
25
26
  "sideEffects": [
26
27
  "./dist/styles.css"
@@ -38,8 +39,8 @@
38
39
  "ts-node": "^10.9.2",
39
40
  "tslib": "^2.6.2",
40
41
  "typescript": "~5.4.5",
41
- "@techv/tokens": "0.1.0",
42
- "@techv/ui": "0.1.0"
42
+ "@techv/ui": "0.1.0",
43
+ "@techv/tokens": "0.1.0"
43
44
  },
44
45
  "publishConfig": {
45
46
  "registry": "https://registry.npmjs.org",