@idealyst/navigation 1.0.62 → 1.0.64

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.
@@ -1,498 +0,0 @@
1
- # GeneralLayout Component
2
-
3
- A flexible, responsive layout component with configurable header and sidebar support, perfect for desktop applications and admin interfaces.
4
-
5
- ## Features
6
-
7
- - ✅ Cross-platform (React & React Native)
8
- - ✅ Configurable header with custom content
9
- - ✅ Collapsible sidebar with left/right positioning
10
- - ✅ Responsive design with breakpoint support
11
- - ✅ Theme integration with @idealyst/theme
12
- - ✅ TypeScript support with comprehensive prop types
13
-
14
- ## Basic Usage
15
-
16
- ```tsx
17
- import { GeneralLayout } from '@idealyst/navigation';
18
- import { Text, Button } from '@idealyst/components';
19
-
20
- <GeneralLayout
21
- header={{
22
- enabled: true,
23
- content: <Text>My Application</Text>,
24
- }}
25
- sidebar={{
26
- enabled: true,
27
- content: <NavigationMenu />,
28
- }}
29
- >
30
- <MainContent />
31
- </GeneralLayout>
32
- ```
33
-
34
- ## Props
35
-
36
- ### GeneralLayoutProps
37
-
38
- | Prop | Type | Default | Description |
39
- |------|------|---------|-------------|
40
- | `children` | `ReactNode` | - | Main content to display in the layout |
41
- | `header` | `HeaderConfig` | - | Header configuration object |
42
- | `sidebar` | `SidebarConfig` | - | Sidebar configuration object |
43
- | `style` | `ViewStyle` | - | Additional styles for the layout container |
44
- | `testID` | `string` | - | Test identifier for testing |
45
-
46
- ## Header Configuration
47
-
48
- ### HeaderConfig
49
-
50
- Configure the layout header with custom content and styling.
51
-
52
- ```tsx
53
- interface HeaderConfig {
54
- enabled?: boolean; // Show/hide header
55
- height?: number; // Header height in pixels
56
- content?: ReactNode; // Header content
57
- style?: any; // Custom header styles
58
- }
59
- ```
60
-
61
- ### Header Examples
62
-
63
- ```tsx
64
- // Basic header
65
- <GeneralLayout
66
- header={{
67
- enabled: true,
68
- content: <Text size="large" weight="bold">Dashboard</Text>,
69
- }}
70
- >
71
- {children}
72
- </GeneralLayout>
73
-
74
- // Header with navigation and actions
75
- <GeneralLayout
76
- header={{
77
- enabled: true,
78
- height: 64,
79
- content: (
80
- <View style={{
81
- flexDirection: 'row',
82
- justifyContent: 'space-between',
83
- alignItems: 'center',
84
- paddingHorizontal: 16
85
- }}>
86
- <Text size="large" weight="bold">My App</Text>
87
- <View style={{ flexDirection: 'row', gap: 8 }}>
88
- <Button variant="outlined" size="small">Settings</Button>
89
- <Button variant="contained" size="small">Profile</Button>
90
- </View>
91
- </View>
92
- ),
93
- style: {
94
- backgroundColor: '#f8f9fa',
95
- borderBottomWidth: 1,
96
- borderBottomColor: '#e9ecef',
97
- },
98
- }}
99
- >
100
- {children}
101
- </GeneralLayout>
102
-
103
- // Responsive header
104
- <GeneralLayout
105
- header={{
106
- enabled: true,
107
- content: (
108
- <View style={{
109
- flexDirection: 'row',
110
- alignItems: 'center',
111
- justifyContent: 'space-between',
112
- paddingHorizontal: 16,
113
- }}>
114
- <Text size="large" weight="bold">Dashboard</Text>
115
- {/* Show different content based on screen size */}
116
- <View style={{ flexDirection: 'row' }}>
117
- <Button size="small">Action</Button>
118
- </View>
119
- </View>
120
- ),
121
- }}
122
- >
123
- {children}
124
- </GeneralLayout>
125
- ```
126
-
127
- ## Sidebar Configuration
128
-
129
- ### SidebarConfig
130
-
131
- Configure a collapsible sidebar with custom content and behavior.
132
-
133
- ```tsx
134
- interface SidebarConfig {
135
- enabled?: boolean; // Show/hide sidebar
136
- initiallyExpanded?: boolean; // Initial expanded state
137
- expandedWidth?: number; // Width when expanded (pixels)
138
- collapsedWidth?: number; // Width when collapsed (pixels)
139
- collapsible?: boolean; // Allow collapse/expand
140
- position?: 'left' | 'right'; // Sidebar position
141
- content?: ReactNode; // Sidebar content
142
- style?: any; // Custom sidebar styles
143
- }
144
- ```
145
-
146
- ### Sidebar Examples
147
-
148
- ```tsx
149
- // Basic sidebar
150
- <GeneralLayout
151
- sidebar={{
152
- enabled: true,
153
- content: (
154
- <View style={{ padding: 16 }}>
155
- <Text weight="bold">Navigation</Text>
156
- <Button variant="text">Dashboard</Button>
157
- <Button variant="text">Analytics</Button>
158
- <Button variant="text">Settings</Button>
159
- </View>
160
- ),
161
- }}
162
- >
163
- {children}
164
- </GeneralLayout>
165
-
166
- // Collapsible sidebar
167
- <GeneralLayout
168
- sidebar={{
169
- enabled: true,
170
- collapsible: true,
171
- initiallyExpanded: false,
172
- expandedWidth: 250,
173
- collapsedWidth: 60,
174
- position: 'left',
175
- content: <NavigationSidebar />,
176
- }}
177
- >
178
- {children}
179
- </GeneralLayout>
180
-
181
- // Right-positioned sidebar
182
- <GeneralLayout
183
- sidebar={{
184
- enabled: true,
185
- position: 'right',
186
- expandedWidth: 300,
187
- content: (
188
- <View style={{ padding: 16 }}>
189
- <Text weight="bold">Inspector</Text>
190
- <Text>Properties and details</Text>
191
- </View>
192
- ),
193
- }}
194
- >
195
- {children}
196
- </GeneralLayout>
197
-
198
- // Styled sidebar
199
- <GeneralLayout
200
- sidebar={{
201
- enabled: true,
202
- collapsible: true,
203
- content: <CustomNavigation />,
204
- style: {
205
- backgroundColor: '#f8f9fa',
206
- borderRightWidth: 1,
207
- borderRightColor: '#e9ecef',
208
- },
209
- }}
210
- >
211
- {children}
212
- </GeneralLayout>
213
- ```
214
-
215
- ## Complete Layout Examples
216
-
217
- ### Dashboard Layout
218
-
219
- ```tsx
220
- import { GeneralLayout } from '@idealyst/navigation';
221
- import { Text, Button, View, Icon } from '@idealyst/components';
222
- import { useNavigator } from '@idealyst/navigation';
223
-
224
- const DashboardLayout: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
225
- const navigator = useNavigator();
226
-
227
- return (
228
- <GeneralLayout
229
- header={{
230
- enabled: true,
231
- height: 64,
232
- content: (
233
- <View style={{
234
- flexDirection: 'row',
235
- justifyContent: 'space-between',
236
- alignItems: 'center',
237
- paddingHorizontal: 24,
238
- }}>
239
- <Text size="large" weight="bold" color="inverse">
240
- Dashboard
241
- </Text>
242
- <View style={{ flexDirection: 'row', gap: 12 }}>
243
- <Button variant="outlined" size="small">
244
- <Icon name="bell" size="small" />
245
- </Button>
246
- <Button variant="contained" size="small">
247
- Profile
248
- </Button>
249
- </View>
250
- </View>
251
- ),
252
- }}
253
- sidebar={{
254
- enabled: true,
255
- collapsible: true,
256
- initiallyExpanded: true,
257
- expandedWidth: 240,
258
- collapsedWidth: 60,
259
- position: 'left',
260
- content: (
261
- <View style={{ padding: 16, gap: 8 }}>
262
- <Text weight="bold" size="small" color="secondary">
263
- NAVIGATION
264
- </Text>
265
- <Button
266
- variant="text"
267
- onPress={() => navigator.navigate({ path: "/dashboard", vars: {} })}
268
- >
269
- <Icon name="home" size="small" />
270
- Dashboard
271
- </Button>
272
- <Button
273
- variant="text"
274
- onPress={() => navigator.navigate({ path: "/analytics", vars: {} })}
275
- >
276
- <Icon name="chart-line" size="small" />
277
- Analytics
278
- </Button>
279
- <Button
280
- variant="text"
281
- onPress={() => navigator.navigate({ path: "/settings", vars: {} })}
282
- >
283
- <Icon name="settings" size="small" />
284
- Settings
285
- </Button>
286
- </View>
287
- ),
288
- }}
289
- >
290
- {children}
291
- </GeneralLayout>
292
- );
293
- };
294
- ```
295
-
296
- ### Admin Interface Layout
297
-
298
- ```tsx
299
- const AdminLayout: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
300
- const [isSidebarExpanded, setIsSidebarExpanded] = useState(true);
301
-
302
- return (
303
- <GeneralLayout
304
- header={{
305
- enabled: true,
306
- content: (
307
- <View style={{
308
- flexDirection: 'row',
309
- alignItems: 'center',
310
- justifyContent: 'space-between',
311
- paddingHorizontal: 16,
312
- }}>
313
- <View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
314
- <Button
315
- variant="text"
316
- onPress={() => setIsSidebarExpanded(!isSidebarExpanded)}
317
- >
318
- <Icon name="menu" />
319
- </Button>
320
- <Text size="large" weight="bold">Admin Panel</Text>
321
- </View>
322
- <UserMenu />
323
- </View>
324
- ),
325
- }}
326
- sidebar={{
327
- enabled: true,
328
- collapsible: true,
329
- initiallyExpanded: isSidebarExpanded,
330
- expandedWidth: 280,
331
- collapsedWidth: 0,
332
- content: <AdminNavigation />,
333
- }}
334
- >
335
- {children}
336
- </GeneralLayout>
337
- );
338
- };
339
- ```
340
-
341
- ### Content Editor Layout
342
-
343
- ```tsx
344
- const EditorLayout: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
345
- return (
346
- <GeneralLayout
347
- header={{
348
- enabled: true,
349
- height: 48,
350
- content: (
351
- <View style={{
352
- flexDirection: 'row',
353
- alignItems: 'center',
354
- paddingHorizontal: 16,
355
- gap: 12,
356
- }}>
357
- <Text weight="bold">Document Editor</Text>
358
- <View style={{ flexDirection: 'row', gap: 4 }}>
359
- <Button variant="text" size="small">
360
- <Icon name="save" size="small" />
361
- </Button>
362
- <Button variant="text" size="small">
363
- <Icon name="undo" size="small" />
364
- </Button>
365
- <Button variant="text" size="small">
366
- <Icon name="redo" size="small" />
367
- </Button>
368
- </View>
369
- </View>
370
- ),
371
- }}
372
- sidebar={{
373
- enabled: true,
374
- position: 'right',
375
- expandedWidth: 300,
376
- content: (
377
- <View style={{ padding: 16 }}>
378
- <Text weight="bold">Properties</Text>
379
- <PropertyPanel />
380
- </View>
381
- ),
382
- }}
383
- >
384
- {children}
385
- </GeneralLayout>
386
- );
387
- };
388
- ```
389
-
390
- ## Responsive Behavior
391
-
392
- The GeneralLayout automatically adapts to different screen sizes:
393
-
394
- ### Mobile (< 768px)
395
- - Header remains fixed at top
396
- - Sidebar collapses to overlay mode
397
- - Touch gestures enable sidebar open/close
398
-
399
- ### Tablet (768px - 1024px)
400
- - Header and sidebar both visible
401
- - Sidebar can be collapsed to save space
402
- - Content adapts to remaining space
403
-
404
- ### Desktop (> 1024px)
405
- - Full header and sidebar layout
406
- - Sidebar typically expanded by default
407
- - Maximum content real estate
408
-
409
- ## State Management
410
-
411
- The GeneralLayout includes built-in state management for sidebar collapse/expand:
412
-
413
- ```tsx
414
- // Internal state automatically manages:
415
- // - Sidebar expanded/collapsed state
416
- // - Responsive breakpoint handling
417
- // - Animation transitions
418
- // - Content area sizing
419
- ```
420
-
421
- ## Styling and Theming
422
-
423
- The layout integrates with @idealyst/theme for consistent styling:
424
-
425
- ```tsx
426
- // Custom styling
427
- <GeneralLayout
428
- header={{
429
- content: <HeaderContent />,
430
- style: {
431
- backgroundColor: theme.colors.surface.primary,
432
- borderBottomWidth: 1,
433
- borderBottomColor: theme.colors.border.subtle,
434
- },
435
- }}
436
- sidebar={{
437
- content: <SidebarContent />,
438
- style: {
439
- backgroundColor: theme.colors.surface.secondary,
440
- borderRightWidth: 1,
441
- borderRightColor: theme.colors.border.subtle,
442
- },
443
- }}
444
- style={{
445
- backgroundColor: theme.colors.background.primary,
446
- }}
447
- >
448
- {children}
449
- </GeneralLayout>
450
- ```
451
-
452
- ## Accessibility
453
-
454
- The GeneralLayout includes built-in accessibility features:
455
-
456
- - Proper focus management for sidebar toggle
457
- - Keyboard navigation support
458
- - Screen reader compatibility
459
- - Touch target sizing for mobile
460
- - Semantic HTML structure (web)
461
-
462
- ## Best Practices
463
-
464
- 1. **Keep Headers Simple**: Use headers for navigation and key actions only
465
- 2. **Sidebar Content**: Organize sidebar content with clear hierarchy
466
- 3. **Responsive Design**: Test layout across different screen sizes
467
- 4. **Performance**: Avoid complex content in collapsible sidebars
468
- 5. **Accessibility**: Ensure keyboard navigation works throughout
469
- 6. **Theme Consistency**: Use theme colors and spacing for visual consistency
470
-
471
- ## Usage with Navigation Routes
472
-
473
- ```tsx
474
- import { GeneralLayout } from '@idealyst/navigation';
475
- import { RouteParam } from '@idealyst/navigation';
476
-
477
- const AppLayout: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
478
- <GeneralLayout
479
- header={{ enabled: true, content: <AppHeader /> }}
480
- sidebar={{ enabled: true, content: <AppSidebar /> }}
481
- >
482
- {children}
483
- </GeneralLayout>
484
- );
485
-
486
- const AppRouter: RouteParam = {
487
- path: "/",
488
- component: DashboardScreen,
489
- layout: {
490
- type: "stack",
491
- component: AppLayout,
492
- },
493
- routes: [
494
- { path: "analytics", component: AnalyticsScreen },
495
- { path: "settings", component: SettingsScreen },
496
- ],
497
- };
498
- ```
@@ -1,2 +0,0 @@
1
- export { default as GeneralLayout } from './GeneralLayout';
2
- export type { GeneralLayoutProps, SidebarConfig, HeaderConfig } from './types';
@@ -1,99 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- export interface SidebarConfig {
4
- /**
5
- * Whether the sidebar is enabled
6
- */
7
- enabled?: boolean;
8
-
9
- /**
10
- * Whether the sidebar is initially expanded
11
- */
12
- initiallyExpanded?: boolean;
13
-
14
- /**
15
- * Width of the sidebar when expanded
16
- */
17
- expandedWidth?: number;
18
-
19
- /**
20
- * Width of the sidebar when collapsed
21
- */
22
- collapsedWidth?: number;
23
-
24
- /**
25
- * Whether the sidebar can be collapsed
26
- */
27
- collapsible?: boolean;
28
-
29
- /**
30
- * Position of the sidebar
31
- */
32
- position?: 'left' | 'right';
33
-
34
- /**
35
- * Content to display in the sidebar
36
- */
37
- content?: ReactNode;
38
-
39
- /**
40
- * Custom styles for the sidebar
41
- */
42
- style?: any;
43
- }
44
-
45
- export interface HeaderConfig {
46
- /**
47
- * Whether the header is enabled
48
- */
49
- enabled?: boolean;
50
-
51
- /**
52
- * Height of the header
53
- */
54
- height?: number;
55
-
56
- /**
57
- * Content to display in the header
58
- */
59
- content?: ReactNode;
60
-
61
- /**
62
- * Custom styles for the header
63
- */
64
- style?: any;
65
- }
66
-
67
- export interface GeneralLayoutProps {
68
- /**
69
- * The main content to display
70
- */
71
- children?: ReactNode;
72
-
73
- /**
74
- * Sidebar configuration
75
- */
76
- sidebar?: SidebarConfig;
77
-
78
- /**
79
- * Header configuration
80
- */
81
- header?: HeaderConfig;
82
-
83
- /**
84
- * Additional styles for the layout container
85
- */
86
- style?: any;
87
-
88
- /**
89
- * Test ID for testing
90
- */
91
- testID?: string;
92
- }
93
-
94
- export interface GeneralLayoutState {
95
- /**
96
- * Whether the sidebar is currently expanded
97
- */
98
- isSidebarExpanded: boolean;
99
- }