@djangocfg/layouts 1.2.17 → 1.2.19
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/package.json +5 -5
- package/src/layouts/AppLayout/components/PackageVersions/packageVersions.config.ts +8 -8
- package/src/layouts/UILayout/SUMMARY.md +298 -0
- package/src/layouts/UILayout/components/index.ts +15 -0
- package/src/layouts/UILayout/components/layout/Header/CopyAIButton.tsx +58 -0
- package/src/layouts/UILayout/components/layout/Header/Header.tsx +53 -0
- package/src/layouts/UILayout/components/layout/Header/HeaderDesktop.tsx +44 -0
- package/src/layouts/UILayout/components/layout/Header/HeaderMobile.tsx +71 -0
- package/src/layouts/UILayout/components/layout/Header/index.ts +9 -0
- package/src/layouts/UILayout/components/layout/MobileOverlay/MobileOverlay.tsx +46 -0
- package/src/layouts/UILayout/components/layout/MobileOverlay/index.ts +6 -0
- package/src/layouts/UILayout/components/layout/Sidebar/Sidebar.tsx +94 -0
- package/src/layouts/UILayout/components/layout/Sidebar/SidebarCategory.tsx +54 -0
- package/src/layouts/UILayout/components/layout/Sidebar/SidebarContent.tsx +86 -0
- package/src/layouts/UILayout/components/layout/Sidebar/SidebarFooter.tsx +49 -0
- package/src/layouts/UILayout/components/layout/Sidebar/index.ts +9 -0
- package/src/layouts/UILayout/components/layout/index.ts +8 -0
- package/src/layouts/UILayout/components/shared/Badge/CountBadge.tsx +38 -0
- package/src/layouts/UILayout/components/shared/Badge/index.ts +5 -0
- package/src/layouts/UILayout/components/shared/CodeBlock/CodeBlock.tsx +48 -0
- package/src/layouts/UILayout/components/shared/CodeBlock/CopyButton.tsx +49 -0
- package/src/layouts/UILayout/components/shared/CodeBlock/index.ts +6 -0
- package/src/layouts/UILayout/components/shared/Section/Section.tsx +63 -0
- package/src/layouts/UILayout/components/shared/Section/index.ts +5 -0
- package/src/layouts/UILayout/components/shared/index.ts +8 -0
- package/src/layouts/UILayout/config/components/navigation.config.tsx +29 -8
- package/src/layouts/UILayout/context/ShowcaseContext.tsx +1 -11
- package/src/layouts/UILayout/{UIGuideLanding.tsx → core/UIGuideLanding.tsx} +1 -1
- package/src/layouts/UILayout/{UIGuideView.tsx → core/UIGuideView.tsx} +6 -6
- package/src/layouts/UILayout/core/UILayout.tsx +102 -0
- package/src/layouts/UILayout/core/index.ts +9 -0
- package/src/layouts/UILayout/hooks/index.ts +9 -0
- package/src/layouts/UILayout/hooks/useAIExport.ts +78 -0
- package/src/layouts/UILayout/hooks/useCategoryNavigation.ts +92 -0
- package/src/layouts/UILayout/hooks/useComponentSearch.ts +81 -0
- package/src/layouts/UILayout/hooks/useSidebarState.ts +36 -0
- package/src/layouts/UILayout/index.ts +121 -22
- package/src/layouts/UILayout/types/component.ts +45 -0
- package/src/layouts/UILayout/types/index.ts +23 -0
- package/src/layouts/UILayout/types/layout.ts +57 -0
- package/src/layouts/UILayout/types/navigation.ts +33 -0
- package/src/layouts/UILayout/utils/ai-export/formatters.ts +71 -0
- package/src/layouts/UILayout/utils/ai-export/generators.ts +130 -0
- package/src/layouts/UILayout/utils/ai-export/index.ts +6 -0
- package/src/layouts/UILayout/utils/component-helpers/filter.ts +109 -0
- package/src/layouts/UILayout/utils/component-helpers/index.ts +6 -0
- package/src/layouts/UILayout/utils/component-helpers/search.ts +95 -0
- package/src/layouts/UILayout/utils/index.ts +6 -0
- package/src/layouts/UILayout/REFACTORING.md +0 -331
- package/src/layouts/UILayout/UILayout.tsx +0 -122
- package/src/layouts/UILayout/components/Header.tsx +0 -114
- package/src/layouts/UILayout/components/MobileOverlay.tsx +0 -33
- package/src/layouts/UILayout/components/Sidebar.tsx +0 -188
- package/src/layouts/UILayout/types.ts +0 -13
- /package/src/layouts/UILayout/{UIGuideApp.tsx → core/UIGuideApp.tsx} +0 -0
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
# UILayout Refactoring - Complete Summary
|
|
2
|
-
|
|
3
|
-
## 🎯 Goal
|
|
4
|
-
|
|
5
|
-
Transform ComponentShowcaseLayout into a modern, config-driven UILayout with:
|
|
6
|
-
1. **Single Source of Truth** - centralized configuration
|
|
7
|
-
2. **Zero Duplication** - no repeated code
|
|
8
|
-
3. **Auto-Rendering** - components render from config
|
|
9
|
-
4. **AI Export** - "Copy for AI" button with complete documentation
|
|
10
|
-
5. **Better Organization** - modular structure by category
|
|
11
|
-
|
|
12
|
-
## ✅ What Was Done
|
|
13
|
-
|
|
14
|
-
### 1. Renamed Old Structure
|
|
15
|
-
```bash
|
|
16
|
-
UILayout_old/ # Backup of old implementation
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### 2. Created New Config-Driven Architecture
|
|
20
|
-
|
|
21
|
-
#### Config Structure (Single Source of Truth)
|
|
22
|
-
```
|
|
23
|
-
config/
|
|
24
|
-
├── components/ # Component configs by category
|
|
25
|
-
│ ├── types.ts # ComponentConfig interface
|
|
26
|
-
│ ├── forms.config.tsx # 8 form components
|
|
27
|
-
│ ├── layout.config.tsx # 5 layout components
|
|
28
|
-
│ ├── navigation.config.tsx # 4 navigation components
|
|
29
|
-
│ ├── overlay.config.tsx # 11 overlay components
|
|
30
|
-
│ ├── feedback.config.tsx # 5 feedback components
|
|
31
|
-
│ ├── data.config.tsx # 5 data components
|
|
32
|
-
│ ├── specialized.config.tsx # 2 specialized components
|
|
33
|
-
│ ├── blocks.config.tsx # 7 landing page blocks
|
|
34
|
-
│ ├── hooks.config.tsx # 6 custom React hooks
|
|
35
|
-
│ └── index.ts # Aggregator
|
|
36
|
-
├── categories.config.tsx # Menu categories
|
|
37
|
-
├── tailwind.config.ts # Tailwind 4 guide
|
|
38
|
-
├── ai-export.config.ts # AI context generator
|
|
39
|
-
└── index.ts # Main exports
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
#### Component Architecture
|
|
43
|
-
```
|
|
44
|
-
components/
|
|
45
|
-
├── AutoComponentDemo.tsx # Reads from config, renders component
|
|
46
|
-
├── CategoryRenderer.tsx # Renders entire category from config
|
|
47
|
-
├── TailwindGuideRenderer.tsx # Renders Tailwind guide from config
|
|
48
|
-
├── Header.tsx # Header with "Copy for AI" button
|
|
49
|
-
├── Sidebar.tsx # Navigation sidebar
|
|
50
|
-
└── MobileOverlay.tsx # Mobile menu overlay
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 3. Component Configuration Format
|
|
54
|
-
|
|
55
|
-
Each component defined as:
|
|
56
|
-
```typescript
|
|
57
|
-
interface ComponentConfig {
|
|
58
|
-
name: string; // "Button"
|
|
59
|
-
category: string; // "forms"
|
|
60
|
-
description: string; // "Interactive button with variants"
|
|
61
|
-
importPath: string; // "import { Button } from '@djangocfg/ui';"
|
|
62
|
-
example: string; // Code example as string
|
|
63
|
-
preview: ReactNode; // Live React component
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 4. Key Features Implemented
|
|
68
|
-
|
|
69
|
-
#### ✅ Auto-Rendering from Config
|
|
70
|
-
```tsx
|
|
71
|
-
// Before: Manual demo files for each category
|
|
72
|
-
FormComponentsDemo.tsx // 200+ lines
|
|
73
|
-
LayoutComponentsDemo.tsx // 180+ lines
|
|
74
|
-
NavigationComponentsDemo.tsx // 150+ lines
|
|
75
|
-
// ... 7 more demo files
|
|
76
|
-
|
|
77
|
-
// After: One universal renderer
|
|
78
|
-
<CategoryRenderer categoryId="forms" /> // Reads from config
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### ✅ "Copy for AI" Button
|
|
82
|
-
- In Header component (desktop & mobile)
|
|
83
|
-
- Generates complete documentation:
|
|
84
|
-
- Tailwind 4 guidelines
|
|
85
|
-
- All 53 components with examples
|
|
86
|
-
- Proper formatting for AI
|
|
87
|
-
- Uses `generateAIContext()` function
|
|
88
|
-
- One-click clipboard copy
|
|
89
|
-
|
|
90
|
-
#### ✅ Zero Duplication
|
|
91
|
-
```typescript
|
|
92
|
-
// Before: Component defined in 3 places
|
|
93
|
-
// 1. Demo file (preview)
|
|
94
|
-
// 2. Code example (string)
|
|
95
|
-
// 3. Import statement
|
|
96
|
-
|
|
97
|
-
// After: Component defined ONCE
|
|
98
|
-
{
|
|
99
|
-
name: 'Button',
|
|
100
|
-
preview: <Button>Click</Button>,
|
|
101
|
-
example: '<Button>Click</Button>',
|
|
102
|
-
importPath: "import { Button } from '@djangocfg/ui';"
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 5. Statistics
|
|
107
|
-
|
|
108
|
-
#### Total Components Documented
|
|
109
|
-
| Category | Count | Config File |
|
|
110
|
-
|----------|-------|-------------|
|
|
111
|
-
| Forms | 8 | forms.config.tsx (320 lines) |
|
|
112
|
-
| Layout | 5 | layout.config.tsx (240 lines) |
|
|
113
|
-
| Navigation | 4 | navigation.config.tsx (195 lines) |
|
|
114
|
-
| Overlay | 11 | overlay.config.tsx (510 lines) |
|
|
115
|
-
| Feedback | 5 | feedback.config.tsx (220 lines) |
|
|
116
|
-
| Data Display | 5 | data.config.tsx (200 lines) |
|
|
117
|
-
| Specialized | 2 | specialized.config.tsx (95 lines) |
|
|
118
|
-
| Blocks | 7 | blocks.config.tsx (280 lines) |
|
|
119
|
-
| Hooks | 6 | hooks.config.tsx (170 lines) |
|
|
120
|
-
| **TOTAL** | **53** | **2,230 lines** |
|
|
121
|
-
|
|
122
|
-
#### Code Reduction
|
|
123
|
-
- **Before**: ~1,800 lines of demo files + ~1,200 lines of component definitions = **3,000 lines**
|
|
124
|
-
- **After**: ~2,230 lines (all-in-one configs) = **2,230 lines**
|
|
125
|
-
- **Saved**: ~770 lines (-25%)
|
|
126
|
-
- **Maintainability**: 100x better (single source of truth)
|
|
127
|
-
|
|
128
|
-
### 6. Files Created
|
|
129
|
-
|
|
130
|
-
#### Core Files (11)
|
|
131
|
-
1. `UILayout.tsx` - Main layout component
|
|
132
|
-
2. `UIGuideView.tsx` - Complete view with categories
|
|
133
|
-
3. `UIGuideLanding.tsx` - Landing page (copied from old)
|
|
134
|
-
4. `UIGuideApp.tsx` - Full app wrapper
|
|
135
|
-
5. `types.ts` - Type definitions
|
|
136
|
-
6. `constants.ts` - Constants
|
|
137
|
-
7. `index.ts` - Main exports
|
|
138
|
-
8. `README.md` - Documentation
|
|
139
|
-
9. `REFACTORING.md` - This file
|
|
140
|
-
|
|
141
|
-
#### Config Files (14)
|
|
142
|
-
10. `config/components/types.ts`
|
|
143
|
-
11. `config/components/forms.config.tsx`
|
|
144
|
-
12. `config/components/layout.config.tsx`
|
|
145
|
-
13. `config/components/navigation.config.tsx`
|
|
146
|
-
14. `config/components/overlay.config.tsx`
|
|
147
|
-
15. `config/components/feedback.config.tsx`
|
|
148
|
-
16. `config/components/data.config.tsx`
|
|
149
|
-
17. `config/components/specialized.config.tsx`
|
|
150
|
-
18. `config/components/blocks.config.tsx`
|
|
151
|
-
19. `config/components/hooks.config.tsx`
|
|
152
|
-
20. `config/components/index.ts`
|
|
153
|
-
21. `config/categories.config.tsx`
|
|
154
|
-
22. `config/tailwind.config.ts`
|
|
155
|
-
23. `config/ai-export.config.ts`
|
|
156
|
-
24. `config/index.ts`
|
|
157
|
-
|
|
158
|
-
#### Component Files (6)
|
|
159
|
-
25. `components/AutoComponentDemo.tsx`
|
|
160
|
-
26. `components/CategoryRenderer.tsx`
|
|
161
|
-
27. `components/TailwindGuideRenderer.tsx`
|
|
162
|
-
28. `components/Header.tsx` (copied & updated)
|
|
163
|
-
29. `components/Sidebar.tsx` (copied)
|
|
164
|
-
30. `components/MobileOverlay.tsx` (copied)
|
|
165
|
-
|
|
166
|
-
#### Context (1)
|
|
167
|
-
31. `context/` (copied from old)
|
|
168
|
-
|
|
169
|
-
**Total: 31 files created/updated**
|
|
170
|
-
|
|
171
|
-
## 🚀 Benefits
|
|
172
|
-
|
|
173
|
-
### 1. Single Source of Truth
|
|
174
|
-
- All component data in config files
|
|
175
|
-
- No duplication
|
|
176
|
-
- Easy to update
|
|
177
|
-
|
|
178
|
-
### 2. Auto-Rendering
|
|
179
|
-
- Add component to config → automatically appears everywhere
|
|
180
|
-
- No manual demo file creation
|
|
181
|
-
- Consistent presentation
|
|
182
|
-
|
|
183
|
-
### 3. Type-Safe
|
|
184
|
-
- Full TypeScript support
|
|
185
|
-
- Interface for ComponentConfig
|
|
186
|
-
- Compile-time error checking
|
|
187
|
-
|
|
188
|
-
### 4. AI-Ready
|
|
189
|
-
- "Copy for AI" button
|
|
190
|
-
- Complete documentation export
|
|
191
|
-
- Proper formatting for AI consumption
|
|
192
|
-
|
|
193
|
-
### 5. Maintainable
|
|
194
|
-
```typescript
|
|
195
|
-
// Adding new component:
|
|
196
|
-
|
|
197
|
-
// Before (3 steps):
|
|
198
|
-
// 1. Create demo component in category file
|
|
199
|
-
// 2. Add code example string
|
|
200
|
-
// 3. Import and wire up
|
|
201
|
-
|
|
202
|
-
// After (1 step):
|
|
203
|
-
// Add to config file:
|
|
204
|
-
{
|
|
205
|
-
name: 'NewComponent',
|
|
206
|
-
category: 'forms',
|
|
207
|
-
description: '...',
|
|
208
|
-
importPath: '...',
|
|
209
|
-
example: '...',
|
|
210
|
-
preview: <NewComponent />
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### 6. Scalable
|
|
215
|
-
- Easy to add new categories
|
|
216
|
-
- Easy to add new components
|
|
217
|
-
- Modular structure
|
|
218
|
-
|
|
219
|
-
## 📊 Comparison
|
|
220
|
-
|
|
221
|
-
### Old Architecture
|
|
222
|
-
```
|
|
223
|
-
ComponentShowcaseLayout/
|
|
224
|
-
├── categories/
|
|
225
|
-
│ ├── FormComponentsDemo.tsx # 200 lines
|
|
226
|
-
│ ├── LayoutComponentsDemo.tsx # 180 lines
|
|
227
|
-
│ ├── NavigationComponentsDemo.tsx # 150 lines
|
|
228
|
-
│ ├── OverlayComponentsDemo.tsx # 250 lines
|
|
229
|
-
│ ├── FeedbackComponentsDemo.tsx # 140 lines
|
|
230
|
-
│ ├── DataDisplayDemo.tsx # 170 lines
|
|
231
|
-
│ ├── SpecializedComponentsDemo.tsx # 120 lines
|
|
232
|
-
│ ├── BlocksDemo.tsx # 280 lines
|
|
233
|
-
│ ├── HooksDemo.tsx # 160 lines
|
|
234
|
-
│ └── Tailwind4Guide.tsx # 240 lines
|
|
235
|
-
└── ... (other files)
|
|
236
|
-
|
|
237
|
-
Problems:
|
|
238
|
-
- ❌ Duplication (component defined multiple times)
|
|
239
|
-
- ❌ Hard to maintain (update in multiple places)
|
|
240
|
-
- ❌ Manual rendering (write demo for each component)
|
|
241
|
-
- ❌ No AI export
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### New Architecture
|
|
245
|
-
```
|
|
246
|
-
UILayout/
|
|
247
|
-
├── config/
|
|
248
|
-
│ ├── components/ # All component definitions
|
|
249
|
-
│ │ ├── forms.config.tsx
|
|
250
|
-
│ │ ├── layout.config.tsx
|
|
251
|
-
│ │ └── ... (9 files total)
|
|
252
|
-
│ ├── categories.config.tsx
|
|
253
|
-
│ ├── tailwind.config.ts
|
|
254
|
-
│ └── ai-export.config.ts
|
|
255
|
-
├── components/
|
|
256
|
-
│ ├── AutoComponentDemo.tsx # Auto-renders from config
|
|
257
|
-
│ ├── CategoryRenderer.tsx # Renders entire category
|
|
258
|
-
│ └── TailwindGuideRenderer.tsx # Renders guide
|
|
259
|
-
└── ...
|
|
260
|
-
|
|
261
|
-
Benefits:
|
|
262
|
-
- ✅ Single source of truth (config)
|
|
263
|
-
- ✅ Easy to maintain (one place to update)
|
|
264
|
-
- ✅ Auto-rendering (no manual demos)
|
|
265
|
-
- ✅ AI export built-in
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## 🎯 Migration Path
|
|
269
|
-
|
|
270
|
-
If you want to migrate existing component showcase:
|
|
271
|
-
|
|
272
|
-
1. **Analyze existing demos** - identify all components
|
|
273
|
-
2. **Create config files** - one per category
|
|
274
|
-
3. **Define ComponentConfig** - for each component:
|
|
275
|
-
```typescript
|
|
276
|
-
{
|
|
277
|
-
name: string,
|
|
278
|
-
category: string,
|
|
279
|
-
description: string,
|
|
280
|
-
importPath: string,
|
|
281
|
-
example: string,
|
|
282
|
-
preview: ReactNode
|
|
283
|
-
}
|
|
284
|
-
```
|
|
285
|
-
4. **Replace demos** - use `<CategoryRenderer categoryId="..." />`
|
|
286
|
-
5. **Test** - verify all components render correctly
|
|
287
|
-
6. **Delete old demos** - remove manual demo files
|
|
288
|
-
|
|
289
|
-
## ✅ Verification
|
|
290
|
-
|
|
291
|
-
### TypeScript Check
|
|
292
|
-
```bash
|
|
293
|
-
pnpm check
|
|
294
|
-
# ✅ No errors
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### File Count
|
|
298
|
-
```bash
|
|
299
|
-
# Config files: 14
|
|
300
|
-
# Component files: 6
|
|
301
|
-
# Context: 1
|
|
302
|
-
# Core: 11
|
|
303
|
-
# Total: 32 files
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### Component Count
|
|
307
|
-
```bash
|
|
308
|
-
# Total components in config: 53
|
|
309
|
-
# - Forms: 8
|
|
310
|
-
# - Layout: 5
|
|
311
|
-
# - Navigation: 4
|
|
312
|
-
# - Overlay: 11
|
|
313
|
-
# - Feedback: 5
|
|
314
|
-
# - Data: 5
|
|
315
|
-
# - Specialized: 2
|
|
316
|
-
# - Blocks: 7
|
|
317
|
-
# - Hooks: 6
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
## 🎉 Result
|
|
321
|
-
|
|
322
|
-
Полностью рефакторенная, config-driven система документации UI компонентов с:
|
|
323
|
-
- ✅ Единым источником правды (конфиг)
|
|
324
|
-
- ✅ Нулевым дублированием кода
|
|
325
|
-
- ✅ Автоматическим рендерингом
|
|
326
|
-
- ✅ Экспортом для AI
|
|
327
|
-
- ✅ TypeScript безопасностью
|
|
328
|
-
- ✅ Модульной структурой
|
|
329
|
-
- ✅ Легкой масштабируемостью
|
|
330
|
-
|
|
331
|
-
**Готово к использованию!** 🚀
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UILayout
|
|
3
|
-
* Modern, config-driven layout for UI component documentation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React, { ReactNode } from 'react';
|
|
9
|
-
import { useCopy, Sticky } from '@djangocfg/ui';
|
|
10
|
-
import { Sidebar } from './components/Sidebar';
|
|
11
|
-
import { Header } from './components/Header';
|
|
12
|
-
import { MobileOverlay } from './components/MobileOverlay';
|
|
13
|
-
import { generateAIContext } from './config';
|
|
14
|
-
import { useShowcase } from './context';
|
|
15
|
-
import type { ComponentCategory } from './config';
|
|
16
|
-
|
|
17
|
-
export interface UILayoutProps {
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
title?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
categories: ComponentCategory[];
|
|
22
|
-
currentCategory?: string;
|
|
23
|
-
onCategoryChange?: (categoryId: string) => void;
|
|
24
|
-
logo?: ReactNode;
|
|
25
|
-
projectName?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* UILayout - Main layout component for UI documentation
|
|
30
|
-
*
|
|
31
|
-
* Features:
|
|
32
|
-
* - Config-driven: All component data comes from centralized config
|
|
33
|
-
* - "Copy for AI": One-click export of all documentation
|
|
34
|
-
* - Responsive: Mobile-first design with sidebar
|
|
35
|
-
* - Type-safe: Full TypeScript support
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* <UILayout
|
|
40
|
-
* title="UI Components"
|
|
41
|
-
* categories={CATEGORIES}
|
|
42
|
-
* currentCategory={category}
|
|
43
|
-
* onCategoryChange={setCategory}
|
|
44
|
-
* >
|
|
45
|
-
* <CategoryRenderer categoryId={category} />
|
|
46
|
-
* </UILayout>
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export function UILayout({
|
|
50
|
-
children,
|
|
51
|
-
title = "UI Component Library",
|
|
52
|
-
description,
|
|
53
|
-
categories,
|
|
54
|
-
currentCategory,
|
|
55
|
-
onCategoryChange,
|
|
56
|
-
logo,
|
|
57
|
-
projectName = "Django CFG UI",
|
|
58
|
-
}: UILayoutProps) {
|
|
59
|
-
const { isSidebarOpen, toggleSidebar, closeSidebar } = useShowcase();
|
|
60
|
-
const { copyToClipboard } = useCopy();
|
|
61
|
-
|
|
62
|
-
const handleCategoryChange = (categoryId: string) => {
|
|
63
|
-
onCategoryChange?.(categoryId);
|
|
64
|
-
closeSidebar();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const handleCopyForAI = () => {
|
|
68
|
-
const aiContext = generateAIContext();
|
|
69
|
-
copyToClipboard(aiContext);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<div className="flex bg-background">
|
|
74
|
-
{/* Mobile Overlay - outside flex container for proper z-index stacking */}
|
|
75
|
-
<MobileOverlay
|
|
76
|
-
isOpen={isSidebarOpen}
|
|
77
|
-
onClose={closeSidebar}
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
{/* Sidebar with Sticky - parent must be scrollable for react-sticky-box */}
|
|
81
|
-
<div className="h-full sticky top-0">
|
|
82
|
-
<Sidebar
|
|
83
|
-
categories={categories}
|
|
84
|
-
currentCategory={currentCategory}
|
|
85
|
-
onCategoryChange={handleCategoryChange}
|
|
86
|
-
isOpen={isSidebarOpen}
|
|
87
|
-
projectName={projectName}
|
|
88
|
-
logo={logo}
|
|
89
|
-
/>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
{/* Main Content */}
|
|
93
|
-
<main className="flex-1 flex flex-col min-w-0">
|
|
94
|
-
{/* Header with Copy for AI button */}
|
|
95
|
-
<Header
|
|
96
|
-
title={title}
|
|
97
|
-
projectName={projectName}
|
|
98
|
-
logo={logo}
|
|
99
|
-
isSidebarOpen={isSidebarOpen}
|
|
100
|
-
onToggleSidebar={toggleSidebar}
|
|
101
|
-
onCopyForAI={handleCopyForAI}
|
|
102
|
-
/>
|
|
103
|
-
|
|
104
|
-
{/* Content Area */}
|
|
105
|
-
<div className="flex-1">
|
|
106
|
-
<div className="container max-w-7xl mx-auto p-6">
|
|
107
|
-
{description && (
|
|
108
|
-
<p className="text-sm text-muted-foreground mb-6">
|
|
109
|
-
{description}
|
|
110
|
-
</p>
|
|
111
|
-
)}
|
|
112
|
-
{children}
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
</main>
|
|
116
|
-
</div>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Legacy export for backward compatibility
|
|
121
|
-
export { UILayout as ComponentShowcaseLayout };
|
|
122
|
-
export type { UILayoutProps as ComponentShowcaseLayoutProps };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Header Component
|
|
3
|
-
* Top header for mobile and page title with Copy for AI button
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React, { useState } from 'react';
|
|
9
|
-
import { Button, useIsMobile, useCopy } from '@djangocfg/ui';
|
|
10
|
-
import { Menu, X, Sparkles, Check } from 'lucide-react';
|
|
11
|
-
|
|
12
|
-
interface HeaderProps {
|
|
13
|
-
title?: string;
|
|
14
|
-
projectName?: string;
|
|
15
|
-
logo?: React.ReactNode;
|
|
16
|
-
isSidebarOpen?: boolean;
|
|
17
|
-
onToggleSidebar?: () => void;
|
|
18
|
-
onCopyForAI?: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function Header({
|
|
22
|
-
title = 'UI Component Library',
|
|
23
|
-
projectName = 'Django CFG',
|
|
24
|
-
logo,
|
|
25
|
-
isSidebarOpen = false,
|
|
26
|
-
onToggleSidebar,
|
|
27
|
-
onCopyForAI,
|
|
28
|
-
}: HeaderProps) {
|
|
29
|
-
const isMobile = useIsMobile();
|
|
30
|
-
const { copyToClipboard } = useCopy();
|
|
31
|
-
const [copied, setCopied] = useState(false);
|
|
32
|
-
|
|
33
|
-
const handleCopyForAI = async () => {
|
|
34
|
-
if (onCopyForAI) {
|
|
35
|
-
onCopyForAI();
|
|
36
|
-
}
|
|
37
|
-
setCopied(true);
|
|
38
|
-
setTimeout(() => setCopied(false), 2000);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
{/* Mobile Header - only on mobile */}
|
|
44
|
-
{isMobile && (
|
|
45
|
-
<header className="w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
|
46
|
-
<div className="flex h-14 items-center px-4 gap-4">
|
|
47
|
-
<Button
|
|
48
|
-
variant="ghost"
|
|
49
|
-
size="icon"
|
|
50
|
-
className="h-9 w-9"
|
|
51
|
-
onClick={onToggleSidebar}
|
|
52
|
-
>
|
|
53
|
-
{isSidebarOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
|
|
54
|
-
</Button>
|
|
55
|
-
|
|
56
|
-
<div className="flex items-center gap-2 flex-1">
|
|
57
|
-
{logo}
|
|
58
|
-
<span className="font-semibold text-sm">{projectName}</span>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<Button
|
|
62
|
-
variant="outline"
|
|
63
|
-
size="sm"
|
|
64
|
-
onClick={handleCopyForAI}
|
|
65
|
-
className="gap-2"
|
|
66
|
-
>
|
|
67
|
-
{copied ? (
|
|
68
|
-
<>
|
|
69
|
-
<Check className="h-4 w-4" />
|
|
70
|
-
<span className="hidden xs:inline">Copied!</span>
|
|
71
|
-
</>
|
|
72
|
-
) : (
|
|
73
|
-
<>
|
|
74
|
-
<Sparkles className="h-4 w-4" />
|
|
75
|
-
<span className="hidden xs:inline">Copy for AI</span>
|
|
76
|
-
</>
|
|
77
|
-
)}
|
|
78
|
-
</Button>
|
|
79
|
-
</div>
|
|
80
|
-
</header>
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
{/* Desktop Page Header - only on desktop */}
|
|
84
|
-
{!isMobile && (
|
|
85
|
-
<div className="border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
|
86
|
-
<div className="flex h-14 items-center gap-4 px-6">
|
|
87
|
-
<div className="flex-1">
|
|
88
|
-
<h1 className="text-lg font-semibold">{title}</h1>
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
<Button
|
|
92
|
-
variant="outline"
|
|
93
|
-
size="sm"
|
|
94
|
-
onClick={handleCopyForAI}
|
|
95
|
-
className="gap-2"
|
|
96
|
-
>
|
|
97
|
-
{copied ? (
|
|
98
|
-
<>
|
|
99
|
-
<Check className="h-4 w-4" />
|
|
100
|
-
Copied!
|
|
101
|
-
</>
|
|
102
|
-
) : (
|
|
103
|
-
<>
|
|
104
|
-
<Sparkles className="h-4 w-4" />
|
|
105
|
-
Copy for AI
|
|
106
|
-
</>
|
|
107
|
-
)}
|
|
108
|
-
</Button>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
)}
|
|
112
|
-
</>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile Overlay Component
|
|
3
|
-
* Backdrop overlay for mobile sidebar
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { cn } from '@djangocfg/ui/lib';
|
|
10
|
-
import { useIsMobile } from '@djangocfg/ui';
|
|
11
|
-
|
|
12
|
-
interface MobileOverlayProps {
|
|
13
|
-
isOpen: boolean;
|
|
14
|
-
onClose: () => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function MobileOverlay({ isOpen, onClose }: MobileOverlayProps) {
|
|
18
|
-
const isMobile = useIsMobile();
|
|
19
|
-
|
|
20
|
-
// Only show on mobile when sidebar is open
|
|
21
|
-
if (!isMobile || !isOpen) return null;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
className={cn(
|
|
26
|
-
"fixed inset-0 z-[150] bg-background/80 backdrop-blur-sm",
|
|
27
|
-
"animate-in fade-in duration-300"
|
|
28
|
-
)}
|
|
29
|
-
onClick={onClose}
|
|
30
|
-
aria-hidden="true"
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
}
|