@work-rjkashyap/unified-ui 0.1.0
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/CHANGELOG.md +152 -0
- package/README.md +365 -0
- package/dist/chunk-2JFREULQ.cjs +29 -0
- package/dist/chunk-2RGLRX6K.cjs +279 -0
- package/dist/chunk-3HHJAYQI.cjs +469 -0
- package/dist/chunk-5S5DMH5G.cjs +5983 -0
- package/dist/chunk-BIW2RPDU.cjs +73 -0
- package/dist/chunk-CWETOWRM.mjs +456 -0
- package/dist/chunk-ECIGDEAH.cjs +140 -0
- package/dist/chunk-EO4WROWH.mjs +432 -0
- package/dist/chunk-EZ2L3XPS.mjs +83 -0
- package/dist/chunk-I74E52C5.mjs +271 -0
- package/dist/chunk-ITBG42M5.mjs +133 -0
- package/dist/chunk-IWJ5VMZ7.mjs +323 -0
- package/dist/chunk-KHON2AEM.cjs +342 -0
- package/dist/chunk-LSNKPQP7.cjs +58 -0
- package/dist/chunk-M2LNQWOB.mjs +63 -0
- package/dist/chunk-NMPHV6ZD.mjs +27 -0
- package/dist/chunk-QXR4VY7Q.cjs +268 -0
- package/dist/chunk-SSGN5QDC.mjs +248 -0
- package/dist/chunk-X2WCY4VB.mjs +5836 -0
- package/dist/chunk-XCKK6P46.cjs +91 -0
- package/dist/chunk-ZBN26FLO.mjs +46 -0
- package/dist/chunk-ZPIPKY2J.cjs +478 -0
- package/dist/components.cjs +477 -0
- package/dist/components.d.cts +3077 -0
- package/dist/components.d.ts +3077 -0
- package/dist/components.mjs +4 -0
- package/dist/index.cjs +1027 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.mjs +17 -0
- package/dist/motion-D9wQbcKL.d.cts +80 -0
- package/dist/motion-D9wQbcKL.d.ts +80 -0
- package/dist/motion.cjs +216 -0
- package/dist/motion.d.cts +104 -0
- package/dist/motion.d.ts +104 -0
- package/dist/motion.mjs +3 -0
- package/dist/primitives.cjs +57 -0
- package/dist/primitives.d.cts +390 -0
- package/dist/primitives.d.ts +390 -0
- package/dist/primitives.mjs +4 -0
- package/dist/theme.cjs +38 -0
- package/dist/theme.d.cts +117 -0
- package/dist/theme.d.ts +117 -0
- package/dist/theme.mjs +5 -0
- package/dist/tokens.cjs +137 -0
- package/dist/tokens.d.cts +30 -0
- package/dist/tokens.d.ts +30 -0
- package/dist/tokens.mjs +4 -0
- package/dist/typography-DlvVjEdE.d.cts +146 -0
- package/dist/typography-DlvVjEdE.d.ts +146 -0
- package/dist/utils.cjs +164 -0
- package/dist/utils.d.cts +521 -0
- package/dist/utils.d.ts +521 -0
- package/dist/utils.mjs +3 -0
- package/dist/z-index-B_nTQ3qo.d.cts +422 -0
- package/dist/z-index-B_nTQ3qo.d.ts +422 -0
- package/package.json +183 -0
- package/styles.css +500 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Unified UI Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Unified UI design system will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.0] — 2026-02-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
#### Design Tokens
|
|
15
|
+
|
|
16
|
+
- Color palettes: `slate`, `gray`, `zinc`, `neutral`, `red`, `green`, `blue`, `amber`, `teal`, `brand`, `pure`
|
|
17
|
+
- Semantic color mappings for light and dark themes (`semanticLight`, `semanticDark`)
|
|
18
|
+
- Spacing scale (0–96 + custom values)
|
|
19
|
+
- Typography tokens: `fontFamily` (display, sans, serif, mono, inherit), `fontSize`, `fontWeight`, `lineHeight`, `letterSpacing`, typography variant presets
|
|
20
|
+
- Radius scale (`none` through `full`)
|
|
21
|
+
- Shadow scale with light and dark variants
|
|
22
|
+
- Z-index scale (`hide`, `base`, `dropdown`, `sticky`, `overlay`, `modal`, `popover`, `toast`, `max`)
|
|
23
|
+
- Motion tokens: `duration`, `easing`, `spring`, `stagger` (with CSS and seconds variants)
|
|
24
|
+
|
|
25
|
+
#### Theme System
|
|
26
|
+
|
|
27
|
+
- CSS variable contract using `--ds-` prefix for all tokens
|
|
28
|
+
- `DSThemeProvider` component with light/dark/system mode support
|
|
29
|
+
- `useDSTheme()` hook for programmatic theme access
|
|
30
|
+
- `buildLightThemeVars()` / `buildDarkThemeVars()` / `buildThemeCSS()` utilities
|
|
31
|
+
- `cssVar()` helper for type-safe CSS variable references
|
|
32
|
+
|
|
33
|
+
#### Typography System
|
|
34
|
+
|
|
35
|
+
- Multi-font architecture with four font families:
|
|
36
|
+
- **Outfit** (`--font-outfit`) — primary sans-serif UI typeface
|
|
37
|
+
- **Inter** (`--font-inter`) — display / headings
|
|
38
|
+
- **Lora** (`--font-lora`) — serif / editorial
|
|
39
|
+
- **JetBrains Mono** (`--font-jetbrains`) — monospace / code
|
|
40
|
+
- `font` prop on `Typography` component for runtime font switching
|
|
41
|
+
- Graceful fallback to system font stacks when web fonts are unavailable
|
|
42
|
+
|
|
43
|
+
#### Tailwind CSS v4 Integration
|
|
44
|
+
|
|
45
|
+
- `design-system.css` with full `@theme` block mapping all tokens to Tailwind utilities
|
|
46
|
+
- `ds-*` prefixed utilities for colors, radius, shadows, transitions, fonts
|
|
47
|
+
- Font CSS custom properties (`--font-outfit`, `--font-inter`, `--font-lora`, `--font-jetbrains`)
|
|
48
|
+
|
|
49
|
+
#### Primitive Components
|
|
50
|
+
|
|
51
|
+
- **Typography** — polymorphic text component with `variant`, `font`, `color`, `align`, `truncate` props
|
|
52
|
+
- **Heading** — semantic heading (h1–h6) with automatic size mapping
|
|
53
|
+
- **Subheading** — secondary heading variant
|
|
54
|
+
- **Body** — paragraph text with size variants
|
|
55
|
+
- **Caption** — small supporting text
|
|
56
|
+
- **Label** — form label with required indicator support
|
|
57
|
+
- **Overline** — uppercase label text
|
|
58
|
+
- **InlineCode** — inline code formatting
|
|
59
|
+
- **Container** — responsive max-width wrapper (`sm` through `2xl`)
|
|
60
|
+
- **Stack** — flexbox layout with `direction`, `gap`, `align`, `justify`
|
|
61
|
+
- **Grid** — CSS grid layout with responsive column configuration
|
|
62
|
+
- **Divider** — horizontal/vertical separator with label support
|
|
63
|
+
|
|
64
|
+
#### Composite Components (22 total)
|
|
65
|
+
|
|
66
|
+
- **Button** — primary, secondary, outline, ghost, danger, link variants; sm/md/lg sizes; icon-only mode; loading state
|
|
67
|
+
- **Input** — text input with prefix/suffix slots, error state, disabled state
|
|
68
|
+
- **Textarea** — auto-resize support, character count, error state
|
|
69
|
+
- **Select** — Radix-based with groups, labels, separators; searchable variant
|
|
70
|
+
- **Checkbox** — with `CheckboxGroup` for managing groups; indeterminate state
|
|
71
|
+
- **Radio** — `RadioGroup` + `RadioGroupItem` + `RadioCard` variant
|
|
72
|
+
- **Switch** — toggle with label positioning (start/end), sizes
|
|
73
|
+
- **Card** — composable `Card` / `CardHeader` / `CardBody` / `CardFooter`; elevated, outline, ghost variants
|
|
74
|
+
- **Badge** — default, secondary, outline, success, warning, danger variants; sm/md/lg sizes
|
|
75
|
+
- **Avatar** — image with fallback initials, status indicator, `AvatarGroup` stacking
|
|
76
|
+
- **Tooltip** — Radix-based with configurable side, align, delay
|
|
77
|
+
- **Popover** — Radix-based with arrow, close button, controlled/uncontrolled
|
|
78
|
+
- **DropdownMenu** — full Radix menu with items, checkbox items, radio items, sub-menus, shortcuts
|
|
79
|
+
- **Dialog** — modal with sm/md/lg/xl/full sizes; composable header/body/footer; scroll locking
|
|
80
|
+
- **Sheet** — slide-out drawer from top/right/bottom/left; sm/md/lg/xl sizes
|
|
81
|
+
- **Tabs** — underline, segment, pills variants; horizontal/vertical orientation
|
|
82
|
+
- **Accordion** — single/multiple mode; default/bordered/ghost variants; sm/md/lg sizes
|
|
83
|
+
- **Toast** — portal-based with stacking, auto-dismiss, pause-on-hover, progress bar, `useToast()` hook
|
|
84
|
+
- **Alert** — info, success, warning, error variants with icon, title, description
|
|
85
|
+
- **Skeleton** — base `Skeleton` + `SkeletonText`, `SkeletonCircle`, `SkeletonRect` presets; pulse animation
|
|
86
|
+
- **Table** — semantic table with striped rows, hover highlight, sticky header, responsive wrapper; compact/default/relaxed density
|
|
87
|
+
- **Pagination** — page numbers with ellipsis, prev/next, compact variant, controlled/uncontrolled
|
|
88
|
+
- **Breadcrumb** — composable sub-components + `BreadcrumbNav` shorthand; truncation with ellipsis
|
|
89
|
+
|
|
90
|
+
#### Motion System
|
|
91
|
+
|
|
92
|
+
- Fade presets: `fadeIn`, `fadeInFast`, `fadeInSlow`
|
|
93
|
+
- Slide presets: `slideUp`, `slideUpSm`, `slideUpLg`, `slideUpSpring`, `slideDown`, `slideDownSm`, `slideLeft`, `slideRight`, `slideInFromLeft`, `slideInFromRight`, `slideInFromBottom`
|
|
94
|
+
- Scale presets: `scaleIn`, `scaleInLg`, `scaleInSpring`
|
|
95
|
+
- Blur presets: `blurIn`, `blurInSubtle`
|
|
96
|
+
- Overlay/modal: `overlayBackdrop`, `modalContent`, `modalContentSpring`
|
|
97
|
+
- Toast: `toastSlideIn`, `toastSlideUp`
|
|
98
|
+
- Expand/collapse: `expandHeight`, `expandHeightSlow`
|
|
99
|
+
- Micro-interactions: `press`, `tapScale`, `hoverScale`, `hoverLift`, `pop`, `popSubtle`
|
|
100
|
+
- Loading: `pulse`, `spin`
|
|
101
|
+
- Stagger containers: `staggerContainer`, `staggerContainerFast`, `staggerContainerSlow`
|
|
102
|
+
- `motionProps()` spread helper for clean JSX usage
|
|
103
|
+
- `reduceMotion` / `withReducedMotion()` utilities for `prefers-reduced-motion` support
|
|
104
|
+
|
|
105
|
+
#### Utilities
|
|
106
|
+
|
|
107
|
+
- `cn()` — class name merger (clsx + tailwind-merge)
|
|
108
|
+
- `mergeSlots()` — slot-based class merging for composite components
|
|
109
|
+
- `composeRefs()` — compose multiple React refs into one
|
|
110
|
+
- `dsAttr()` / `dsDataAttrs()` — data attribute generators for component identification
|
|
111
|
+
- `dsStateAttr()` — conditional data attribute for component states
|
|
112
|
+
- `dsVar()` / `dsColorVar()` — CSS custom property reference helpers
|
|
113
|
+
- `typedKeys()` — type-safe `Object.keys`
|
|
114
|
+
- `noop` — no-operation function
|
|
115
|
+
- Polymorphic component types: `AsProp`, `PolymorphicProps`, `PolymorphicPropsWithRef`, `PolymorphicRef`, `PolymorphicComponent`
|
|
116
|
+
- Slot types: `SlotClasses`, `SlotConfig`, `SlotDefinition`, `SlotRenderFn`, `Slots`
|
|
117
|
+
- Component types: `ComponentSize`, `ComponentIntent`, `ChildrenProps`, `OptionalChildrenProps`
|
|
118
|
+
|
|
119
|
+
#### Package & Build
|
|
120
|
+
|
|
121
|
+
- `tsup` build pipeline producing ESM (`.mjs`) and CJS (`.cjs`) with TypeScript declarations (`.d.ts` / `.d.cts`)
|
|
122
|
+
- 7 entry points: `index`, `tokens`, `theme`, `primitives`, `components`, `motion`, `utils`
|
|
123
|
+
- Selective `"use client"` directive — applied only to client entry points (not tokens/utils)
|
|
124
|
+
- Radix UI packages externalized as optional peer dependencies
|
|
125
|
+
- Tree-shakeable with code splitting enabled
|
|
126
|
+
- `design-system.css` exported as `unified-ui/css` for Tailwind `@theme` integration
|
|
127
|
+
- `@unified-ui/*` TypeScript path aliases (zero relative cross-directory imports)
|
|
128
|
+
- Consumer documentation: `INSTALL.md` with setup guide, font loading, theme provider, import patterns, troubleshooting
|
|
129
|
+
|
|
130
|
+
#### Infrastructure
|
|
131
|
+
|
|
132
|
+
- `UNIFIED_UI_VERSION` exported constant for runtime version checking
|
|
133
|
+
- `.npmignore` for clean package distribution
|
|
134
|
+
- `sideEffects` field for optimal tree-shaking
|
|
135
|
+
- Conditional `exports` map with full `import`/`require`/`types` resolution
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## [Unreleased]
|
|
140
|
+
|
|
141
|
+
### Planned
|
|
142
|
+
|
|
143
|
+
- Documentation site overhaul (Phase 6) — MDX pages with interactive component previews
|
|
144
|
+
- Motion & accessibility hardening (Phase 7) — focus ring standardization, WCAG AA contrast audit, `prefers-reduced-motion` audit
|
|
145
|
+
- Migration guide (Phase 9) — mapping from legacy `fd-*` tokens to `ds-*` tokens, component replacement strategy
|
|
146
|
+
- CI/CD pipeline for automated publishing on git tags
|
|
147
|
+
- `UnifiedUIProvider` component for optional auto CSS injection
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
_Design system: Unified UI v0.1.0_
|
|
152
|
+
_Maintainer: Rajeshwar Kashyap_
|
package/README.md
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# @work-rjkashyap/unified-ui
|
|
2
|
+
|
|
3
|
+
> A scalable, token-driven React design system built with Tailwind CSS v4, Radix UI, and Framer Motion.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@work-rjkashyap/unified-ui)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Token-driven** — Every color, spacing, radius, shadow, and motion value flows from a single source of truth
|
|
13
|
+
- **22+ components** — Battle-tested composites built on Radix UI primitives
|
|
14
|
+
- **Tailwind CSS v4** — First-class integration via `@theme` and `ds-*` utility classes
|
|
15
|
+
- **Framer Motion** — Consistent animation presets with `prefers-reduced-motion` support
|
|
16
|
+
- **Accessible** — WCAG AA contrast, keyboard navigation, ARIA attributes, and focus management
|
|
17
|
+
- **Tree-shakeable** — 7 independent entry points with ESM/CJS dual output and code splitting
|
|
18
|
+
- **Type-safe** — Full TypeScript coverage with exported types for every prop, variant, and token
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @work-rjkashyap/unified-ui
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Peer Dependencies
|
|
29
|
+
|
|
30
|
+
| Package | Version | Required |
|
|
31
|
+
| -------------- | --------- | -------- |
|
|
32
|
+
| `react` | ≥ 19.0.0 | Yes |
|
|
33
|
+
| `react-dom` | ≥ 19.0.0 | Yes |
|
|
34
|
+
| `tailwindcss` | ≥ 4.0.0 | Optional |
|
|
35
|
+
|
|
36
|
+
Radix UI primitives and Framer Motion are optional — install only the ones you use:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# If using motion presets
|
|
40
|
+
npm install framer-motion
|
|
41
|
+
|
|
42
|
+
# If using Radix-based components (Dialog, Select, Tabs, etc.)
|
|
43
|
+
npm install @radix-ui/react-dialog @radix-ui/react-select @radix-ui/react-tabs
|
|
44
|
+
# ... and any other @radix-ui/* packages for the components you need
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### 1. Import the CSS
|
|
52
|
+
|
|
53
|
+
Add the stylesheet to your global CSS file **before** any component usage. This registers all `--ds-*` CSS custom properties and Tailwind `@theme` utilities.
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
/* src/app/globals.css */
|
|
57
|
+
@import "tailwindcss";
|
|
58
|
+
@import "@work-rjkashyap/unified-ui/styles.css";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. Load Fonts (Recommended)
|
|
62
|
+
|
|
63
|
+
Unified UI references four font families via CSS variables. Load them in your root layout:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
// src/app/layout.tsx
|
|
67
|
+
import { Outfit, Inter, Lora, JetBrains_Mono } from "next/font/google";
|
|
68
|
+
|
|
69
|
+
const outfit = Outfit({ subsets: ["latin"], variable: "--font-outfit" });
|
|
70
|
+
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
|
|
71
|
+
const lora = Lora({ subsets: ["latin"], variable: "--font-lora" });
|
|
72
|
+
const jetbrainsMono = JetBrains_Mono({
|
|
73
|
+
subsets: ["latin"],
|
|
74
|
+
variable: "--font-jetbrains",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export default function RootLayout({ children }) {
|
|
78
|
+
return (
|
|
79
|
+
<html
|
|
80
|
+
lang="en"
|
|
81
|
+
className={`${outfit.variable} ${inter.variable} ${lora.variable} ${jetbrainsMono.variable} ${outfit.className}`}
|
|
82
|
+
>
|
|
83
|
+
<body>{children}</body>
|
|
84
|
+
</html>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If you don't load these fonts, the system gracefully falls back to system font stacks.
|
|
90
|
+
|
|
91
|
+
### 3. Wrap with Theme Provider (Optional)
|
|
92
|
+
|
|
93
|
+
If you need programmatic light/dark/system theme toggling:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { DSThemeProvider } from "@work-rjkashyap/unified-ui";
|
|
97
|
+
|
|
98
|
+
export default function Providers({ children }) {
|
|
99
|
+
return <DSThemeProvider>{children}</DSThemeProvider>;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
If you already use `next-themes` or another provider that toggles the `.dark` class on `<html>`, the CSS variables respond automatically — no `DSThemeProvider` needed.
|
|
104
|
+
|
|
105
|
+
### 4. Use Components
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { Button, Heading, Body, Stack } from "@work-rjkashyap/unified-ui";
|
|
109
|
+
|
|
110
|
+
export function Hero() {
|
|
111
|
+
return (
|
|
112
|
+
<Stack direction="column" gap={4}>
|
|
113
|
+
<Heading level={1}>Welcome to Unified UI</Heading>
|
|
114
|
+
<Body>A token-driven design system for React applications.</Body>
|
|
115
|
+
<Button variant="primary" size="md">
|
|
116
|
+
Get Started
|
|
117
|
+
</Button>
|
|
118
|
+
</Stack>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Import Patterns
|
|
126
|
+
|
|
127
|
+
### Barrel import (most common)
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { Button, Typography, fadeIn, cn } from "@work-rjkashyap/unified-ui";
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Layer-specific imports (better tree-shaking in large apps)
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { spacing, radius } from "@work-rjkashyap/unified-ui/tokens";
|
|
137
|
+
import { DSThemeProvider } from "@work-rjkashyap/unified-ui/theme";
|
|
138
|
+
import { Typography, Heading } from "@work-rjkashyap/unified-ui/primitives";
|
|
139
|
+
import { Button, Dialog } from "@work-rjkashyap/unified-ui/components";
|
|
140
|
+
import { slideUp, motionProps } from "@work-rjkashyap/unified-ui/motion";
|
|
141
|
+
import { cn, mergeSlots } from "@work-rjkashyap/unified-ui/utils";
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Architecture
|
|
147
|
+
|
|
148
|
+
The design system is organized into strict layers. Each layer only depends on the layers below it — never sideways or upward.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
┌─────────────────────────────────────────────────┐
|
|
152
|
+
│ Layer 6: Utilities src/utils/ │
|
|
153
|
+
│ Layer 5: Motion System src/motion/ │
|
|
154
|
+
│ Layer 4: Components src/components/ │
|
|
155
|
+
│ Layer 3: Primitives src/primitives/ │
|
|
156
|
+
│ Layer 2: Theme System src/theme/ │
|
|
157
|
+
│ Layer 1: Design Tokens src/tokens/ │
|
|
158
|
+
└─────────────────────────────────────────────────┘
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Layer 1 — Design Tokens (`tokens/`)
|
|
162
|
+
|
|
163
|
+
Raw design values: colors, spacing, typography, radius, shadows, z-index, and motion timing. The **single source of truth** for all visual properties.
|
|
164
|
+
|
|
165
|
+
| File | Contents |
|
|
166
|
+
| --------------- | ------------------------------------------------------------- |
|
|
167
|
+
| `colors.ts` | Color palettes + semantic maps for light/dark |
|
|
168
|
+
| `spacing.ts` | 4px-grid spacing scale |
|
|
169
|
+
| `typography.ts` | Font families, sizes, weights, line heights, letter spacing |
|
|
170
|
+
| `radius.ts` | Border radius scale |
|
|
171
|
+
| `shadows.ts` | Box shadow elevation scale (light + dark) |
|
|
172
|
+
| `z-index.ts` | Z-index layering scale |
|
|
173
|
+
| `motion.ts` | Duration, easing, spring, and stagger tokens |
|
|
174
|
+
|
|
175
|
+
### Layer 2 — Theme System (`theme/`)
|
|
176
|
+
|
|
177
|
+
Bridges tokens to runtime via CSS custom properties and React context.
|
|
178
|
+
|
|
179
|
+
| File | Contents |
|
|
180
|
+
| -------------- | --------------------------------------------------------------- |
|
|
181
|
+
| `contract.ts` | Maps token keys → CSS variable names (`--ds-*`), `cssVar` helper |
|
|
182
|
+
| `provider.tsx` | `DSThemeProvider` + `useDSTheme` hook |
|
|
183
|
+
|
|
184
|
+
### Layer 3 — Primitives (`primitives/`)
|
|
185
|
+
|
|
186
|
+
Foundational UI building blocks:
|
|
187
|
+
|
|
188
|
+
- **Typography** — `Typography`, `Heading`, `Body`, `Caption`, `Label`, `Overline`, `InlineCode`
|
|
189
|
+
- **Layout** — `Container`, `Stack`, `Grid`
|
|
190
|
+
- **Structural** — `Divider`
|
|
191
|
+
|
|
192
|
+
### Layer 4 — Components (`components/`)
|
|
193
|
+
|
|
194
|
+
22 production-ready composite components:
|
|
195
|
+
|
|
196
|
+
| Component | Component | Component |
|
|
197
|
+
| -------------- | --------------- | -------------- |
|
|
198
|
+
| Accordion | Dialog | Select |
|
|
199
|
+
| Alert | DropdownMenu | Sheet |
|
|
200
|
+
| Avatar | Input | Skeleton |
|
|
201
|
+
| Badge | Pagination | Switch |
|
|
202
|
+
| Breadcrumb | Popover | Table |
|
|
203
|
+
| Button | Radio | Tabs |
|
|
204
|
+
| Card | Checkbox | Textarea |
|
|
205
|
+
| | | Toast / Tooltip|
|
|
206
|
+
|
|
207
|
+
### Layer 5 — Motion (`motion/`)
|
|
208
|
+
|
|
209
|
+
Framer Motion animation presets: `fadeIn`, `slideUp`, `scaleIn`, `modalContent`, `toastSlideIn`, stagger containers, micro-interactions, and reduced-motion utilities.
|
|
210
|
+
|
|
211
|
+
### Layer 6 — Utilities (`utils/`)
|
|
212
|
+
|
|
213
|
+
- `cn()` — class merging (clsx + tailwind-merge)
|
|
214
|
+
- `mergeSlots()` — slot-based class composition
|
|
215
|
+
- `composeRefs()` — combine multiple refs
|
|
216
|
+
- `dsAttr()` / `dsStateAttr()` — data attribute generators
|
|
217
|
+
- `dsVar()` / `dsColorVar()` — CSS variable reference helpers
|
|
218
|
+
- Focus ring utilities
|
|
219
|
+
- WCAG contrast checking utilities
|
|
220
|
+
- Polymorphic component types
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## CSS Variable Prefix
|
|
225
|
+
|
|
226
|
+
All CSS custom properties use the `--ds-` prefix:
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
--ds-color-primary
|
|
230
|
+
--ds-radius-md
|
|
231
|
+
--ds-shadow-lg
|
|
232
|
+
--ds-duration-normal
|
|
233
|
+
--ds-easing-standard
|
|
234
|
+
--ds-font-sans
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Tailwind Utility Classes
|
|
238
|
+
|
|
239
|
+
After importing the CSS, use `ds-*` prefixed Tailwind utilities anywhere:
|
|
240
|
+
|
|
241
|
+
```html
|
|
242
|
+
<!-- Colors (supports opacity modifier) -->
|
|
243
|
+
<div class="bg-ds-primary text-ds-primary-foreground">Primary</div>
|
|
244
|
+
<div class="bg-ds-muted/50">Semi-transparent muted</div>
|
|
245
|
+
|
|
246
|
+
<!-- Radius, shadows, transitions -->
|
|
247
|
+
<div class="rounded-ds-md shadow-ds-lg">Elevated card</div>
|
|
248
|
+
<button class="duration-ds-fast ease-ds-standard">Animated</button>
|
|
249
|
+
|
|
250
|
+
<!-- Fonts -->
|
|
251
|
+
<p class="font-ds-serif">Editorial text</p>
|
|
252
|
+
<code class="font-ds-mono">console.log("hello")</code>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Data Attributes
|
|
256
|
+
|
|
257
|
+
Components emit `data-ds` attributes for CSS scoping and testing:
|
|
258
|
+
|
|
259
|
+
```html
|
|
260
|
+
<button data-ds data-ds-component="button" data-ds-variant="primary" data-ds-size="md">
|
|
261
|
+
Click me
|
|
262
|
+
</button>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Entry Points
|
|
268
|
+
|
|
269
|
+
The package provides 7 independently importable entry points for optimal tree-shaking:
|
|
270
|
+
|
|
271
|
+
| Entry Point | Import Path | Contains |
|
|
272
|
+
| ------------- | ------------------------------- | ---------------------------------- |
|
|
273
|
+
| Root | `@work-rjkashyap/unified-ui` | Everything (barrel) |
|
|
274
|
+
| Tokens | `@work-rjkashyap/unified-ui/tokens` | Design tokens (pure JS, no React) |
|
|
275
|
+
| Theme | `@work-rjkashyap/unified-ui/theme` | Theme provider, contract, hooks |
|
|
276
|
+
| Primitives | `@work-rjkashyap/unified-ui/primitives` | Typography, Layout, Divider |
|
|
277
|
+
| Components | `@work-rjkashyap/unified-ui/components` | All 22 composite components |
|
|
278
|
+
| Motion | `@work-rjkashyap/unified-ui/motion` | Animation presets and utilities |
|
|
279
|
+
| Utils | `@work-rjkashyap/unified-ui/utils` | cn, mergeSlots, contrast, etc. |
|
|
280
|
+
| CSS | `@work-rjkashyap/unified-ui/styles.css` | Tailwind @theme + CSS variables |
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Build
|
|
285
|
+
|
|
286
|
+
The package is built with [tsup](https://tsup.egoist.dev/), producing:
|
|
287
|
+
|
|
288
|
+
- **ESM** (`.mjs`) and **CJS** (`.cjs`) formats
|
|
289
|
+
- **TypeScript declarations** (`.d.ts` / `.d.cts`)
|
|
290
|
+
- Code splitting enabled for optimal bundle size
|
|
291
|
+
- Selective `"use client"` directive on client entry points (tokens/utils remain server-safe)
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Build the package
|
|
295
|
+
npm run build
|
|
296
|
+
|
|
297
|
+
# Watch mode for development
|
|
298
|
+
npm run dev
|
|
299
|
+
|
|
300
|
+
# Type check
|
|
301
|
+
npm run typecheck
|
|
302
|
+
|
|
303
|
+
# Clean dist/
|
|
304
|
+
npm run clean
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Key Rules
|
|
310
|
+
|
|
311
|
+
1. **Never hardcode design values.** All colors, spacing, radii, shadows, and motion values must come from tokens.
|
|
312
|
+
2. **Always use `cn()` for class merging.** Never concatenate class strings manually.
|
|
313
|
+
3. **Components must emit `data-ds` attributes** for scoping and testability.
|
|
314
|
+
4. **Respect the layer hierarchy.** Tokens → Theme → Primitives → Components. No upward imports.
|
|
315
|
+
5. **All components must support `ref` forwarding** via `React.forwardRef`.
|
|
316
|
+
6. **Accessibility is mandatory.** Focus rings, ARIA attributes, keyboard navigation, and `prefers-reduced-motion` support.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Adding a New Component
|
|
321
|
+
|
|
322
|
+
1. Create `src/components/<name>.tsx`
|
|
323
|
+
2. Use CVA for variant composition (if the component has variants)
|
|
324
|
+
3. Use `cn()` for all class merging
|
|
325
|
+
4. Forward refs with `React.forwardRef`
|
|
326
|
+
5. Add `data-ds`, `data-ds-component`, and relevant `data-ds-*` state attributes
|
|
327
|
+
6. Export from `src/components/index.ts`
|
|
328
|
+
7. Re-export from `src/index.ts`
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Version
|
|
333
|
+
|
|
334
|
+
Check the installed version programmatically:
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { UNIFIED_UI_VERSION } from "@work-rjkashyap/unified-ui";
|
|
338
|
+
console.log(UNIFIED_UI_VERSION); // "0.1.0"
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Troubleshooting
|
|
344
|
+
|
|
345
|
+
### `bg-ds-primary` and other Tailwind utilities aren't working
|
|
346
|
+
|
|
347
|
+
Make sure you import the CSS **after** `@import "tailwindcss"` in your global stylesheet. The `@theme` block must be processed by Tailwind.
|
|
348
|
+
|
|
349
|
+
### Fonts aren't loading
|
|
350
|
+
|
|
351
|
+
Verify that the CSS variables (`--font-outfit`, `--font-inter`, etc.) are applied to the `<html>` element. Inspect with DevTools → Computed Styles.
|
|
352
|
+
|
|
353
|
+
### Dark mode isn't switching
|
|
354
|
+
|
|
355
|
+
Unified UI uses the `.dark` class on `<html>` for dark mode. Ensure your theme provider toggles this class.
|
|
356
|
+
|
|
357
|
+
### Bundle size is larger than expected
|
|
358
|
+
|
|
359
|
+
Use layer-specific imports (`@work-rjkashyap/unified-ui/components`) instead of the barrel import to improve tree-shaking.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## License
|
|
364
|
+
|
|
365
|
+
MIT © [Rajeshwar Kashyap](https://github.com/work-rjkashyap)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/tokens/spacing.ts
|
|
4
|
+
var spacing = {
|
|
5
|
+
0: "0px",
|
|
6
|
+
px: "1px",
|
|
7
|
+
0.5: "2px",
|
|
8
|
+
1: "4px",
|
|
9
|
+
1.5: "6px",
|
|
10
|
+
2: "8px",
|
|
11
|
+
2.5: "10px",
|
|
12
|
+
3: "12px",
|
|
13
|
+
3.5: "14px",
|
|
14
|
+
4: "16px",
|
|
15
|
+
5: "20px",
|
|
16
|
+
6: "24px",
|
|
17
|
+
7: "28px",
|
|
18
|
+
8: "32px",
|
|
19
|
+
9: "36px",
|
|
20
|
+
10: "40px",
|
|
21
|
+
11: "44px",
|
|
22
|
+
12: "48px",
|
|
23
|
+
14: "56px",
|
|
24
|
+
16: "64px",
|
|
25
|
+
20: "80px",
|
|
26
|
+
24: "96px"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.spacing = spacing;
|