@tachui/responsive 0.8.0-alpha

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 (31) hide show
  1. package/LICENSE +363 -0
  2. package/README.md +507 -0
  3. package/dist/index.d.ts +11 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +2538 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/modifiers/index.d.ts +5 -0
  8. package/dist/modifiers/index.d.ts.map +1 -0
  9. package/dist/modifiers/responsive/advanced-utilities.d.ts +121 -0
  10. package/dist/modifiers/responsive/advanced-utilities.d.ts.map +1 -0
  11. package/dist/modifiers/responsive/breakpoints.d.ts +81 -0
  12. package/dist/modifiers/responsive/breakpoints.d.ts.map +1 -0
  13. package/dist/modifiers/responsive/css-generator.d.ts +100 -0
  14. package/dist/modifiers/responsive/css-generator.d.ts.map +1 -0
  15. package/dist/modifiers/responsive/dev-tools.d.ts +107 -0
  16. package/dist/modifiers/responsive/dev-tools.d.ts.map +1 -0
  17. package/dist/modifiers/responsive/index.d.ts +29 -0
  18. package/dist/modifiers/responsive/index.d.ts.map +1 -0
  19. package/dist/modifiers/responsive/layout-patterns.d.ts +230 -0
  20. package/dist/modifiers/responsive/layout-patterns.d.ts.map +1 -0
  21. package/dist/modifiers/responsive/performance.d.ts +130 -0
  22. package/dist/modifiers/responsive/performance.d.ts.map +1 -0
  23. package/dist/modifiers/responsive/responsive-builder.d.ts +133 -0
  24. package/dist/modifiers/responsive/responsive-builder.d.ts.map +1 -0
  25. package/dist/modifiers/responsive/responsive-modifier.d.ts +123 -0
  26. package/dist/modifiers/responsive/responsive-modifier.d.ts.map +1 -0
  27. package/dist/modifiers/responsive/types.d.ts +183 -0
  28. package/dist/modifiers/responsive/types.d.ts.map +1 -0
  29. package/dist/modifiers/responsive/utilities.d.ts +149 -0
  30. package/dist/modifiers/responsive/utilities.d.ts.map +1 -0
  31. package/package.json +73 -0
package/README.md ADDED
@@ -0,0 +1,507 @@
1
+ # @tachui/responsive
2
+
3
+ Responsive design utilities for tachUI applications with breakpoint management and adaptive layouts.
4
+
5
+ ## Overview
6
+
7
+ The `@tachui/responsive` package provides comprehensive responsive design capabilities for tachUI applications. Build interfaces that automatically adapt to different screen sizes, orientations, and device capabilities with SwiftUI-inspired responsive modifiers.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @tachui/responsive@0.8.0-alpha
13
+ # or
14
+ pnpm add @tachui/responsive@0.8.0-alpha
15
+ ```
16
+
17
+ ## Core Features
18
+
19
+ ### Breakpoint System
20
+
21
+ Built-in breakpoint system with customizable breakpoints:
22
+
23
+ ```typescript
24
+ import { useBreakpoint, breakpoints } from '@tachui/responsive'
25
+
26
+ // Default breakpoints
27
+ const currentBreakpoint = useBreakpoint()
28
+ // Returns: 'mobile' | 'tablet' | 'desktop' | 'wide'
29
+
30
+ // Breakpoint values
31
+ console.log(breakpoints)
32
+ // {
33
+ // mobile: 0,
34
+ // tablet: 768,
35
+ // desktop: 1024,
36
+ // wide: 1440
37
+ // }
38
+ ```
39
+
40
+ ### Responsive Values
41
+
42
+ Use responsive values throughout your application:
43
+
44
+ ```typescript
45
+ import { VStack, Text } from '@tachui/primitives'
46
+
47
+ VStack({
48
+ spacing: {
49
+ mobile: 8,
50
+ tablet: 12,
51
+ desktop: 16,
52
+ wide: 20,
53
+ },
54
+ children: [
55
+ Text('Responsive Title')
56
+ .modifier.fontSize({
57
+ mobile: 24,
58
+ tablet: 28,
59
+ desktop: 32,
60
+ wide: 36,
61
+ })
62
+ .padding({
63
+ mobile: 16,
64
+ tablet: 20,
65
+ desktop: 24,
66
+ })
67
+ .build(),
68
+ ],
69
+ })
70
+ ```
71
+
72
+ ## Responsive Modifiers
73
+
74
+ ### Size and Spacing
75
+
76
+ ```typescript
77
+ Text('Adaptive Content')
78
+ .modifier.padding({
79
+ mobile: 12,
80
+ desktop: 20,
81
+ })
82
+ .margin({
83
+ mobile: { vertical: 8 },
84
+ desktop: { vertical: 16 },
85
+ })
86
+ .width({
87
+ mobile: '100%',
88
+ tablet: '80%',
89
+ desktop: '60%',
90
+ })
91
+ .build()
92
+ ```
93
+
94
+ ### Layout Adaptations
95
+
96
+ ```typescript
97
+ // Responsive stack direction
98
+ VStack({
99
+ direction: {
100
+ mobile: 'vertical',
101
+ tablet: 'horizontal',
102
+ },
103
+ children: [Text('Item 1'), Text('Item 2'), Text('Item 3')],
104
+ })
105
+ ```
106
+
107
+ ### Typography Scaling
108
+
109
+ ```typescript
110
+ Text('Responsive Typography')
111
+ .modifier.font({
112
+ mobile: { size: 16, weight: 400 },
113
+ tablet: { size: 18, weight: 500 },
114
+ desktop: { size: 20, weight: 600 },
115
+ })
116
+ .lineHeight({
117
+ mobile: 1.4,
118
+ desktop: 1.6,
119
+ })
120
+ .textAlign({
121
+ mobile: 'left',
122
+ tablet: 'center',
123
+ })
124
+ .build()
125
+ ```
126
+
127
+ ## Responsive Components
128
+
129
+ ### ResponsiveContainer
130
+
131
+ A container that applies responsive behavior to its children:
132
+
133
+ ```typescript
134
+ import { ResponsiveContainer } from '@tachui/responsive'
135
+
136
+ ResponsiveContainer({
137
+ breakpoints: {
138
+ mobile: 320,
139
+ tablet: 768,
140
+ desktop: 1024,
141
+ },
142
+ children: [Text('This content adapts to container size')],
143
+ })
144
+ ```
145
+
146
+ ### MediaQuery
147
+
148
+ Component for conditional rendering based on media queries:
149
+
150
+ ```typescript
151
+ import { MediaQuery } from '@tachui/responsive'
152
+
153
+ VStack({
154
+ children: [
155
+ MediaQuery({
156
+ query: 'min-width: 768px',
157
+ children: Text('Only visible on tablet and up'),
158
+ }),
159
+
160
+ MediaQuery({
161
+ query: 'max-width: 767px',
162
+ children: Text('Only visible on mobile'),
163
+ }),
164
+ ],
165
+ })
166
+ ```
167
+
168
+ ### ViewportSize
169
+
170
+ Hook and component for viewport-based logic:
171
+
172
+ ```typescript
173
+ import { useViewportSize, ViewportSize } from '@tachui/responsive'
174
+
175
+ // As a hook
176
+ const viewportSize = useViewportSize()
177
+ const isMobile = () => viewportSize().width < 768
178
+
179
+ // As a component
180
+ ViewportSize({
181
+ render: size => Text(`Viewport: ${size.width}x${size.height}`),
182
+ })
183
+ ```
184
+
185
+ ## Device Detection
186
+
187
+ ### Device Type Detection
188
+
189
+ ```typescript
190
+ import { useDeviceType, DeviceType } from '@tachui/responsive'
191
+
192
+ const deviceType = useDeviceType()
193
+
194
+ VStack({
195
+ children: [
196
+ Show({
197
+ when: () => deviceType() === 'mobile',
198
+ children: MobileNavigation(),
199
+ }),
200
+
201
+ Show({
202
+ when: () => deviceType() === 'desktop',
203
+ children: DesktopNavigation(),
204
+ }),
205
+ ],
206
+ })
207
+ ```
208
+
209
+ ### Orientation Support
210
+
211
+ ```typescript
212
+ import { useOrientation } from '@tachui/responsive'
213
+
214
+ const orientation = useOrientation()
215
+
216
+ HStack({
217
+ direction: () => (orientation() === 'landscape' ? 'horizontal' : 'vertical'),
218
+ children: [
219
+ Text('Adapts to orientation'),
220
+ Text('Portrait: vertical, Landscape: horizontal'),
221
+ ],
222
+ })
223
+ ```
224
+
225
+ ## Advanced Responsive Patterns
226
+
227
+ ### Container Queries
228
+
229
+ Use container-based responsive design:
230
+
231
+ ```typescript
232
+ import { ContainerQuery } from '@tachui/responsive'
233
+
234
+ ContainerQuery({
235
+ container: 'cardContainer',
236
+ query: 'min-width: 300px',
237
+ children: VStack({
238
+ children: [
239
+ Text('Card expands when container is wide enough')
240
+ .modifier.fontSize(18)
241
+ .build(),
242
+ ],
243
+ })
244
+ .modifier.container('cardContainer')
245
+ .build(),
246
+ })
247
+ ```
248
+
249
+ ### Responsive Grid
250
+
251
+ ```typescript
252
+ import { Grid } from '@tachui/grid'
253
+
254
+ Grid({
255
+ columns: {
256
+ mobile: 1,
257
+ tablet: 2,
258
+ desktop: 3,
259
+ wide: 4,
260
+ },
261
+ gap: {
262
+ mobile: 12,
263
+ desktop: 20,
264
+ },
265
+ children: items.map(item =>
266
+ Card({ title: item.title, content: item.content })
267
+ ),
268
+ })
269
+ ```
270
+
271
+ ### Adaptive Navigation
272
+
273
+ ```typescript
274
+ const navigationStyle = {
275
+ mobile: 'bottom-tabs',
276
+ tablet: 'sidebar',
277
+ desktop: 'top-nav',
278
+ }
279
+
280
+ Show({
281
+ when: () => useBreakpoint() === 'mobile',
282
+ children: BottomTabNavigation(),
283
+ fallback: Show({
284
+ when: () => useBreakpoint() === 'tablet',
285
+ children: SidebarNavigation(),
286
+ fallback: TopNavigation(),
287
+ }),
288
+ })
289
+ ```
290
+
291
+ ## Responsive Utilities
292
+
293
+ ### Breakpoint Helpers
294
+
295
+ ```typescript
296
+ import {
297
+ isMobile,
298
+ isTablet,
299
+ isDesktop,
300
+ atLeast,
301
+ atMost,
302
+ between,
303
+ } from '@tachui/responsive'
304
+
305
+ // Simple checks
306
+ if (isMobile()) {
307
+ // Mobile-specific logic
308
+ }
309
+
310
+ // Range checks
311
+ if (atLeast('tablet')) {
312
+ // Tablet and above
313
+ }
314
+
315
+ if (between('tablet', 'desktop')) {
316
+ // Only tablet and desktop, not mobile or wide
317
+ }
318
+ ```
319
+
320
+ ### Responsive Values Helper
321
+
322
+ ```typescript
323
+ import { responsive } from '@tachui/responsive'
324
+
325
+ const spacing = responsive({
326
+ mobile: 8,
327
+ tablet: 12,
328
+ desktop: 16,
329
+ })
330
+
331
+ // Use in components
332
+ VStack({ spacing })
333
+ ```
334
+
335
+ ### CSS-in-JS Integration
336
+
337
+ ```typescript
338
+ import { createResponsiveStyles } from '@tachui/responsive'
339
+
340
+ const buttonStyles = createResponsiveStyles({
341
+ mobile: {
342
+ fontSize: 14,
343
+ padding: '8px 16px',
344
+ },
345
+ desktop: {
346
+ fontSize: 16,
347
+ padding: '12px 24px',
348
+ },
349
+ })
350
+
351
+ Button('Responsive Button').modifier.css(buttonStyles()).build()
352
+ ```
353
+
354
+ ## Performance Optimization
355
+
356
+ ### Efficient Re-renders
357
+
358
+ ```typescript
359
+ // Reactive responsive values with minimal re-renders
360
+ const fontSize = createMemo(() => {
361
+ const bp = useBreakpoint()
362
+ switch (bp()) {
363
+ case 'mobile':
364
+ return 14
365
+ case 'tablet':
366
+ return 16
367
+ case 'desktop':
368
+ return 18
369
+ default:
370
+ return 20
371
+ }
372
+ })
373
+
374
+ Text('Optimized Text').modifier.fontSize(fontSize).build()
375
+ ```
376
+
377
+ ### Lazy Loading
378
+
379
+ ```typescript
380
+ import { LazyBreakpoint } from '@tachui/responsive'
381
+
382
+ LazyBreakpoint({
383
+ breakpoint: 'desktop',
384
+ children: ExpensiveDesktopComponent,
385
+ fallback: MobileComponent,
386
+ })
387
+ ```
388
+
389
+ ## Integration Examples
390
+
391
+ ### With Navigation
392
+
393
+ ```typescript
394
+ import { NavigationView } from '@tachui/navigation'
395
+
396
+ NavigationView({
397
+ navigationStyle: {
398
+ mobile: 'stack',
399
+ tablet: 'split',
400
+ desktop: 'sidebar',
401
+ },
402
+ children: [HomePage(), ProfilePage(), SettingsPage()],
403
+ })
404
+ ```
405
+
406
+ ### With Forms
407
+
408
+ ```typescript
409
+ import { Form, TextField } from '@tachui/forms'
410
+
411
+ Form({
412
+ layout: {
413
+ mobile: 'vertical',
414
+ desktop: 'horizontal',
415
+ },
416
+ children: [
417
+ TextField({
418
+ label: 'Name',
419
+ width: {
420
+ mobile: '100%',
421
+ desktop: '50%',
422
+ },
423
+ }),
424
+ TextField({
425
+ label: 'Email',
426
+ width: {
427
+ mobile: '100%',
428
+ desktop: '50%',
429
+ },
430
+ }),
431
+ ],
432
+ })
433
+ ```
434
+
435
+ ## Custom Breakpoints
436
+
437
+ Define custom breakpoints for your application:
438
+
439
+ ```typescript
440
+ import { createBreakpoints } from '@tachui/responsive'
441
+
442
+ const customBreakpoints = createBreakpoints({
443
+ xs: 0,
444
+ sm: 576,
445
+ md: 768,
446
+ lg: 992,
447
+ xl: 1200,
448
+ xxl: 1400,
449
+ })
450
+
451
+ // Use custom breakpoints
452
+ Text('Custom responsive')
453
+ .modifier.fontSize({
454
+ xs: 12,
455
+ sm: 14,
456
+ md: 16,
457
+ lg: 18,
458
+ xl: 20,
459
+ xxl: 24,
460
+ })
461
+ .build()
462
+ ```
463
+
464
+ ## Server-Side Rendering (SSR)
465
+
466
+ SSR-safe responsive utilities:
467
+
468
+ ```typescript
469
+ import { ServerResponsiveProvider } from '@tachui/responsive'
470
+
471
+ // On the server
472
+ ServerResponsiveProvider({
473
+ userAgent: request.userAgent,
474
+ viewport: { width: 1024, height: 768 },
475
+ children: App(),
476
+ })
477
+ ```
478
+
479
+ ## Accessibility Considerations
480
+
481
+ - **Reduced Motion**: Respects user's motion preferences
482
+ - **High Contrast**: Adapts to high contrast mode
483
+ - **Screen Reader**: Provides appropriate breakpoint information
484
+
485
+ ```typescript
486
+ Text('Accessible responsive content')
487
+ .modifier.fontSize({
488
+ mobile: 16,
489
+ desktop: 18,
490
+ })
491
+ .accessibilityLabel(() => `Text size adapts to ${useBreakpoint()} screen`)
492
+ .build()
493
+ ```
494
+
495
+ ## Browser Support
496
+
497
+ - Modern browsers with CSS3 media query support
498
+ - Graceful fallback for older browsers
499
+ - Progressive enhancement for advanced features
500
+
501
+ ## Contributing
502
+
503
+ See the [contributing guide](../../CONTRIBUTING.md) for information on extending the responsive system.
504
+
505
+ ## License
506
+
507
+ This package is part of the tachUI framework and is licensed under the MPL-2.0 License.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @tachui/responsive - Advanced Responsive Design Plugin
3
+ *
4
+ * Advanced responsive design utilities that extend the core responsive system
5
+ * with sophisticated breakpoint management, responsive typography, container queries,
6
+ * and adaptive component behaviors.
7
+ */
8
+ export * from './modifiers/responsive';
9
+ export type { ResponsiveValue, BreakpointKey, ResponsiveStyleConfig, ResponsiveModifierResult, BreakpointConfig, } from './modifiers/responsive/types';
10
+ export { createResponsiveModifier, ResponsiveCSSGenerator, CSSInjector, configureBreakpoints, useBreakpoint, useMediaQuery, useResponsiveValue, DEFAULT_BREAKPOINTS, } from './modifiers/responsive';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,wBAAwB,CAAA;AAGtC,YAAY,EACV,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,8BAA8B,CAAA;AAGrC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,wBAAwB,CAAA"}