@titan-design/react-ui 0.0.1

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 ADDED
@@ -0,0 +1,319 @@
1
+ # @titan-design/react-ui
2
+
3
+ A cross-platform design system built on React Native primitives with NativeWind (Tailwind CSS). Works on web and React Native.
4
+
5
+ ## Features
6
+
7
+ - **Cross-platform**: Components work on web (via react-native-web) and React Native
8
+ - **Dark mode first**: Dark theme by default with light mode support
9
+ - **Accessible**: Built with accessibility in mind (WCAG 2.1 AA)
10
+ - **Customizable**: Theme tokens and component styles are easy to override
11
+ - **Type-safe**: Full TypeScript support with strict mode
12
+ - **Compound components**: Flexible composition following Gluestack patterns
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @titan-design/react-ui
18
+ ```
19
+
20
+ ### Peer Dependencies
21
+
22
+ ```bash
23
+ # For web
24
+ pnpm add react react-dom react-native-web lucide-react
25
+
26
+ # For React Native
27
+ pnpm add react react-native lucide-react-native
28
+ ```
29
+
30
+ ## Setup
31
+
32
+ ### 1. Import Global CSS
33
+
34
+ ```tsx
35
+ // App.tsx or entry point
36
+ import '@titan-design/react-ui/theme/global.css'
37
+ ```
38
+
39
+ ### 2. Configure Tailwind (optional, for custom styling)
40
+
41
+ ```javascript
42
+ // tailwind.config.js
43
+ module.exports = {
44
+ content: [
45
+ './src/**/*.{js,jsx,ts,tsx}',
46
+ './node_modules/@titan-design/react-ui/dist/**/*.{js,mjs}',
47
+ ],
48
+ presets: [require('nativewind/preset')],
49
+ // Your customizations...
50
+ }
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ```tsx
56
+ import {
57
+ Button,
58
+ ButtonText,
59
+ ButtonIcon,
60
+ Typography,
61
+ Card,
62
+ CardHeader,
63
+ CardTitle,
64
+ CardContent,
65
+ Input,
66
+ InputGroup,
67
+ } from '@titan-design/react-ui'
68
+ import { Plus } from 'lucide-react'
69
+
70
+ function App() {
71
+ return (
72
+ <Card variant="elevated">
73
+ <CardHeader>
74
+ <CardTitle>Welcome</CardTitle>
75
+ </CardHeader>
76
+ <CardContent className="gap-4">
77
+ <Typography variant="body1">
78
+ This is a cross-platform card component.
79
+ </Typography>
80
+
81
+ <InputGroup>
82
+ <Input
83
+ placeholder="Enter your email"
84
+ label="Email"
85
+ />
86
+ </InputGroup>
87
+
88
+ <Button color="primary" variant="solid">
89
+ <ButtonIcon as={Plus} />
90
+ <ButtonText>Get Started</ButtonText>
91
+ </Button>
92
+ </CardContent>
93
+ </Card>
94
+ )
95
+ }
96
+ ```
97
+
98
+ ## Components
99
+
100
+ ### Core UI Components
101
+
102
+ | Component | Description |
103
+ |-----------|-------------|
104
+ | **Button** | Primary action component with variants: solid, outline, ghost, link |
105
+ | **Input** | Text input with label, helper text, and error states |
106
+ | **Card** | Container component with header, content, footer |
107
+ | **Badge** | Status indicator labels |
108
+ | **Spinner** | Loading indicator |
109
+ | **Avatar** | User/entity representation |
110
+ | **Divider** | Visual separator |
111
+ | **Checkbox** | Boolean input with group support |
112
+ | **Switch** | Toggle input |
113
+ | **Modal** | Dialog/overlay component |
114
+
115
+ ### Custom Components
116
+
117
+ | Component | Description |
118
+ |-----------|-------------|
119
+ | **Typography** | Consistent text styling (h1-h6, body, caption, etc.) |
120
+ | **Sidebar** | Navigation sidebar with collapsible support |
121
+ | **Table** | Data table with sorting and pagination |
122
+ | **EmptyState** | Placeholder for empty data states |
123
+
124
+ ## Component API
125
+
126
+ ### Button
127
+
128
+ ```tsx
129
+ <Button
130
+ variant="solid" | "outline" | "ghost" | "link"
131
+ color="primary" | "secondary" | "success" | "error" | "warning" | "info"
132
+ size="sm" | "md" | "lg"
133
+ isDisabled={false}
134
+ isLoading={false}
135
+ onPress={() => {}}
136
+ >
137
+ <ButtonIcon as={IconComponent} />
138
+ <ButtonText>Button Text</ButtonText>
139
+ </Button>
140
+ ```
141
+
142
+ ### Input
143
+
144
+ ```tsx
145
+ <Input
146
+ label="Field Label"
147
+ placeholder="Placeholder text"
148
+ helperText="Helper text"
149
+ errorMessage="Error message"
150
+ variant="outline" | "filled" | "underlined"
151
+ size="sm" | "md" | "lg"
152
+ isDisabled={false}
153
+ isInvalid={false}
154
+ isReadOnly={false}
155
+ isRequired={false}
156
+ value={value}
157
+ onChangeText={setValue}
158
+ />
159
+ ```
160
+
161
+ ### Typography
162
+
163
+ ```tsx
164
+ <Typography
165
+ variant="h1" | "h2" | "h3" | "h4" | "h5" | "h6" |
166
+ "body1" | "body2" | "caption" | "overline"
167
+ color="primary" | "secondary" | "tertiary" | "disabled"
168
+ >
169
+ Text content
170
+ </Typography>
171
+ ```
172
+
173
+ ### Card
174
+
175
+ ```tsx
176
+ <Card variant="default" | "elevated" | "outline" | "filled">
177
+ <CardHeader>
178
+ <CardTitle>Title</CardTitle>
179
+ </CardHeader>
180
+ <CardContent>
181
+ Content here
182
+ </CardContent>
183
+ <CardFooter>
184
+ <Button>Action</Button>
185
+ </CardFooter>
186
+ </Card>
187
+ ```
188
+
189
+ ## Theme
190
+
191
+ The design system uses CSS custom properties for theming. Dark mode is the default.
192
+
193
+ ### Using the Theme
194
+
195
+ Import the global CSS in your app:
196
+
197
+ ```tsx
198
+ import '@titan-design/react-ui/theme/global.css'
199
+ ```
200
+
201
+ ### Switching Themes
202
+
203
+ Add the `light` class to your root element for light mode:
204
+
205
+ ```tsx
206
+ // Dark mode (default)
207
+ <div>
208
+ {/* Your app */}
209
+ </div>
210
+
211
+ // Light mode
212
+ <div className="light">
213
+ {/* Your app */}
214
+ </div>
215
+ ```
216
+
217
+ ### Programmatic Theme Switching
218
+
219
+ ```tsx
220
+ function toggleTheme() {
221
+ document.documentElement.classList.toggle('light')
222
+ }
223
+ ```
224
+
225
+ ## Design Tokens
226
+
227
+ The design system uses a two-tier token system following DTCG conventions:
228
+
229
+ ### Token Categories
230
+
231
+ | Category | Pattern | Description |
232
+ |----------|---------|-------------|
233
+ | `brand-*` | `brand-primary`, `brand-secondary` | Brand identity colors |
234
+ | `status-*` | `status-success`, `status-error`, `status-warning`, `status-info` | Feedback colors |
235
+ | `text-*` | `text-primary`, `text-secondary`, `text-tertiary` | Text hierarchy |
236
+ | `surface-*` | `surface-base`, `surface-elevated`, `surface-raised` | Container backgrounds |
237
+ | `background-*` | `background-base`, `background-default` | Page backgrounds |
238
+ | `border-*` | `border-default`, `border-subtle`, `border-strong` | Border colors |
239
+ | `interactive-*` | `interactive-hover`, `interactive-focus`, `interactive-active` | State colors |
240
+
241
+ ### Using Tokens
242
+
243
+ ```tsx
244
+ // In components
245
+ <View className="bg-surface-elevated border border-border-default rounded-lg">
246
+ <Text className="text-text-primary">Primary text</Text>
247
+ <Text className="text-text-secondary">Secondary text</Text>
248
+ </View>
249
+ ```
250
+
251
+ ## Development
252
+
253
+ ### Storybook
254
+
255
+ ```bash
256
+ pnpm storybook
257
+ ```
258
+
259
+ Open [http://localhost:6006](http://localhost:6006) to view component documentation.
260
+
261
+ ### Testing
262
+
263
+ ```bash
264
+ # Run tests
265
+ pnpm test
266
+
267
+ # Run tests with coverage
268
+ pnpm test:coverage
269
+ ```
270
+
271
+ ### Build
272
+
273
+ ```bash
274
+ pnpm build
275
+ ```
276
+
277
+ ## Storybook Configuration
278
+
279
+ This package uses Storybook 10 with `@storybook/react-native-web-vite` for proper NativeWind support. Key configuration:
280
+
281
+ ```typescript
282
+ // .storybook/main.ts
283
+ framework: {
284
+ name: '@storybook/react-native-web-vite',
285
+ options: {
286
+ pluginReactOptions: {
287
+ jsxImportSource: 'nativewind',
288
+ },
289
+ },
290
+ }
291
+ ```
292
+
293
+ See the [Storybook Setup Guide](../../docs/STORYBOOK_SETUP.md) for detailed configuration.
294
+
295
+ ## Cross-Platform Notes
296
+
297
+ ### React Native Primitives
298
+
299
+ All components use React Native primitives for cross-platform compatibility:
300
+
301
+ | Web Element | React Native Equivalent |
302
+ |-------------|------------------------|
303
+ | `div` | `View` |
304
+ | `span`, `p` | `Text` |
305
+ | `button` | `Pressable` |
306
+ | `input` | `TextInput` |
307
+ | `img` | `Image` |
308
+
309
+ ### Platform-Specific Styles
310
+
311
+ Use NativeWind platform modifiers when needed:
312
+
313
+ ```tsx
314
+ <View className="p-4 web:hover:bg-gray-100 native:active:opacity-80">
315
+ ```
316
+
317
+ ## License
318
+
319
+ MIT