|
| 1 | +import { |
| 2 | + PanelTop, |
| 3 | + Minus, |
| 4 | + Layers, |
| 5 | + StickyNote, |
| 6 | + Navigation, |
| 7 | + MousePointer2, |
| 8 | + PanelLeft, |
| 9 | + GalleryHorizontal, |
| 10 | + Box, |
| 11 | + Columns, |
| 12 | + Layout, |
| 13 | + Moon, |
| 14 | +} from "lucide-react"; |
| 15 | +import type { LucideIcon } from "lucide-react"; |
| 16 | + |
| 17 | +export interface ExampleEntry { |
| 18 | + slug: string; |
| 19 | + title: string; |
| 20 | + description: string; |
| 21 | + icon: LucideIcon; |
| 22 | + code: string; |
| 23 | +} |
| 24 | + |
| 25 | +export interface ExampleCategory { |
| 26 | + id: string; |
| 27 | + title: string; |
| 28 | + examples: ExampleEntry[]; |
| 29 | +} |
| 30 | + |
| 31 | +export const categories: ExampleCategory[] = [ |
| 32 | + { |
| 33 | + id: "headers", |
| 34 | + title: "Headers", |
| 35 | + examples: [ |
| 36 | + { |
| 37 | + slug: "fixed-header", |
| 38 | + title: "Fixed Header", |
| 39 | + description: |
| 40 | + "A header that stays pinned to the top of the viewport as the user scrolls through content.", |
| 41 | + icon: PanelTop, |
| 42 | + code: `<AppShell>\n <Header behavior="fixed" logo={...} nav={...} />\n <Content>...</Content>\n</AppShell>`, |
| 43 | + }, |
| 44 | + { |
| 45 | + slug: "static-header", |
| 46 | + title: "Static Header", |
| 47 | + description: |
| 48 | + "A header that scrolls naturally with the page content, disappearing as the user scrolls down.", |
| 49 | + icon: Minus, |
| 50 | + code: `<AppShell>\n <Header behavior="static" logo={...} />\n <Content>...</Content>\n</AppShell>`, |
| 51 | + }, |
| 52 | + { |
| 53 | + slug: "reveal-all", |
| 54 | + title: "Reveal Header", |
| 55 | + description: |
| 56 | + "The header hides on scroll down and reveals all rows when the user scrolls back up.", |
| 57 | + icon: Layers, |
| 58 | + code: `<AppShell>\n <Header behavior="reveal-all" logo={...} title="..." />\n <Content>...</Content>\n</AppShell>`, |
| 59 | + }, |
| 60 | + { |
| 61 | + slug: "sticky-tabs", |
| 62 | + title: "Sticky Tabs", |
| 63 | + description: |
| 64 | + "A fixed header with a secondary tab bar that sticks below it using CSS variable syncing.", |
| 65 | + icon: StickyNote, |
| 66 | + code: `<Header behavior="fixed" />\n{/* Tabs use var(--header-height) for sticky offset */}\n<div style={{ top: "var(--header-height)" }} className="sticky" />`, |
| 67 | + }, |
| 68 | + ], |
| 69 | + }, |
| 70 | + { |
| 71 | + id: "footers", |
| 72 | + title: "Footers", |
| 73 | + examples: [ |
| 74 | + { |
| 75 | + slug: "tab-bar", |
| 76 | + title: "Tab Bar", |
| 77 | + description: |
| 78 | + "A standard mobile bottom navigation with 5 items, badges, and auto-hide on scroll.", |
| 79 | + icon: Navigation, |
| 80 | + code: `<Footer variant="tab-bar" behavior="auto-hide">\n <FooterItem icon={<Home />} label="Home" active />\n <FooterItem icon={<Search />} label="Search" />\n</Footer>`, |
| 81 | + }, |
| 82 | + { |
| 83 | + slug: "floating-footer", |
| 84 | + title: "Floating Action", |
| 85 | + description: |
| 86 | + "An elevated floating action button for primary actions like cart, compose, or create.", |
| 87 | + icon: MousePointer2, |
| 88 | + code: `<Footer variant="floating" position="center">\n <button className="rounded-full bg-primary px-7 py-3.5">\n Show Cart\n </button>\n</Footer>`, |
| 89 | + }, |
| 90 | + ], |
| 91 | + }, |
| 92 | + { |
| 93 | + id: "layout", |
| 94 | + title: "Layout", |
| 95 | + examples: [ |
| 96 | + { |
| 97 | + slug: "sidebar", |
| 98 | + title: "Sidebar Menu", |
| 99 | + description: |
| 100 | + "A slide-out drawer with backdrop overlay, keyboard dismiss, and smooth animations.", |
| 101 | + icon: PanelLeft, |
| 102 | + code: `<Sidebar open={open} onClose={() => setOpen(false)}>\n <NavGroup label="Navigation">\n <NavItem label="Home" icon={<Home />} />\n </NavGroup>\n</Sidebar>`, |
| 103 | + }, |
| 104 | + { |
| 105 | + slug: "nested-scroll", |
| 106 | + title: "Nested Scroll", |
| 107 | + description: |
| 108 | + "Netflix-style layout with horizontal carousels nested inside vertical scrolling content.", |
| 109 | + icon: GalleryHorizontal, |
| 110 | + code: `<Content>\n {sections.map(section => (\n <div className="overflow-x-auto snap-x snap-mandatory">\n {section.items.map(item => <Card />)}\n </div>\n ))}\n</Content>`, |
| 111 | + }, |
| 112 | + { |
| 113 | + slug: "scroll-nav", |
| 114 | + title: "Scroll Navigation", |
| 115 | + description: |
| 116 | + "Horizontal pill-style scrollable tabs for category filtering and section navigation.", |
| 117 | + icon: Box, |
| 118 | + code: `<Header searchContent={\n <ScrollNav>\n <ScrollNavItem label="All" active />\n <ScrollNavItem label="Tech" />\n </ScrollNav>\n} />`, |
| 119 | + }, |
| 120 | + { |
| 121 | + slug: "desktop-nav", |
| 122 | + title: "Desktop Nav", |
| 123 | + description: |
| 124 | + "Horizontal navigation with dropdown menus that adapts from mobile hamburger to desktop layout.", |
| 125 | + icon: Columns, |
| 126 | + code: `<Header\n nav={<HeaderNav>\n <HeaderNavItem label="Products" dropdown={...} />\n </HeaderNav>}\n mobileMenu={<NavGroup>...</NavGroup>}\n/>`, |
| 127 | + }, |
| 128 | + ], |
| 129 | + }, |
| 130 | + { |
| 131 | + id: "patterns", |
| 132 | + title: "Patterns", |
| 133 | + examples: [ |
| 134 | + { |
| 135 | + slug: "reveal-combined", |
| 136 | + title: "Combined Reveal", |
| 137 | + description: |
| 138 | + "The most complex pattern: header reveals on scroll up while footer auto-hides on scroll down.", |
| 139 | + icon: Layout, |
| 140 | + code: `<AppShell>\n <Header behavior="reveal-all" />\n <Content>...</Content>\n <Footer behavior="auto-hide" />\n</AppShell>`, |
| 141 | + }, |
| 142 | + { |
| 143 | + slug: "dark-mode", |
| 144 | + title: "Dark Mode", |
| 145 | + description: |
| 146 | + "Live theme switching using CSS custom properties and the shadcn token system.", |
| 147 | + icon: Moon, |
| 148 | + code: `// Toggle .dark class on <html>\ndocument.documentElement.classList.toggle("dark");\n\n// All components use --background, --foreground tokens`, |
| 149 | + }, |
| 150 | + ], |
| 151 | + }, |
| 152 | +]; |
| 153 | + |
| 154 | +export function findExample( |
| 155 | + slug: string |
| 156 | +): { category: ExampleCategory; example: ExampleEntry } | null { |
| 157 | + for (const category of categories) { |
| 158 | + const example = category.examples.find((e) => e.slug === slug); |
| 159 | + if (example) return { category, example }; |
| 160 | + } |
| 161 | + return null; |
| 162 | +} |
| 163 | + |
| 164 | +export function getAllExamples(): ExampleEntry[] { |
| 165 | + return categories.flatMap((c) => c.examples); |
| 166 | +} |
0 commit comments