eva-css-fluid 2.0.5 → 2.0.6
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.
- package/README.md +287 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -219,15 +219,22 @@ npm run build
|
|
|
219
219
|
|
|
220
220
|
1. Copy the build script template:
|
|
221
221
|
```bash
|
|
222
|
-
#
|
|
223
|
-
|
|
222
|
+
# Create scripts directory if needed
|
|
223
|
+
mkdir -p scripts
|
|
224
|
+
|
|
225
|
+
# Copy the ready-to-use script from the monorepo examples
|
|
226
|
+
cp node_modules/eva-css-fluid/../../examples/user-scripts/build-with-config.js scripts/build-eva.js
|
|
227
|
+
|
|
228
|
+
# Or download directly from GitHub
|
|
229
|
+
curl -o scripts/build-eva.js https://raw.githubusercontent.com/nkdeus/eva-framework/main/examples/user-scripts/build-with-config.js
|
|
224
230
|
```
|
|
225
231
|
|
|
226
232
|
2. Add npm script to your `package.json`:
|
|
227
233
|
```json
|
|
228
234
|
{
|
|
229
235
|
"scripts": {
|
|
230
|
-
"build:css": "node scripts/build-eva.js styles/main.scss dist/main.css"
|
|
236
|
+
"build:css": "node scripts/build-eva.js styles/main.scss dist/main.css",
|
|
237
|
+
"watch:css": "nodemon --watch eva.config.cjs --watch styles/ --exec 'npm run build:css'"
|
|
231
238
|
}
|
|
232
239
|
}
|
|
233
240
|
```
|
|
@@ -237,6 +244,14 @@ npm run build
|
|
|
237
244
|
npm run build:css
|
|
238
245
|
```
|
|
239
246
|
|
|
247
|
+
**What the script does:**
|
|
248
|
+
- Reads your `eva.config.cjs` configuration
|
|
249
|
+
- Converts JSON config → SCSS variables
|
|
250
|
+
- Compiles SCSS with the injected config
|
|
251
|
+
- Handles HEX → OKLCH color conversion automatically
|
|
252
|
+
|
|
253
|
+
📚 **See [examples/user-scripts/README.md](../../examples/user-scripts/README.md) for detailed documentation**
|
|
254
|
+
|
|
240
255
|
✅ **Advantages:**
|
|
241
256
|
- Single config file shared across multiple SCSS files
|
|
242
257
|
- Config validation with `npx eva-css validate`
|
|
@@ -377,6 +392,30 @@ module.exports = {
|
|
|
377
392
|
};
|
|
378
393
|
```
|
|
379
394
|
|
|
395
|
+
**Real-world example** (Tailwind colors to EVA theme):
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
// Extract colors from your design system
|
|
399
|
+
module.exports = {
|
|
400
|
+
theme: {
|
|
401
|
+
name: 'myproject',
|
|
402
|
+
colors: {
|
|
403
|
+
brand: '#3b82f6', // Tailwind blue-500
|
|
404
|
+
accent: '#22c55e', // Tailwind green-500
|
|
405
|
+
extra: '#a855f7' // Tailwind purple-500
|
|
406
|
+
},
|
|
407
|
+
lightMode: { lightness: 98, darkness: 10 },
|
|
408
|
+
darkMode: { lightness: 8, darkness: 95 },
|
|
409
|
+
autoSwitch: true // Auto dark mode with prefers-color-scheme
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**These HEX colors are automatically converted to:**
|
|
415
|
+
- `#3b82f6` → `oklch(57.4% 0.213 263.8)` (perceptually uniform blue)
|
|
416
|
+
- `#22c55e` → `oklch(72.6% 0.200 147.6)` (perceptually uniform green)
|
|
417
|
+
- `#a855f7` → `oklch(60.8% 0.248 302.7)` (perceptually uniform purple)
|
|
418
|
+
|
|
380
419
|
**Available colors:** `brand`, `accent`, `extra`, `dark`, `light`
|
|
381
420
|
|
|
382
421
|
**Color formats:**
|
|
@@ -612,6 +651,251 @@ var(--brand-b_) // More brighter
|
|
|
612
651
|
}
|
|
613
652
|
```
|
|
614
653
|
|
|
654
|
+
## ❗ Troubleshooting
|
|
655
|
+
|
|
656
|
+
### Common Issues and Solutions
|
|
657
|
+
|
|
658
|
+
#### "The target selector was not found" with @extend
|
|
659
|
+
|
|
660
|
+
**Error:**
|
|
661
|
+
```
|
|
662
|
+
Error: The target selector was not found.
|
|
663
|
+
Use "@extend .w-64 !optional" to avoid this error.
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
**Cause:** You're using `@use` instead of `@forward` when trying to extend EVA classes.
|
|
667
|
+
|
|
668
|
+
**Solution:** Use `@forward` to expose EVA classes in your module:
|
|
669
|
+
|
|
670
|
+
```scss
|
|
671
|
+
// ❌ Wrong - @use doesn't expose classes for @extend
|
|
672
|
+
@use 'eva-css-fluid';
|
|
673
|
+
|
|
674
|
+
.my-class {
|
|
675
|
+
@extend .w-64; // Error!
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// ✅ Correct - @forward exposes classes
|
|
679
|
+
@forward 'eva-css-fluid';
|
|
680
|
+
|
|
681
|
+
.my-class {
|
|
682
|
+
@extend .w-64; // Works!
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
#### Theme colors not appearing in compiled CSS
|
|
687
|
+
|
|
688
|
+
**Problem:** You defined colors in `eva.config.cjs` but they don't show up in the output CSS.
|
|
689
|
+
|
|
690
|
+
**Solutions:**
|
|
691
|
+
|
|
692
|
+
1. **Using JSON config?** Make sure you're using the build script:
|
|
693
|
+
```bash
|
|
694
|
+
# Won't work - SCSS can't read .cjs files
|
|
695
|
+
npx sass styles/main.scss dist/main.css
|
|
696
|
+
|
|
697
|
+
# Use this instead
|
|
698
|
+
node scripts/build-eva.js styles/main.scss dist/main.css
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
2. **Import colors module** if using SCSS variables:
|
|
702
|
+
```scss
|
|
703
|
+
@use 'eva-css-fluid/src/colors' with (
|
|
704
|
+
$theme-name: 'myapp',
|
|
705
|
+
$theme-colors: (
|
|
706
|
+
brand: (lightness: 62.8, chroma: 0.258, hue: 29.23),
|
|
707
|
+
// ... more colors
|
|
708
|
+
)
|
|
709
|
+
);
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
3. **Apply theme class in HTML:**
|
|
713
|
+
```html
|
|
714
|
+
<!-- Without this class, theme colors won't be active -->
|
|
715
|
+
<body class="current-theme theme-myapp">
|
|
716
|
+
<h1 class="_c-brand">Now this works!</h1>
|
|
717
|
+
</body>
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
#### HEX colors not converting to OKLCH
|
|
721
|
+
|
|
722
|
+
**Problem:** You put HEX colors in `eva.config.cjs` but get an error or they don't work.
|
|
723
|
+
|
|
724
|
+
**Cause:** The build script needs `eva-colors` to convert HEX → OKLCH automatically.
|
|
725
|
+
|
|
726
|
+
**Solution:**
|
|
727
|
+
|
|
728
|
+
1. Install `eva-colors` as a dependency:
|
|
729
|
+
```bash
|
|
730
|
+
npm install eva-colors
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
2. Or convert colors manually:
|
|
734
|
+
```bash
|
|
735
|
+
npx eva-color convert "#ff5733"
|
|
736
|
+
# Output: oklch(62.8% 0.258 29.23)
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
3. Then use OKLCH format in config:
|
|
740
|
+
```javascript
|
|
741
|
+
// eva.config.cjs
|
|
742
|
+
module.exports = {
|
|
743
|
+
theme: {
|
|
744
|
+
colors: {
|
|
745
|
+
brand: { lightness: 62.8, chroma: 0.258, hue: 29.23 }
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
#### Configuration not loading / "Invalid configuration" error
|
|
752
|
+
|
|
753
|
+
**Problem:** Your `eva.config.cjs` isn't being read or validation fails.
|
|
754
|
+
|
|
755
|
+
**Checklist:**
|
|
756
|
+
|
|
757
|
+
1. **File location:** Must be in project root (same level as `package.json`)
|
|
758
|
+
2. **File name:** Must be exactly `eva.config.cjs` or `eva.config.js`
|
|
759
|
+
3. **Syntax:** Must use `module.exports`, not ESM `export`
|
|
760
|
+
4. **Validate config:**
|
|
761
|
+
```bash
|
|
762
|
+
npx eva-css validate
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
**Common mistakes:**
|
|
766
|
+
|
|
767
|
+
```javascript
|
|
768
|
+
// ❌ Wrong - ESM syntax
|
|
769
|
+
export default {
|
|
770
|
+
sizes: [16, 24]
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
// ✅ Correct - CommonJS
|
|
774
|
+
module.exports = {
|
|
775
|
+
sizes: [16, 24]
|
|
776
|
+
};
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
#### Dark mode toggle not working
|
|
780
|
+
|
|
781
|
+
**Problem:** Clicking toggle button doesn't switch themes.
|
|
782
|
+
|
|
783
|
+
**Required setup:**
|
|
784
|
+
|
|
785
|
+
1. **HTML structure:**
|
|
786
|
+
```html
|
|
787
|
+
<body class="current-theme theme-myapp">
|
|
788
|
+
<!-- Both classes required ^^ -->
|
|
789
|
+
<button onclick="document.body.classList.toggle('toggle-theme')">
|
|
790
|
+
Toggle Dark Mode
|
|
791
|
+
</button>
|
|
792
|
+
</body>
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
2. **Theme configuration:**
|
|
796
|
+
```javascript
|
|
797
|
+
// eva.config.cjs
|
|
798
|
+
module.exports = {
|
|
799
|
+
theme: {
|
|
800
|
+
name: 'myapp', // Must match class: .theme-myapp
|
|
801
|
+
lightMode: { lightness: 96.4, darkness: 6.4 },
|
|
802
|
+
darkMode: { lightness: 5, darkness: 95 },
|
|
803
|
+
autoSwitch: false // Set true for auto prefers-color-scheme
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
3. **Toggle class:** The `.toggle-theme` class triggers dark mode when present.
|
|
809
|
+
|
|
810
|
+
#### CSS file size is huge (100KB+)
|
|
811
|
+
|
|
812
|
+
**Problem:** Generated CSS file is very large.
|
|
813
|
+
|
|
814
|
+
**Solutions:**
|
|
815
|
+
|
|
816
|
+
1. **Enable custom class mode** to generate only needed classes:
|
|
817
|
+
```scss
|
|
818
|
+
@use 'eva-css-fluid' with (
|
|
819
|
+
$sizes: (16, 24, 32, 64),
|
|
820
|
+
$custom-class: true,
|
|
821
|
+
$class-config: (
|
|
822
|
+
w: (64,), // Only .w-64
|
|
823
|
+
p: (16, 24), // Only .p-16 and .p-24
|
|
824
|
+
fs: (16, 24) // Only .fs-16 and .fs-24
|
|
825
|
+
)
|
|
826
|
+
);
|
|
827
|
+
```
|
|
828
|
+
**Result:** Reduces output by ~85%
|
|
829
|
+
|
|
830
|
+
2. **Use CSS purging** to remove unused classes:
|
|
831
|
+
```bash
|
|
832
|
+
npm install --save-dev eva-css-purge
|
|
833
|
+
npx eva-purge --css dist/eva.css --content "src/**/*.html"
|
|
834
|
+
```
|
|
835
|
+
**Result:** Typically 60-90% size reduction
|
|
836
|
+
|
|
837
|
+
3. **Use variables mode** instead of utility classes:
|
|
838
|
+
```scss
|
|
839
|
+
@use 'eva-css-fluid' with (
|
|
840
|
+
$build-class: false // No utility classes, only variables
|
|
841
|
+
);
|
|
842
|
+
```
|
|
843
|
+
**Result:** Much smaller CSS (only variables, no classes)
|
|
844
|
+
|
|
845
|
+
#### Sass compilation error: "Cannot find module"
|
|
846
|
+
|
|
847
|
+
**Error:**
|
|
848
|
+
```
|
|
849
|
+
Error: Can't find stylesheet to import.
|
|
850
|
+
╷
|
|
851
|
+
1 │ @use 'eva-css-fluid';
|
|
852
|
+
│ ^^^^^^^^^^^^^^^^^^^^^
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
**Solutions:**
|
|
856
|
+
|
|
857
|
+
1. **Add load-path** if using older Sass:
|
|
858
|
+
```bash
|
|
859
|
+
npx sass --load-path=node_modules styles/main.scss dist/main.css
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
2. **Check package is installed:**
|
|
863
|
+
```bash
|
|
864
|
+
npm ls eva-css-fluid
|
|
865
|
+
# Should show: eva-css-fluid@x.x.x
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
3. **Try explicit path:**
|
|
869
|
+
```scss
|
|
870
|
+
@use '../node_modules/eva-css-fluid/src';
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
#### Watch mode not detecting config changes
|
|
874
|
+
|
|
875
|
+
**Problem:** Changing `eva.config.cjs` doesn't trigger rebuild.
|
|
876
|
+
|
|
877
|
+
**Solution:** Use `nodemon` to watch config file:
|
|
878
|
+
|
|
879
|
+
```json
|
|
880
|
+
{
|
|
881
|
+
"scripts": {
|
|
882
|
+
"watch:css": "nodemon --watch eva.config.cjs --watch styles/ --exec 'node scripts/build-eva.js styles/main.scss dist/main.css'"
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
Install nodemon:
|
|
888
|
+
```bash
|
|
889
|
+
npm install --save-dev nodemon
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
#### Need help?
|
|
893
|
+
|
|
894
|
+
- 📖 [Full Documentation](https://eva-css.xyz/)
|
|
895
|
+
- 💬 [GitHub Issues](https://github.com/nkdeus/eva/issues)
|
|
896
|
+
- 📦 [NPM Package](https://www.npmjs.com/package/eva-css-fluid)
|
|
897
|
+
- 🎯 [Working Examples](../../examples/)
|
|
898
|
+
|
|
615
899
|
## 📚 Documentation
|
|
616
900
|
|
|
617
901
|
- [Full Documentation](https://eva-css.xyz/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eva-css-fluid",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Fluid design framework with OKLCH colors - Transform static designs into responsive fluid systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.scss",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"generate:config": "node cli.cjs generate"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"eva-colors": "^2.0.
|
|
71
|
+
"eva-colors": "^2.0.6"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"sass": "^1.94.1"
|