-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Zero-config theme system with virtual modules and runtime switching (fixes #101) #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VAIBHAVSING
wants to merge
18
commits into
accretional:main
Choose a base branch
from
VAIBHAVSING:feature/theme-selector-101
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Zero-config theme system with virtual modules and runtime switching (fixes #101) #106
VAIBHAVSING
wants to merge
18
commits into
accretional:main
from
VAIBHAVSING:feature/theme-selector-101
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1c83a69 to
ecb1e14
Compare
VAIBHAVSING
commented
Dec 30, 2025
Contributor
|
it says this is a draft, what are we waiting for here? |
Author
|
some architectural and developer exprience improvement needed |
- Changed import from './vite-plugin/index.js' to 'statue-ssg/vite-plugin' - This allows vite.config.js to work for both development and when distributed via npm - Fixes Docker test failure where installed package couldn't resolve local path - Also updated content/docs/themes.md with comprehensive theme system docs
Contributor
|
Let's hold off on further reviewing until #93 is ready |
This reverts commit b112aa1.
- Fix FOUC (Flash of Unstyled Content): - Moved script injection to `transformPageChunk` hook for earlier execution. - Added runtime sanitization to `src/hooks.server.js` to handle legacy localStorage values (e.g. collapsing 'black--white' to 'black-white'). - Improve Accessibility: - Added ARIA roles (listbox, option) to ThemeSelector. - Implemented full keyboard navigation (Arrow keys, Enter, Escape, Tab). - Fix Build Issues: - Refactored `Stats.svelte` to use CSS variables for colors, resolving Tailwind dynamic class extraction warnings. - Fix Logic: - Updated `toKebabCase` in `vite-plugin` to correctly collapse multiple dashes. - Shared `THEME_STORAGE_KEY` constant across files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements a production-ready theme system with zero-config auto-detection, virtual modules, and runtime theme switching via
data-themeattributes.Architecture Highlights
site.config.js, no manual config neededdata-themeswitching - Instant theme changes via HTML attributeCloses #101
screenshot
Key Features
🔌 Vite Plugin (
statue-ssg/vite-plugin)Zero-config auto-detection:
What it does:
site.config.jsand finds theme configuration@theme {}and:root {})--color-*variablesvirtual:statue-themes- Theme metadata (JS)virtual:statue-themes.css- Combined CSS with:root+html[data-theme="..."]selectors🎨 Theme Configuration
In
site.config.js:🎯 Usage
In layout:
Theme switching:
document.documentElement.dataset.theme = 'blue'Implementation Details
Files Changed
Vite Plugin:
vite-plugin/index.js- Theme parsing and virtual module generationvite-plugin/README.md- Plugin documentationvite-plugin/package.json- Module configurationComponents:
src/lib/components/ThemeSelector.svelte- Dropdown theme switchersrc/lib/components/NavigationBar.svelte- Integrated ThemeSelectorsrc/declarations.d.ts- TypeScript declarations for virtual modulesConfiguration:
vite.config.js- AddedstatueThemesPlugin()site.config.js- Theme configurationpackage.json- Added./vite-pluginexportThemes:
src/lib/themes/*.css- 9 built-in themessrc/lib/themes/README.md- Theme documentationDocumentation:
content/docs/themes.md- User-facing documentationvite-plugin/README.md- Plugin usage guideLayout & Routing:
src/routes/+layout.svelte- Imports virtual theme CSSsrc/hooks.server.js- Removed unnecessary SSR theme injectionRemoved (no longer needed):
src/lib/themes/index.ts- Replaced by virtual modulesrc/routes/api/save-theme/+server.js- Not needed (localStorage)How It Works
Build Time:
Generated CSS structure:
Runtime:
Developer Experience Improvements
Before (PR #106 - had issues):
fsat runtime (breaks in browser)/api/save-themeendpoint (dev-only)After (this PR):
Zero-Config Example
vite.config.js (simplified):
Plugin automatically:
site.config.jssiteConfig.themeTesting
Manual Testing (Completed)
Dev Server:
✅ All 9 themes load correctly
✅ Auto-detection works
✅ Theme switching instant
✅ localStorage persistence works
Production Build:
✅ Static build succeeds
✅ All theme CSS in bundle
✅
html[data-theme="..."]selectors present✅ No runtime errors
User Repository Test:
statue-ssgto test repo (/home/vsing/code/osp/new/)statue-ssg/themes/*→ correct files)Test Checklist
Migration Guide
For users upgrading from old
@importapproach:Before:
After:
src/lib/index.cssvite.config.js(see above)site.config.js(see above)virtual:statue-themes.cssin layoutDocumentation
vite-plugin/README.md- Plugin usage and APIsrc/lib/themes/README.md- Theme system overviewcontent/docs/themes.md- User-facing docs (rendered at/docs/themes)All docs updated to reflect new architecture.
Breaking Changes
@importapproachUsers need to:
site.config.jsMigration is straightforward (see Migration Guide above).