@techv/design-system 0.1.2 → 0.1.3

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 +183 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -144,30 +144,193 @@ Import `styles.css` to get all tokens as CSS variables on `:root`, usable anywhe
144
144
 
145
145
  ### JavaScript Tokens
146
146
 
147
- Use typed token values directly in styled-components or inline styles.
147
+ #### Inline styles
148
+
149
+ Use tokens directly in React `style` props:
150
+
151
+ ```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
+ }
170
+ ```
171
+
172
+ #### Alert / status banner
173
+
174
+ ```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 }) {
198
+ 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
+ >
208
+ {message}
209
+ </div>
210
+ );
211
+ }
212
+
213
+ // Usage
214
+ <Alert type="success" message="Profile saved!" />
215
+ <Alert type="danger" message="Something went wrong." />
216
+ <Alert type="warning" message="Your session expires soon." />
217
+ ```
218
+
219
+ #### Card component
220
+
221
+ ```tsx
222
+ import { tokens } from '@techv/design-system';
223
+
224
+ function Card({ title, body }: { title: string; body: string }) {
225
+ 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>
256
+ </div>
257
+ );
258
+ }
259
+ ```
260
+
261
+ #### Using flat `colors` / `spacing` / `radii` exports
262
+
263
+ ```tsx
264
+ import { colors, spacing, radii } from '@techv/design-system';
265
+
266
+ function Tag({ label }: { label: string }) {
267
+ 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
+ >
277
+ {label}
278
+ </span>
279
+ );
280
+ }
281
+ ```
282
+
283
+ #### Animated element using duration + easing tokens
284
+
285
+ ```tsx
286
+ import { tokens } from '@techv/design-system';
287
+
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
+ }
303
+ ```
304
+
305
+ #### Quick reference
148
306
 
149
307
  ```tsx
150
308
  import { tokens, colors, spacing, radii } from '@techv/design-system';
151
309
 
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'
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'
171
334
  ```
172
335
 
173
336
  ### Token Reference
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techv/design-system",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "author": "Pranav V K <pranavvk@techversantinfotech.com>",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",