@marlinjai/clearify 1.5.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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/bin/clearify.js +2 -0
  4. package/dist/node/chunk-5TD7NQIW.js +25 -0
  5. package/dist/node/chunk-B2Q23JW3.js +55 -0
  6. package/dist/node/chunk-CQ4MNGBE.js +301 -0
  7. package/dist/node/chunk-GFD54GNO.js +223 -0
  8. package/dist/node/chunk-IBK35HZR.js +194 -0
  9. package/dist/node/chunk-L24ILRSX.js +125 -0
  10. package/dist/node/chunk-NXQNNLGC.js +395 -0
  11. package/dist/node/chunk-PRTER35L.js +48 -0
  12. package/dist/node/chunk-SCZZB7OE.js +9 -0
  13. package/dist/node/chunk-V7LLYIRO.js +8 -0
  14. package/dist/node/chunk-WT5W333R.js +136 -0
  15. package/dist/node/cli/index.d.ts +2 -0
  16. package/dist/node/cli/index.js +41 -0
  17. package/dist/node/core/config.d.ts +9 -0
  18. package/dist/node/core/config.js +16 -0
  19. package/dist/node/core/mermaid-renderer.d.ts +22 -0
  20. package/dist/node/core/mermaid-renderer.js +125 -0
  21. package/dist/node/core/mermaid-utils.d.ts +3 -0
  22. package/dist/node/core/mermaid-utils.js +6 -0
  23. package/dist/node/core/navigation.d.ts +2 -0
  24. package/dist/node/core/navigation.js +13 -0
  25. package/dist/node/core/openapi-parser.d.ts +14 -0
  26. package/dist/node/core/openapi-parser.js +6 -0
  27. package/dist/node/core/remark-mermaid.d.ts +10 -0
  28. package/dist/node/core/remark-mermaid.js +11 -0
  29. package/dist/node/core/search.d.ts +31 -0
  30. package/dist/node/core/search.js +6 -0
  31. package/dist/node/node/build.d.ts +3 -0
  32. package/dist/node/node/build.js +14 -0
  33. package/dist/node/node/check.d.ts +3 -0
  34. package/dist/node/node/check.js +10 -0
  35. package/dist/node/node/index.d.ts +11 -0
  36. package/dist/node/node/index.js +108 -0
  37. package/dist/node/node/init.d.ts +6 -0
  38. package/dist/node/node/init.js +6 -0
  39. package/dist/node/presets/nestjs.d.ts +15 -0
  40. package/dist/node/presets/nestjs.js +98 -0
  41. package/dist/node/types/index.d.ts +79 -0
  42. package/dist/node/types/index.js +6 -0
  43. package/dist/node/vite-plugin/index.d.ts +13 -0
  44. package/dist/node/vite-plugin/index.js +11 -0
  45. package/package.json +94 -0
  46. package/src/client/App.tsx +101 -0
  47. package/src/client/Page.tsx +15 -0
  48. package/src/client/entry-server.tsx +79 -0
  49. package/src/client/index.html +18 -0
  50. package/src/client/main.tsx +11 -0
  51. package/src/theme/CodeBlock.tsx +103 -0
  52. package/src/theme/Content.tsx +32 -0
  53. package/src/theme/Footer.tsx +53 -0
  54. package/src/theme/Head.tsx +80 -0
  55. package/src/theme/HeadContext.tsx +32 -0
  56. package/src/theme/Header.tsx +177 -0
  57. package/src/theme/Layout.tsx +44 -0
  58. package/src/theme/MDXComponents.tsx +40 -0
  59. package/src/theme/NotFound.tsx +246 -0
  60. package/src/theme/Search.tsx +359 -0
  61. package/src/theme/Sidebar.tsx +325 -0
  62. package/src/theme/TableOfContents.tsx +153 -0
  63. package/src/theme/ThemeProvider.tsx +77 -0
  64. package/src/theme/components/Accordion.tsx +109 -0
  65. package/src/theme/components/Badge.tsx +72 -0
  66. package/src/theme/components/Breadcrumbs.tsx +88 -0
  67. package/src/theme/components/Callout.tsx +115 -0
  68. package/src/theme/components/Card.tsx +103 -0
  69. package/src/theme/components/CodeGroup.tsx +79 -0
  70. package/src/theme/components/Columns.tsx +42 -0
  71. package/src/theme/components/Frame.tsx +55 -0
  72. package/src/theme/components/Mermaid.tsx +99 -0
  73. package/src/theme/components/MermaidStatic.tsx +32 -0
  74. package/src/theme/components/OpenAPI.tsx +160 -0
  75. package/src/theme/components/OpenAPIPage.tsx +16 -0
  76. package/src/theme/components/Steps.tsx +76 -0
  77. package/src/theme/components/Tabs.tsx +75 -0
  78. package/src/theme/components/Tooltip.tsx +108 -0
  79. package/src/theme/components/index.ts +14 -0
  80. package/src/theme/styles/globals.css +363 -0
@@ -0,0 +1,359 @@
1
+ import React, { useEffect, useState, useRef, useCallback, useMemo } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ // @ts-expect-error virtual module
4
+ import searchEntries from 'virtual:clearify/search-index';
5
+
6
+ interface SearchEntry {
7
+ id: number;
8
+ path: string;
9
+ title: string;
10
+ description: string;
11
+ content: string;
12
+ sectionId?: string;
13
+ sectionLabel?: string;
14
+ }
15
+
16
+ function search(query: string, entries: SearchEntry[]): SearchEntry[] {
17
+ if (!query.trim()) return [];
18
+ const q = query.toLowerCase();
19
+ const terms = q.split(/\s+/);
20
+
21
+ return entries
22
+ .map((entry) => {
23
+ const text = `${entry.title} ${entry.description} ${entry.content}`.toLowerCase();
24
+ let score = 0;
25
+ for (const term of terms) {
26
+ if (entry.title.toLowerCase().includes(term)) score += 10;
27
+ if (entry.description.toLowerCase().includes(term)) score += 5;
28
+ if (text.includes(term)) score += 1;
29
+ }
30
+ return { entry, score };
31
+ })
32
+ .filter((r) => r.score > 0)
33
+ .sort((a, b) => b.score - a.score)
34
+ .slice(0, 8)
35
+ .map((r) => r.entry);
36
+ }
37
+
38
+ function getExcerpt(content: string, query: string): string {
39
+ const q = query.toLowerCase();
40
+ const idx = content.toLowerCase().indexOf(q);
41
+ if (idx === -1) return content.slice(0, 120) + '...';
42
+ const start = Math.max(0, idx - 40);
43
+ const end = Math.min(content.length, idx + query.length + 80);
44
+ let excerpt = content.slice(start, end);
45
+ if (start > 0) excerpt = '...' + excerpt;
46
+ if (end < content.length) excerpt = excerpt + '...';
47
+ return excerpt;
48
+ }
49
+
50
+ export function Search() {
51
+ const [open, setOpen] = useState(false);
52
+ const [query, setQuery] = useState('');
53
+ const [selected, setSelected] = useState(0);
54
+ const inputRef = useRef<HTMLInputElement>(null);
55
+ const navigate = useNavigate();
56
+
57
+ const results = useMemo(() => search(query, searchEntries as SearchEntry[]), [query]);
58
+
59
+ useEffect(() => {
60
+ setSelected(0);
61
+ }, [results]);
62
+
63
+ useEffect(() => {
64
+ const handler = (e: KeyboardEvent) => {
65
+ if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
66
+ e.preventDefault();
67
+ setOpen((prev) => !prev);
68
+ }
69
+ if (e.key === 'Escape') {
70
+ setOpen(false);
71
+ }
72
+ };
73
+ window.addEventListener('keydown', handler);
74
+ return () => window.removeEventListener('keydown', handler);
75
+ }, []);
76
+
77
+ useEffect(() => {
78
+ if (open) {
79
+ setTimeout(() => inputRef.current?.focus(), 50);
80
+ } else {
81
+ setQuery('');
82
+ }
83
+ }, [open]);
84
+
85
+ const handleSelect = useCallback(
86
+ (path: string) => {
87
+ navigate(path);
88
+ setOpen(false);
89
+ },
90
+ [navigate]
91
+ );
92
+
93
+ const handleKeyDown = (e: React.KeyboardEvent) => {
94
+ if (e.key === 'ArrowDown') {
95
+ e.preventDefault();
96
+ setSelected((s) => Math.min(s + 1, results.length - 1));
97
+ } else if (e.key === 'ArrowUp') {
98
+ e.preventDefault();
99
+ setSelected((s) => Math.max(s - 1, 0));
100
+ } else if (e.key === 'Enter' && results[selected]) {
101
+ handleSelect(results[selected].path);
102
+ }
103
+ };
104
+
105
+ return (
106
+ <>
107
+ <button
108
+ onClick={() => setOpen(true)}
109
+ style={{
110
+ display: 'flex',
111
+ alignItems: 'center',
112
+ gap: '0.5rem',
113
+ padding: '0.4rem 0.75rem',
114
+ border: '1px solid var(--clearify-border)',
115
+ borderRadius: 'var(--clearify-radius)',
116
+ background: 'var(--clearify-bg-secondary)',
117
+ cursor: 'pointer',
118
+ fontSize: '0.8125rem',
119
+ color: 'var(--clearify-text-tertiary)',
120
+ minWidth: 200,
121
+ transition: 'border-color 0.15s, box-shadow 0.15s',
122
+ height: 36,
123
+ }}
124
+ className="clearify-search-btn"
125
+ >
126
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
127
+ <circle cx="11" cy="11" r="8" />
128
+ <path d="m21 21-4.3-4.3" />
129
+ </svg>
130
+ Search docs...
131
+ <kbd
132
+ style={{
133
+ marginLeft: 'auto',
134
+ padding: '0.1rem 0.375rem',
135
+ borderRadius: 'var(--clearify-radius-sm)',
136
+ border: '1px solid var(--clearify-border)',
137
+ fontSize: '0.625rem',
138
+ fontFamily: 'var(--font-mono)',
139
+ color: 'var(--clearify-text-tertiary)',
140
+ fontWeight: 500,
141
+ lineHeight: 1.6,
142
+ }}
143
+ >
144
+ {navigator.platform?.includes('Mac') ? '\u2318K' : 'Ctrl+K'}
145
+ </kbd>
146
+
147
+ <style>{`
148
+ .clearify-search-btn:hover {
149
+ border-color: var(--clearify-border-strong) !important;
150
+ box-shadow: var(--clearify-shadow-sm);
151
+ }
152
+ `}</style>
153
+ </button>
154
+
155
+ {open && (
156
+ <div
157
+ style={{
158
+ position: 'fixed',
159
+ inset: 0,
160
+ zIndex: 100,
161
+ display: 'flex',
162
+ alignItems: 'flex-start',
163
+ justifyContent: 'center',
164
+ paddingTop: '12vh',
165
+ backgroundColor: 'rgba(0, 0, 0, 0.4)',
166
+ backdropFilter: 'blur(8px)',
167
+ WebkitBackdropFilter: 'blur(8px)',
168
+ animation: 'clearify-fade-in 0.15s ease-out',
169
+ }}
170
+ onClick={() => setOpen(false)}
171
+ >
172
+ <div
173
+ style={{
174
+ width: '100%',
175
+ maxWidth: 580,
176
+ margin: '0 1rem',
177
+ backgroundColor: 'var(--clearify-surface-elevated)',
178
+ border: '1px solid var(--clearify-border-strong)',
179
+ borderRadius: 'var(--clearify-radius-xl)',
180
+ boxShadow: 'var(--clearify-shadow-lg)',
181
+ overflow: 'hidden',
182
+ backdropFilter: 'blur(20px) saturate(180%)',
183
+ WebkitBackdropFilter: 'blur(20px) saturate(180%)',
184
+ animation: 'clearify-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1)',
185
+ }}
186
+ onClick={(e) => e.stopPropagation()}
187
+ >
188
+ <div
189
+ style={{
190
+ display: 'flex',
191
+ alignItems: 'center',
192
+ padding: '0.875rem 1.25rem',
193
+ borderBottom: '1px solid var(--clearify-border)',
194
+ }}
195
+ >
196
+ <svg
197
+ width="16"
198
+ height="16"
199
+ viewBox="0 0 24 24"
200
+ fill="none"
201
+ stroke="var(--clearify-text-tertiary)"
202
+ strokeWidth="2"
203
+ strokeLinecap="round"
204
+ strokeLinejoin="round"
205
+ style={{ flexShrink: 0 }}
206
+ >
207
+ <circle cx="11" cy="11" r="8" />
208
+ <path d="m21 21-4.3-4.3" />
209
+ </svg>
210
+ <input
211
+ ref={inputRef}
212
+ value={query}
213
+ onChange={(e) => setQuery(e.target.value)}
214
+ onKeyDown={handleKeyDown}
215
+ placeholder="Search documentation..."
216
+ style={{
217
+ flex: 1,
218
+ border: 'none',
219
+ outline: 'none',
220
+ background: 'none',
221
+ padding: '0.25rem 0.75rem',
222
+ fontSize: '0.9375rem',
223
+ color: 'var(--clearify-text)',
224
+ fontFamily: 'var(--font-sans)',
225
+ }}
226
+ />
227
+ <kbd
228
+ style={{
229
+ padding: '0.15rem 0.5rem',
230
+ borderRadius: 'var(--clearify-radius-sm)',
231
+ border: '1px solid var(--clearify-border)',
232
+ fontSize: '0.6875rem',
233
+ color: 'var(--clearify-text-tertiary)',
234
+ fontFamily: 'var(--font-mono)',
235
+ fontWeight: 500,
236
+ }}
237
+ >
238
+ Esc
239
+ </kbd>
240
+ </div>
241
+
242
+ <div
243
+ style={{
244
+ maxHeight: 420,
245
+ overflowY: 'auto',
246
+ padding: results.length > 0 ? '0.375rem' : '0',
247
+ }}
248
+ >
249
+ {query && results.length === 0 && (
250
+ <div
251
+ style={{
252
+ padding: '2.5rem 1rem',
253
+ textAlign: 'center',
254
+ color: 'var(--clearify-text-tertiary)',
255
+ fontSize: '0.875rem',
256
+ }}
257
+ >
258
+ <svg
259
+ width="32"
260
+ height="32"
261
+ viewBox="0 0 24 24"
262
+ fill="none"
263
+ stroke="currentColor"
264
+ strokeWidth="1.5"
265
+ strokeLinecap="round"
266
+ strokeLinejoin="round"
267
+ style={{ margin: '0 auto 0.75rem', opacity: 0.4 }}
268
+ >
269
+ <circle cx="11" cy="11" r="8" />
270
+ <path d="m21 21-4.3-4.3" />
271
+ <line x1="8" y1="8" x2="14" y2="14" />
272
+ <line x1="14" y1="8" x2="8" y2="14" />
273
+ </svg>
274
+ No results for "{query}"
275
+ </div>
276
+ )}
277
+ {results.map((result, i) => (
278
+ <button
279
+ key={result.id}
280
+ onClick={() => handleSelect(result.path)}
281
+ style={{
282
+ display: 'block',
283
+ width: '100%',
284
+ textAlign: 'left',
285
+ padding: '0.75rem 1rem',
286
+ border: 'none',
287
+ borderRadius: 'var(--clearify-radius)',
288
+ cursor: 'pointer',
289
+ backgroundColor: selected === i ? 'var(--clearify-primary-soft)' : 'transparent',
290
+ color: 'var(--clearify-text)',
291
+ transition: 'background-color 0.1s',
292
+ fontFamily: 'var(--font-sans)',
293
+ }}
294
+ onMouseEnter={() => setSelected(i)}
295
+ >
296
+ <div
297
+ style={{
298
+ fontWeight: 600,
299
+ fontSize: '0.875rem',
300
+ marginBottom: '0.25rem',
301
+ display: 'flex',
302
+ alignItems: 'center',
303
+ gap: '0.5rem',
304
+ letterSpacing: '-0.01em',
305
+ }}
306
+ >
307
+ <svg
308
+ width="14"
309
+ height="14"
310
+ viewBox="0 0 24 24"
311
+ fill="none"
312
+ stroke={selected === i ? 'var(--clearify-primary)' : 'var(--clearify-text-tertiary)'}
313
+ strokeWidth="2"
314
+ strokeLinecap="round"
315
+ strokeLinejoin="round"
316
+ style={{ flexShrink: 0, transition: 'stroke 0.15s' }}
317
+ >
318
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
319
+ <polyline points="14 2 14 8 20 8" />
320
+ </svg>
321
+ {result.title}
322
+ {result.sectionLabel && (
323
+ <span
324
+ style={{
325
+ fontSize: '0.625rem',
326
+ fontWeight: 600,
327
+ padding: '0.1rem 0.4rem',
328
+ borderRadius: '9999px',
329
+ background: 'var(--clearify-gradient-subtle)',
330
+ border: '1px solid var(--clearify-border)',
331
+ color: 'var(--clearify-text-secondary)',
332
+ whiteSpace: 'nowrap',
333
+ }}
334
+ >
335
+ {result.sectionLabel}
336
+ </span>
337
+ )}
338
+ </div>
339
+ <div
340
+ style={{
341
+ fontSize: '0.8125rem',
342
+ color: 'var(--clearify-text-tertiary)',
343
+ overflow: 'hidden',
344
+ textOverflow: 'ellipsis',
345
+ whiteSpace: 'nowrap',
346
+ paddingLeft: '1.625rem',
347
+ }}
348
+ >
349
+ {getExcerpt(result.content, query)}
350
+ </div>
351
+ </button>
352
+ ))}
353
+ </div>
354
+ </div>
355
+ </div>
356
+ )}
357
+ </>
358
+ );
359
+ }
@@ -0,0 +1,325 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { Link, useLocation } from 'react-router-dom';
3
+ import clsx from 'clsx';
4
+ import type { NavigationItem, SectionNavigation } from '../types/index.js';
5
+
6
+ interface SidebarProps {
7
+ sections: SectionNavigation[];
8
+ open: boolean;
9
+ onClose: () => void;
10
+ }
11
+
12
+ function findActiveSection(pathname: string, sections: SectionNavigation[]): string {
13
+ let bestMatch = sections[0]?.id ?? '';
14
+ let bestLen = 0;
15
+
16
+ for (const section of sections) {
17
+ const bp = section.basePath;
18
+ if (bp === '/' && pathname === '/') {
19
+ if (bestLen === 0) {
20
+ bestMatch = section.id;
21
+ bestLen = 1;
22
+ }
23
+ } else if (bp !== '/' && pathname.startsWith(bp)) {
24
+ const rest = pathname.slice(bp.length);
25
+ if (rest === '' || rest.startsWith('/')) {
26
+ if (bp.length > bestLen) {
27
+ bestMatch = section.id;
28
+ bestLen = bp.length;
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ if (bestLen === 0 && sections.length > 0) {
35
+ bestMatch = sections[0].id;
36
+ }
37
+
38
+ return bestMatch;
39
+ }
40
+
41
+ function SectionSwitcher({
42
+ sections,
43
+ activeId,
44
+ onSelect,
45
+ }: {
46
+ sections: SectionNavigation[];
47
+ activeId: string;
48
+ onSelect: (id: string) => void;
49
+ }) {
50
+ return (
51
+ <div
52
+ style={{
53
+ display: 'flex',
54
+ gap: '0.25rem',
55
+ padding: '0.625rem 1.25rem',
56
+ marginBottom: '0.25rem',
57
+ }}
58
+ >
59
+ {sections.map((section) => {
60
+ const isActive = activeId === section.id;
61
+ return (
62
+ <button
63
+ key={section.id}
64
+ onClick={() => onSelect(section.id)}
65
+ style={{
66
+ padding: '0.3rem 0.75rem',
67
+ borderRadius: '9999px',
68
+ border: 'none',
69
+ fontSize: '0.75rem',
70
+ fontWeight: 600,
71
+ cursor: 'pointer',
72
+ background: isActive ? 'var(--clearify-gradient)' : 'var(--clearify-bg-secondary)',
73
+ color: isActive ? '#fff' : 'var(--clearify-text-secondary)',
74
+ transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
75
+ boxShadow: isActive ? 'var(--clearify-shadow-sm)' : 'none',
76
+ }}
77
+ >
78
+ {section.label}
79
+ </button>
80
+ );
81
+ })}
82
+ </div>
83
+ );
84
+ }
85
+
86
+ export function Sidebar({ sections, open, onClose }: SidebarProps) {
87
+ const location = useLocation();
88
+
89
+ const isSectionData = sections.length > 0 && sections[0]?.id != null && Array.isArray(sections[0]?.navigation);
90
+ const legacyNavigation = !isSectionData ? (sections as unknown as NavigationItem[]) : null;
91
+
92
+ const [selectedSectionId, setSelectedSectionId] = useState(() =>
93
+ isSectionData ? findActiveSection(location.pathname, sections) : ''
94
+ );
95
+
96
+ useEffect(() => {
97
+ if (isSectionData) {
98
+ const active = findActiveSection(location.pathname, sections);
99
+ setSelectedSectionId(active);
100
+ }
101
+ }, [location.pathname, sections, isSectionData]);
102
+
103
+ const sidebarRef = useRef<HTMLElement>(null);
104
+
105
+ useEffect(() => {
106
+ const sidebar = sidebarRef.current;
107
+ if (!sidebar) return;
108
+ // Small delay to allow render to complete
109
+ const timer = setTimeout(() => {
110
+ const activeEl = sidebar.querySelector('[data-active="true"]');
111
+ if (activeEl) {
112
+ activeEl.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
113
+ }
114
+ }, 100);
115
+ return () => clearTimeout(timer);
116
+ }, [location.pathname]);
117
+
118
+ const activeSection = isSectionData
119
+ ? (sections.find((s) => s.id === selectedSectionId) ?? sections[0])
120
+ : null;
121
+ const navigation = legacyNavigation ?? activeSection?.navigation ?? [];
122
+ const showSwitcher = isSectionData && sections.length > 1;
123
+
124
+ return (
125
+ <>
126
+ {/* Mobile overlay */}
127
+ {open && (
128
+ <div
129
+ onClick={onClose}
130
+ style={{
131
+ position: 'fixed',
132
+ inset: 0,
133
+ backgroundColor: 'rgba(0, 0, 0, 0.4)',
134
+ backdropFilter: 'blur(4px)',
135
+ WebkitBackdropFilter: 'blur(4px)',
136
+ zIndex: 40,
137
+ animation: 'clearify-fade-in 0.15s ease-out',
138
+ }}
139
+ className="clearify-sidebar-overlay"
140
+ />
141
+ )}
142
+
143
+ <aside
144
+ ref={sidebarRef}
145
+ style={{
146
+ width: 'var(--clearify-sidebar-width)',
147
+ flexShrink: 0,
148
+ borderRight: '1px solid var(--clearify-border)',
149
+ overflowY: 'auto',
150
+ padding: '0.75rem 0',
151
+ height: 'calc(100vh - var(--clearify-header-height))',
152
+ position: 'sticky',
153
+ top: 'var(--clearify-header-height)',
154
+ backgroundColor: 'var(--clearify-bg)',
155
+ transition: 'transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)',
156
+ }}
157
+ className={clsx('clearify-sidebar', open && 'clearify-sidebar-open')}
158
+ >
159
+ {showSwitcher && (
160
+ <SectionSwitcher
161
+ sections={sections}
162
+ activeId={selectedSectionId}
163
+ onSelect={setSelectedSectionId}
164
+ />
165
+ )}
166
+ <nav style={{ padding: '0 0.5rem' }}>
167
+ {navigation.map((item, i) => (
168
+ <NavItem key={i} item={item} depth={0} onNavigate={onClose} />
169
+ ))}
170
+ </nav>
171
+ </aside>
172
+
173
+ <style>{`
174
+ @media (max-width: 768px) {
175
+ .clearify-sidebar {
176
+ position: fixed !important;
177
+ top: var(--clearify-header-height) !important;
178
+ left: 0;
179
+ z-index: 41;
180
+ transform: translateX(-100%);
181
+ height: calc(100vh - var(--clearify-header-height)) !important;
182
+ box-shadow: var(--clearify-shadow-lg);
183
+ }
184
+ .clearify-sidebar-open {
185
+ transform: translateX(0) !important;
186
+ }
187
+ .clearify-menu-btn {
188
+ display: flex !important;
189
+ }
190
+ }
191
+ `}</style>
192
+ </>
193
+ );
194
+ }
195
+
196
+ function NavItem({ item, depth, onNavigate }: { item: NavigationItem; depth: number; onNavigate: () => void }) {
197
+ const location = useLocation();
198
+ const [expanded, setExpanded] = useState(true);
199
+ const isActive = item.path === location.pathname;
200
+
201
+ if (item.children) {
202
+ return (
203
+ <div style={{ marginBottom: '0.125rem' }}>
204
+ <button
205
+ onClick={() => setExpanded(!expanded)}
206
+ style={{
207
+ display: 'flex',
208
+ alignItems: 'center',
209
+ width: '100%',
210
+ padding: '0.4rem 0.75rem',
211
+ background: 'none',
212
+ border: 'none',
213
+ cursor: 'pointer',
214
+ fontSize: '0.6875rem',
215
+ fontWeight: 600,
216
+ textTransform: 'uppercase',
217
+ letterSpacing: '0.06em',
218
+ color: 'var(--clearify-text-tertiary)',
219
+ marginTop: depth === 0 ? '1.25rem' : 0,
220
+ borderRadius: 'var(--clearify-radius-sm)',
221
+ transition: 'color 0.15s',
222
+ }}
223
+ onMouseEnter={(e) => (e.currentTarget.style.color = 'var(--clearify-text-secondary)')}
224
+ onMouseLeave={(e) => (e.currentTarget.style.color = 'var(--clearify-text-tertiary)')}
225
+ >
226
+ <svg
227
+ width="12"
228
+ height="12"
229
+ viewBox="0 0 24 24"
230
+ fill="none"
231
+ stroke="currentColor"
232
+ strokeWidth="2.5"
233
+ strokeLinecap="round"
234
+ strokeLinejoin="round"
235
+ style={{
236
+ marginRight: '0.375rem',
237
+ transition: 'transform 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
238
+ transform: expanded ? 'rotate(90deg)' : 'rotate(0deg)',
239
+ flexShrink: 0,
240
+ }}
241
+ >
242
+ <polyline points="9 18 15 12 9 6" />
243
+ </svg>
244
+ {item.label}
245
+ </button>
246
+ {expanded && (
247
+ <div style={{ animation: 'clearify-fade-in 0.15s ease-out' }}>
248
+ {item.children.map((child, i) => (
249
+ <NavItem key={i} item={child} depth={depth + 1} onNavigate={onNavigate} />
250
+ ))}
251
+ </div>
252
+ )}
253
+ </div>
254
+ );
255
+ }
256
+
257
+ return (
258
+ <Link
259
+ to={item.path!}
260
+ data-active={isActive ? 'true' : undefined}
261
+ onClick={() => {
262
+ onNavigate();
263
+ window.scrollTo(0, 0);
264
+ }}
265
+ style={{
266
+ display: 'flex',
267
+ alignItems: 'center',
268
+ gap: '0.375rem',
269
+ padding: '0.4rem 0.75rem',
270
+ paddingLeft: `${0.75 + depth * 0.75}rem`,
271
+ fontSize: '0.8125rem',
272
+ fontWeight: isActive ? 600 : 400,
273
+ color: isActive ? 'var(--clearify-primary)' : 'var(--clearify-text-secondary)',
274
+ backgroundColor: isActive ? 'var(--clearify-primary-soft)' : 'transparent',
275
+ borderRadius: 'var(--clearify-radius-sm)',
276
+ textDecoration: 'none',
277
+ transition: 'all 0.15s ease',
278
+ position: 'relative',
279
+ overflow: 'hidden',
280
+ }}
281
+ className="clearify-nav-link"
282
+ >
283
+ {isActive && (
284
+ <span
285
+ style={{
286
+ position: 'absolute',
287
+ left: 0,
288
+ top: '15%',
289
+ bottom: '15%',
290
+ width: 3,
291
+ borderRadius: '0 2px 2px 0',
292
+ background: 'var(--clearify-gradient)',
293
+ }}
294
+ />
295
+ )}
296
+ {item.icon && <span style={{ flexShrink: 0, fontSize: '1rem', lineHeight: 1 }}>{item.icon}</span>}
297
+ <span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{item.label}</span>
298
+ {item.badge && (
299
+ <span style={{
300
+ fontSize: '0.5625rem',
301
+ fontWeight: 700,
302
+ fontFamily: 'var(--font-mono)',
303
+ padding: '0.0625rem 0.3rem',
304
+ borderRadius: '3px',
305
+ backgroundColor: item.badgeColor ?? 'var(--clearify-primary)',
306
+ color: '#fff',
307
+ marginLeft: 'auto',
308
+ flexShrink: 0,
309
+ textTransform: 'uppercase',
310
+ letterSpacing: '0.02em',
311
+ lineHeight: '1.4',
312
+ }}>
313
+ {item.badge}
314
+ </span>
315
+ )}
316
+
317
+ <style>{`
318
+ .clearify-nav-link:hover {
319
+ color: var(--clearify-text) !important;
320
+ background-color: var(--clearify-bg-secondary) !important;
321
+ }
322
+ `}</style>
323
+ </Link>
324
+ );
325
+ }