Skip to content

Commit f206ee0

Browse files
authored
fix: update for version 2 (#1887)
* fix(accordion): update for version 2 * fix: coderabbitai fix * fix(alert): color update, CloseButton update * fix(alert): coderabbitai fix * fix: add src/plugin-utilites * fix: coderabbitai fix * fix(badge): update * fix: coderabbitai fix * fix: add legacy colors to alert and badge * fix(bottom-navigation): update * fix(bottom-navigation): theme * fix(breadcrumb): update and tests * fix(button-group): tests * fix(button): update theme and tests * fix(image): update people image * fix(image): update people image * fix: coderabbitai fix * fix(clipboard): examples update * tests(clipboard): new tests * tests(datepicker): test, add script/sync-plugin-utilities-export * fix: add eslint-disable-next-line for any * fix: initiate tailwindcss colors by adding src/routes/color-test/ * tests(device-mockups): add tests * tests(dialog): unit tests * fix(drawer): update * fix: coderabbitai fix * tests(drawer): drawer and dropdown * tests(footer): add unit tests * fix: coderabbitai fix * fix: coderabbitai fix * tests: button-toggle, checkbox, dropzone, fileupload * fix: coderabbitai fix * tests(floating-label): unit tests * fix: coderabbitai fix
1 parent 18c0c4b commit f206ee0

File tree

519 files changed

+16832
-3251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

519 files changed

+16832
-3251
lines changed

.coderabbit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
reviews:
2+
auto_review:
3+
enabled: true
4+
base_branches:
5+
- ".*"
26
tools:
37
github-checks:
48
timeout_ms: 300000

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ samples/
66
src/routes/md/
77
src/routes/testdir
88
*.html
9-
src/routes/utils/highlight
9+
**/utils/highlight/**
1010
/.vercel
1111
*.md
12+

AGENTS.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

QUICK_START.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Theme Selector - Quick Start Guide
2+
3+
## What's Ready Now ✅
4+
5+
I've made the following changes to fix your theme selector:
6+
7+
### 1. Core Files Updated
8+
- **`layout.css`**: Now loads base Flowbite styles; fonts loaded dynamically
9+
- **`+layout.svelte`**: Properly initializes theme from localStorage
10+
- **`themeStore.svelte.ts`**: Fixed font URLs and theme loading logic
11+
12+
### 2. Working Themes
13+
- **Default** ✅ (`default-runtime.css` created)
14+
- **Enterprise** ✅ (`enterprise-runtime.css` created)
15+
16+
### 3. Themes Still Needing Conversion
17+
- **Minimal**: Need to create `minimal-runtime.css`
18+
- **Playful**: Need to create `playful-runtime.css`
19+
- **Mono**: Need to create `mono-runtime.css`
20+
21+
## Quick Test (5 minutes)
22+
23+
### 1. Test What's Working Now
24+
```bash
25+
npm run dev
26+
```
27+
28+
Visit `/theme-test` and try switching between **Default** and **Enterprise** themes. You should see:
29+
- Colors change (blue → cyan for Enterprise)
30+
- Fonts change (Inter → STIX Two Text for Enterprise)
31+
- All components update instantly
32+
33+
### 2. Complete the Setup
34+
35+
**Option A: Manual (Fastest)**
36+
For each remaining theme file (`minimal.css`, `playful.css`, `mono.css`):
37+
38+
1. Copy the file to a `-runtime.css` version
39+
2. Open it and replace `@theme {` with `:root {`
40+
3. Save the file
41+
42+
**Option B: Automated**
43+
```bash
44+
node convertThemes.js
45+
```
46+
47+
Then update `themeStore.svelte.ts` to use `-runtime.css` for the remaining themes.
48+
49+
## Why This Fix Was Needed
50+
51+
**The Problem**: Tailwind CSS v4's `@theme` directive is a compile-time feature. Your theme files are in `static/themes/` (not processed at build time), so when loaded dynamically, the `@theme` blocks don't work.
52+
53+
**The Solution**: Convert `@theme {}` to `:root {}` so they work as standard CSS custom properties at runtime.
54+
55+
## Notes
56+
57+
### Google Sans Code Font Issue
58+
The `mono` theme uses "Google Sans Code", which isn't publicly available on Google Fonts (it's proprietary). You have two options:
59+
60+
1. **Keep it**: The browser will fall back to system monospace fonts
61+
2. **Replace it**: Change to "Roboto Mono" or "JetBrains Mono" in both:
62+
- `static/themes/mono.css` (and `mono-runtime.css`)
63+
- `themeStore.svelte.ts`
64+
65+
### How Dynamic Loading Works
66+
67+
1. Base theme from Flowbite provides foundational CSS variables
68+
2. When you switch themes:
69+
- Old theme CSS and fonts are removed
70+
- New theme's font loads from Google Fonts
71+
- New theme's CSS loads and overrides base variables
72+
- Style recalculation is triggered
73+
3. Theme choice saved to localStorage for persistence
74+
75+
## Troubleshooting
76+
77+
### Theme doesn't change
78+
- Check browser console for CSS load errors
79+
- Verify the `-runtime.css` file exists in `static/themes/`
80+
- Check Network tab to see if CSS file is loading (200 status)
81+
82+
### Fonts don't change
83+
- Verify font URL in `themeStore.svelte.ts` matches font in CSS file
84+
- Check Network tab for font file loads
85+
- Some fonts may take a moment to load
86+
87+
### Colors look wrong
88+
- Make sure you're using the `-runtime.css` version
89+
- Check that `:root {` is used instead of `@theme {`
90+
- Clear browser cache and reload
91+
92+
## Testing Checklist
93+
94+
- [ ] Default theme loads on page load
95+
- [ ] Enterprise theme works when selected
96+
- [ ] Switch between Default and Enterprise multiple times
97+
- [ ] Reload page - theme persists from localStorage
98+
- [ ] Convert remaining themes (Minimal, Playful, Mono)
99+
- [ ] Test all 5 themes work correctly
100+
- [ ] Test theme switching in light and dark modes
101+
- [ ] Verify fonts load and change correctly
102+
103+
## Next Steps
104+
105+
Once all themes are converted and working:
106+
1. You can delete the original `.css` files (keep only `-runtime.css`)
107+
2. Remove the `convertThemes.js` script if you used it
108+
3. Update your README with theme switching info
109+
110+
Need help? Check `THEME_SELECTOR_FIX.md` for detailed explanation!

THEME_SELECTOR_FIX.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Theme Selector Fix - Summary
2+
3+
## The Problem
4+
Your theme CSS files use Tailwind CSS v4's `@theme` directive, which is a **compile-time directive**. When these files are loaded dynamically at runtime from the `static/themes/` directory, the `@theme` blocks don't work because they're not being processed by Tailwind's compiler.
5+
6+
## The Solution
7+
Convert all theme CSS files to use standard CSS `:root {}` blocks instead of `@theme {}` blocks. This allows them to work when loaded dynamically at runtime.
8+
9+
## What I've Done
10+
11+
### 1. Updated `layout.css`
12+
- Removed static font imports
13+
- Kept base Flowbite theme (`flowbite/src/themes/themes.css`) for foundational variables
14+
- Font loading is now handled dynamically by the theme store
15+
16+
### 2. Updated `+layout.svelte`
17+
- Now loads the saved theme initially for better SSR/first render
18+
- Properly initializes the theme on mount
19+
20+
### 3. Fixed `themeStore.svelte.ts`
21+
- Fixed font URLs to match actual fonts in theme CSS files
22+
- Improved theme loading logic to remove ALL existing theme links
23+
- Added better style recalculation after theme loads
24+
25+
### 4. Created `enterprise-runtime.css`
26+
- This is the enterprise theme converted to use `:root {}` instead of `@theme {}`
27+
- Updated the themeStore to use this file for the enterprise theme
28+
29+
## What You Need To Do
30+
31+
### Option 1: Quick Manual Conversion (Recommended)
32+
For each theme file in `static/themes/`, create a `-runtime.css` version:
33+
34+
1. Copy the file (e.g., `default.css``default-runtime.css`)
35+
2. Replace `@theme {` with `:root {`
36+
3. Save the file
37+
38+
### Option 2: Use the Conversion Script
39+
I've created `convertThemes.js` in your project root:
40+
41+
```bash
42+
node convertThemes.js
43+
```
44+
45+
This will automatically create `-runtime.css` versions of all your theme files.
46+
47+
### After Conversion
48+
Update `themeStore.svelte.ts` to use the `-runtime.css` files:
49+
50+
```typescript
51+
const themes: Theme[] = [
52+
{
53+
id: "default",
54+
name: "Default",
55+
cssPath: "/themes/default-runtime.css", // Add -runtime
56+
fontUrl: "https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap",
57+
colors: ["bg-gray-100 dark:bg-gray-700", "bg-blue-50 dark:bg-blue-900", "bg-blue-200 dark:bg-blue-800", "bg-blue-700 dark:bg-blue-700"]
58+
},
59+
{
60+
id: "minimal",
61+
name: "Minimal",
62+
cssPath: "/themes/minimal-runtime.css", // Add -runtime
63+
fontUrl: "https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap",
64+
colors: ["bg-stone-50 dark:bg-stone-600", "bg-stone-100 dark:bg-stone-700", "bg-stone-300 dark:bg-stone-800", "bg-stone-900 dark:bg-stone-900"]
65+
},
66+
// Enterprise is already done!
67+
{
68+
id: "enterprise",
69+
name: "Enterprise",
70+
cssPath: "/themes/enterprise-runtime.css",
71+
fontUrl: "https://fonts.googleapis.com/css2?family=STIX+Two+Text:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap",
72+
colors: ["bg-zinc-100 dark:bg-zinc-700", "bg-cyan-50 dark:bg-cyan-900", "bg-cyan-100 dark:bg-cyan-800", "bg-cyan-700 dark:bg-cyan-700"]
73+
},
74+
{
75+
id: "playful",
76+
name: "Playful",
77+
cssPath: "/themes/playful-runtime.css", // Add -runtime
78+
fontUrl: "https://fonts.googleapis.com/css2?family=Shantell+Sans:ital,wght@0,300..800;1,300..800&display=swap",
79+
colors: ["bg-slate-100 dark:bg-slate-700", "bg-pink-50 dark:bg-pink-900", "bg-pink-100 dark:bg-pink-800", "bg-pink-700 dark:bg-pink-700"]
80+
},
81+
{
82+
id: "mono",
83+
name: "Mono",
84+
cssPath: "/themes/mono-runtime.css", // Add -runtime
85+
fontUrl: "https://fonts.googleapis.com/css2?family=Google+Sans+Code:wght@300;400;500;600;700&display=swap",
86+
colors: ["bg-neutral-100 dark:bg-neutral-700", "bg-indigo-50 dark:bg-indigo-900", "bg-indigo-100 dark:bg-indigo-800", "bg-indigo-700 dark:bg-indigo-700"]
87+
}
88+
];
89+
```
90+
91+
## Testing
92+
93+
1. **Test Enterprise Theme First**: I've already converted this one, so switch to the Enterprise theme and see if colors/fonts change
94+
2. **Convert Other Themes**: Use one of the methods above to convert the remaining themes
95+
3. **Update themeStore**: Update all paths to use `-runtime.css` versions
96+
4. **Test All Themes**: Visit `/theme-test` and try switching between all themes
97+
98+
## How It Works Now
99+
100+
1. Base Flowbite theme is loaded from `layout.css` (provides foundational styles)
101+
2. When you select a theme, JavaScript:
102+
- Removes any existing theme CSS links
103+
- Loads the new theme's font from Google Fonts
104+
- Loads the new theme's CSS variables (runtime version)
105+
- Forces a style recalculation
106+
3. CSS variables from the runtime theme override the base theme
107+
4. Theme preference is saved to localStorage
108+
109+
## Why This Works
110+
111+
- CSS custom properties (variables) can be changed at runtime
112+
- Later-loaded stylesheets override earlier ones
113+
- The `-runtime.css` files use standard `:root {}` blocks that work at runtime
114+
- Font loading is dynamic and matches the theme
115+
116+
The theme selector should now work perfectly! Let me know if you need help with the conversion or run into any issues.

TROUBLESHOOTING.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Troubleshooting TypeScript Errors
2+
3+
## If you're seeing "validation does not exist in type FloatingLabelInputProps"
4+
5+
This is a TypeScript caching issue. The types ARE correct in `src/lib/types.ts` (lines 772-786), but TypeScript/Svelte language server may need to reload.
6+
7+
### Solutions (try in order):
8+
9+
1. **Restart TypeScript Server in VS Code**
10+
- Press `Cmd+Shift+P` (Mac) or `Ctrl+Shift+P` (Windows/Linux)
11+
- Type: "TypeScript: Restart TS Server"
12+
- Press Enter
13+
14+
2. **Reload VS Code Window**
15+
- Press `Cmd+Shift+P` (Mac) or `Ctrl+Shift+P` (Windows/Linux)
16+
- Type: "Developer: Reload Window"
17+
- Press Enter
18+
19+
3. **Clear node_modules and reinstall**
20+
```bash
21+
rm -rf node_modules
22+
npm install
23+
```
24+
25+
4. **Clear Svelte language server cache**
26+
```bash
27+
rm -rf ~/.vscode/extensions/svelte.svelte-vscode-*/
28+
```
29+
30+
5. **Build the project**
31+
```bash
32+
npm run build
33+
```
34+
35+
## What was changed?
36+
37+
### FloatingLabelInputProps (in `src/lib/types.ts`)
38+
**Removed:**
39+
- `color?: FloatingLabelInputVaratiants["color"]`
40+
41+
**Added:**
42+
- `validation?: FloatingLabelInputVaratiants["validation"]` - New semantic validation states (none, success, error)
43+
- `disabled?: FloatingLabelInputVaratiants["disabled"]` - Explicit disabled state
44+
- `withIcon?: FloatingLabelInputVaratiants["withIcon"]` - Icon support flag
45+
46+
### Theme changes (in `src/lib/forms/floating-label/theme.ts`)
47+
**Removed:**
48+
- All individual color variants (primary, red, green, blue, etc.)
49+
50+
**Added:**
51+
- `validation` variant with three semantic states:
52+
- `none` - Default state
53+
- `success` - Success state with green colors
54+
- `error` - Error state with red colors
55+
- `disabled` variant for proper disabled styling
56+
- `withIcon` variant for icon alignment
57+
58+
### Component changes (in `FloatingLabelInput.svelte`)
59+
**Updated props:**
60+
```typescript
61+
// OLD
62+
color = "brand"
63+
64+
// NEW
65+
validation = "none"
66+
disabled = false
67+
withIcon = false
68+
```
69+
70+
## Usage Examples
71+
72+
```svelte
73+
<!-- Default -->
74+
<FloatingLabelInput>Label</FloatingLabelInput>
75+
76+
<!-- Success -->
77+
<FloatingLabelInput validation="success">Success Label</FloatingLabelInput>
78+
79+
<!-- Error -->
80+
<FloatingLabelInput validation="error">Error Label</FloatingLabelInput>
81+
82+
<!-- Disabled -->
83+
<FloatingLabelInput disabled={true}>Disabled Label</FloatingLabelInput>
84+
85+
<!-- With icon -->
86+
<FloatingLabelInput withIcon={true}>
87+
<EnvelopeOutline class="w-4 h-4 me-1.5" />
88+
Email
89+
</FloatingLabelInput>
90+
```

clear-cache.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Usage: Stop your dev server before running this script.
3+
# This script clears build caches and requires a dev server restart.
4+
5+
echo "Clearing build caches..."
6+
7+
# Remove .svelte-kit directory
8+
rm -rf .svelte-kit || echo "Warning: Failed to remove .svelte-kit"
9+
10+
# Remove node_modules/.vite cache
11+
rm -rf node_modules/.vite || echo "Warning: Failed to remove node_modules/.vite"
12+
13+
echo "Caches cleared! Now restart your dev server with: pnpm dev"

0 commit comments

Comments
 (0)