Skip to content

Commit 0d6aa84

Browse files
PJCoopsclaude
andcommitted
feat: Add Vite support and pattern documentation
- Add "Using with Vite" docs page for non-Next.js setups - Add Dashboard, Data Tables, Settings, Empty & Loading pattern pages - Move docs-only deps to devDependencies (removes Next.js transitive dep) - Fix HTML nesting error on themes page The package is now fully Vite-compatible with zero Next.js dependencies. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f8a394e commit 0d6aa84

10 files changed

Lines changed: 2160 additions & 12 deletions

File tree

CLAUDE.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,76 @@ export default function RootLayout({ children }) {
713713
}
714714
```
715715

716+
#### Using with Vite (Non-Next.js Projects)
717+
718+
The design system is fully compatible with Vite, Create React App, and other non-Next.js setups. The only difference is handling dark mode yourself instead of using `next-themes`.
719+
720+
```tsx
721+
// main.tsx or App.tsx
722+
import { useState, useEffect } from "react"
723+
import { DesignSystemProvider, Button, Card } from "@sourceful-energy/ui"
724+
import "@sourceful-energy/ui/styles.css" // MUST be imported
725+
import "./index.css" // Your styles second
726+
727+
function App() {
728+
// Handle dark mode yourself (replaces next-themes)
729+
const [darkMode, setDarkMode] = useState(() =>
730+
window.matchMedia("(prefers-color-scheme: dark)").matches
731+
)
732+
733+
// Toggle .dark class on <html> - this is all that's needed!
734+
useEffect(() => {
735+
document.documentElement.classList.toggle("dark", darkMode)
736+
}, [darkMode])
737+
738+
return (
739+
// DesignSystemProvider handles visual theme + accessibility
740+
<DesignSystemProvider defaultTheme="elevated">
741+
<div className="min-h-screen bg-background text-foreground">
742+
<Button onClick={() => setDarkMode(!darkMode)}>
743+
{darkMode ? "Light Mode" : "Dark Mode"}
744+
</Button>
745+
746+
{/* All components work exactly the same */}
747+
<Card>
748+
<CardHeader>
749+
<CardTitle>Works in Vite!</CardTitle>
750+
</CardHeader>
751+
</Card>
752+
</div>
753+
</DesignSystemProvider>
754+
)
755+
}
756+
```
757+
758+
**Key points for Vite users:**
759+
760+
1. **No Next.js dependencies** - The npm package has zero Next.js dependencies
761+
2. **Dark mode** - Toggle the `.dark` class on `<html>` yourself (2 lines of code)
762+
3. **DesignSystemProvider** - Handles themes (`base`/`elevated`) and accessibility modes
763+
4. **All hooks work** - `useAccessibility()`, `useFontMode()`, etc. are pure React
764+
765+
**Accessibility settings in Vite:**
766+
767+
```tsx
768+
import { useAccessibility } from "@sourceful-energy/ui"
769+
770+
function AccessibilityPanel() {
771+
const {
772+
fontMode, setFontMode, // "default" | "dyslexic"
773+
colorMode, setColorMode, // color blind modes
774+
spacingMode, setSpacingMode // text spacing
775+
} = useAccessibility()
776+
777+
return (
778+
<Switch
779+
checked={fontMode === "dyslexic"}
780+
onCheckedChange={(v) => setFontMode(v ? "dyslexic" : "default")}
781+
/>
782+
)
783+
}
784+
```
785+
716786
#### Critical Setup (Existing Projects / Reskinning)
717787

718788
**Before making any changes, verify:**

0 commit comments

Comments
 (0)