eva-css-fluid 1.0.4 → 2.0.5
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/MIGRATION.md +337 -0
- package/README.md +441 -3
- package/cli.cjs +73 -0
- package/dist/eva.css +2133 -2093
- package/dist/eva.css.map +1 -1
- package/dist/eva.min.css +1 -1
- package/dist/eva.min.css.map +1 -1
- package/dist/test.css +5689 -0
- package/dist/test.css.map +1 -0
- package/eva.config.template.js +216 -0
- package/index.scss +9 -0
- package/package.json +85 -52
- package/scripts/build-with-config.cjs +169 -0
- package/src/_colors.scss +41 -6
- package/src/_config.scss +55 -0
- package/src/_eva.scss +84 -0
- package/src/cli-commands.cjs +539 -0
- package/src/colors-only.scss +16 -0
- package/src/config-loader.cjs +319 -0
- package/src/config-schema.cjs +455 -0
- package/src/core.scss +43 -0
- package/src/index.scss +5 -1
- package/src/variables.scss +33 -0
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# EVA CSS Migration Guide
|
|
2
|
+
|
|
3
|
+
This guide helps you migrate from your internal framework to EVA CSS.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Quick Start](#quick-start)
|
|
8
|
+
- [Configuration Changes](#configuration-changes)
|
|
9
|
+
- [Common Gotchas](#common-gotchas)
|
|
10
|
+
- [Breaking Changes](#breaking-changes)
|
|
11
|
+
- [Migration Examples](#migration-examples)
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install eva-css-fluid
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Basic Setup
|
|
22
|
+
|
|
23
|
+
Replace your old framework import with EVA CSS:
|
|
24
|
+
|
|
25
|
+
```scss
|
|
26
|
+
// Before (internal framework)
|
|
27
|
+
@import 'internal-framework/styles';
|
|
28
|
+
|
|
29
|
+
// After (EVA CSS)
|
|
30
|
+
@use 'eva-css-fluid/src' as *;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### With Custom Configuration
|
|
34
|
+
|
|
35
|
+
```scss
|
|
36
|
+
@use 'eva-css-fluid/src' as * with (
|
|
37
|
+
$sizes: (4, 8, 12, 16, 24, 32, 48, 64, 96, 128),
|
|
38
|
+
$font-sizes: (12, 14, 16, 18, 20, 24, 32, 48)
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration Changes
|
|
43
|
+
|
|
44
|
+
### Required Base Size
|
|
45
|
+
|
|
46
|
+
**Important**: EVA CSS requires size `16` to be present in your `$sizes` configuration.
|
|
47
|
+
|
|
48
|
+
```scss
|
|
49
|
+
// ❌ Will throw error
|
|
50
|
+
@use 'eva-css-fluid/src' as * with (
|
|
51
|
+
$sizes: (8, 24, 32, 64)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// ✅ Correct
|
|
55
|
+
@use 'eva-css-fluid/src' as * with (
|
|
56
|
+
$sizes: (8, 16, 24, 32, 64)
|
|
57
|
+
);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Why?** Size 16 (1rem) is used as the base unit for fluid calculations.
|
|
61
|
+
|
|
62
|
+
### Configuration Options
|
|
63
|
+
|
|
64
|
+
| Option | Default | Description |
|
|
65
|
+
|--------|---------|-------------|
|
|
66
|
+
| `$sizes` | `4, 8, 12, 16, 24, 32, 48, 64, 96, 128` | Available size values (16 required) |
|
|
67
|
+
| `$font-sizes` | `12, 14, 16, 18, 20, 24, 32, 48` | Font size values |
|
|
68
|
+
| `$build-class` | `true` | Generate utility classes |
|
|
69
|
+
| `$px-rem-suffix` | `false` | Add px/rem debug values |
|
|
70
|
+
| `$name-by-size` | `true` | Use size values in names |
|
|
71
|
+
| `$custom-class` | `false` | Enable selective class generation |
|
|
72
|
+
| `$class-config` | `()` | Configure which classes to generate |
|
|
73
|
+
|
|
74
|
+
## Common Gotchas
|
|
75
|
+
|
|
76
|
+
### 1. Import Syntax Change
|
|
77
|
+
|
|
78
|
+
EVA CSS uses modern Sass `@use` instead of `@import`:
|
|
79
|
+
|
|
80
|
+
```scss
|
|
81
|
+
// ❌ Old syntax (deprecated)
|
|
82
|
+
@import 'eva-css-fluid/src';
|
|
83
|
+
|
|
84
|
+
// ✅ New syntax
|
|
85
|
+
@use 'eva-css-fluid/src' as *;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. Custom Class Mode
|
|
89
|
+
|
|
90
|
+
When using `$custom-class: true`, you **must** provide `$class-config`:
|
|
91
|
+
|
|
92
|
+
```scss
|
|
93
|
+
// ❌ Will throw error
|
|
94
|
+
@use 'eva-css-fluid/src' as * with (
|
|
95
|
+
$custom-class: true
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// ✅ Correct
|
|
99
|
+
@use 'eva-css-fluid/src' as * with (
|
|
100
|
+
$custom-class: true,
|
|
101
|
+
$class-config: (
|
|
102
|
+
w: (50, 100),
|
|
103
|
+
px: (24,), // Note: trailing comma for single-item lists
|
|
104
|
+
g: (24, 50)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 3. Property Names in class-config
|
|
110
|
+
|
|
111
|
+
Only use valid property keys from the framework:
|
|
112
|
+
|
|
113
|
+
```scss
|
|
114
|
+
// ❌ Invalid property
|
|
115
|
+
$class-config: (
|
|
116
|
+
width: (50, 100) // Use 'w' not 'width'
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// ✅ Correct
|
|
120
|
+
$class-config: (
|
|
121
|
+
w: (50, 100)
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Available properties**: `w`, `mw`, `h`, `p`, `px`, `pr`, `py`, `br`, `mb`, `mr`, `ml`, `mt`, `pt`, `pb`, `g`, `gap`
|
|
126
|
+
|
|
127
|
+
### 4. Sizes Must Exist in $sizes
|
|
128
|
+
|
|
129
|
+
All sizes referenced in `$class-config` must exist in your `$sizes` list:
|
|
130
|
+
|
|
131
|
+
```scss
|
|
132
|
+
// ❌ Will throw error (999 not in $sizes)
|
|
133
|
+
@use 'eva-css-fluid/src' as * with (
|
|
134
|
+
$sizes: (16, 24, 50, 100),
|
|
135
|
+
$custom-class: true,
|
|
136
|
+
$class-config: (
|
|
137
|
+
w: (50, 999)
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// ✅ Correct
|
|
142
|
+
@use 'eva-css-fluid/src' as * with (
|
|
143
|
+
$sizes: (16, 24, 50, 100),
|
|
144
|
+
$custom-class: true,
|
|
145
|
+
$class-config: (
|
|
146
|
+
w: (50, 100)
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Breaking Changes
|
|
152
|
+
|
|
153
|
+
### Version 1.1.0
|
|
154
|
+
|
|
155
|
+
#### Added
|
|
156
|
+
|
|
157
|
+
- **`$class-config` parameter**: New configuration option for custom class mode
|
|
158
|
+
- **Configuration validation**: Helpful error messages for invalid configurations
|
|
159
|
+
- **Required base size**: Size 16 is now required in `$sizes`
|
|
160
|
+
|
|
161
|
+
#### Changed
|
|
162
|
+
|
|
163
|
+
- `$custom-class` now requires `$class-config` to be set (if enabled)
|
|
164
|
+
- Empty `$sizes` or `$font-sizes` lists now throw errors
|
|
165
|
+
|
|
166
|
+
#### Migration Steps
|
|
167
|
+
|
|
168
|
+
1. Ensure size `16` is in your `$sizes` configuration
|
|
169
|
+
2. If using `$custom-class: true`, add `$class-config` parameter
|
|
170
|
+
3. Test compilation to catch any validation errors
|
|
171
|
+
|
|
172
|
+
## Migration Examples
|
|
173
|
+
|
|
174
|
+
### Example 1: From Internal Framework
|
|
175
|
+
|
|
176
|
+
```scss
|
|
177
|
+
// Before
|
|
178
|
+
@import 'internal-framework';
|
|
179
|
+
|
|
180
|
+
$spacing: 8px, 16px, 24px, 32px;
|
|
181
|
+
$colors: (
|
|
182
|
+
primary: #3498db,
|
|
183
|
+
secondary: #2ecc71
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// After
|
|
187
|
+
@use 'eva-css-fluid/src' as * with (
|
|
188
|
+
$sizes: (8, 16, 24, 32)
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// Colors are built-in with OKLCH system
|
|
192
|
+
// Use: var(--brand), var(--accent), etc.
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Example 2: Production Build with Custom Classes
|
|
196
|
+
|
|
197
|
+
**Scenario**: You want to generate only specific classes to reduce CSS size.
|
|
198
|
+
|
|
199
|
+
```scss
|
|
200
|
+
// Before (generated all classes)
|
|
201
|
+
@use 'eva-css-fluid/src' as *;
|
|
202
|
+
|
|
203
|
+
// After (optimized)
|
|
204
|
+
@use 'eva-css-fluid/src' as * with (
|
|
205
|
+
$sizes: (16, 24, 50, 100),
|
|
206
|
+
$custom-class: true,
|
|
207
|
+
$class-config: (
|
|
208
|
+
w: (50, 100), // Only width-50 and width-100
|
|
209
|
+
h: (50, 100), // Only height-50 and height-100
|
|
210
|
+
px: (24,), // Only padding-x-24
|
|
211
|
+
py: (24,), // Only padding-y-24
|
|
212
|
+
g: (24, 50), // Only gap-24 and gap-50
|
|
213
|
+
br: (16,) // Only border-radius-16
|
|
214
|
+
)
|
|
215
|
+
);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Result**: Significantly smaller CSS output, perfect for production.
|
|
219
|
+
|
|
220
|
+
### Example 3: Development Mode
|
|
221
|
+
|
|
222
|
+
**Scenario**: You're in development and want CSS variables only (no classes).
|
|
223
|
+
|
|
224
|
+
```scss
|
|
225
|
+
@use 'eva-css-fluid/src' as * with (
|
|
226
|
+
$build-class: false, // Don't generate utility classes
|
|
227
|
+
$px-rem-suffix: true // Add debug values
|
|
228
|
+
);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Then use in your CSS:
|
|
232
|
+
|
|
233
|
+
```scss
|
|
234
|
+
.my-component {
|
|
235
|
+
width: var(--64);
|
|
236
|
+
padding: var(--16);
|
|
237
|
+
border-radius: var(--8);
|
|
238
|
+
|
|
239
|
+
// Debug values available:
|
|
240
|
+
// var(--64-px) → pixel value
|
|
241
|
+
// var(--64-rem) → rem value
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Example 4: Gradual Migration
|
|
246
|
+
|
|
247
|
+
**Scenario**: You want to migrate gradually, keeping both frameworks.
|
|
248
|
+
|
|
249
|
+
```scss
|
|
250
|
+
// Load EVA CSS with custom namespace
|
|
251
|
+
@use 'eva-css-fluid/src' as eva with (
|
|
252
|
+
$sizes: (16, 24, 32, 48, 64)
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
// Keep your old framework temporarily
|
|
256
|
+
@import 'old-framework';
|
|
257
|
+
|
|
258
|
+
// Now you can use both:
|
|
259
|
+
.new-component {
|
|
260
|
+
padding: var(--eva-16);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.old-component {
|
|
264
|
+
padding: $old-spacing-md;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Troubleshooting
|
|
269
|
+
|
|
270
|
+
### Error: "Size 16 is required as a base size"
|
|
271
|
+
|
|
272
|
+
**Solution**: Add `16` to your `$sizes` list:
|
|
273
|
+
|
|
274
|
+
```scss
|
|
275
|
+
@use 'eva-css-fluid/src' as * with (
|
|
276
|
+
$sizes: (4, 8, 16, 24, 32, 48, 64) // Add 16 here
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Error: "Unknown property 'xyz' in $class-config"
|
|
281
|
+
|
|
282
|
+
**Solution**: Use valid property abbreviations. Check the list of available properties in [Common Gotchas](#3-property-names-in-class-config).
|
|
283
|
+
|
|
284
|
+
### Error: "When $custom-class is true, $class-config must be a map"
|
|
285
|
+
|
|
286
|
+
**Solution**: Provide a valid `$class-config` map:
|
|
287
|
+
|
|
288
|
+
```scss
|
|
289
|
+
@use 'eva-css-fluid/src' as * with (
|
|
290
|
+
$custom-class: true,
|
|
291
|
+
$class-config: (
|
|
292
|
+
w: (50, 100),
|
|
293
|
+
px: (24,)
|
|
294
|
+
)
|
|
295
|
+
);
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Compilation is Slow
|
|
299
|
+
|
|
300
|
+
**Solutions**:
|
|
301
|
+
|
|
302
|
+
1. Use `$custom-class: true` to reduce generated classes
|
|
303
|
+
2. Use `$build-class: false` if you only need CSS variables
|
|
304
|
+
3. Disable `$px-rem-suffix` in production
|
|
305
|
+
|
|
306
|
+
### CSS Output is Too Large
|
|
307
|
+
|
|
308
|
+
**Solutions**:
|
|
309
|
+
|
|
310
|
+
1. Enable custom class mode:
|
|
311
|
+
```scss
|
|
312
|
+
@use 'eva-css-fluid/src' as * with (
|
|
313
|
+
$custom-class: true,
|
|
314
|
+
$class-config: (
|
|
315
|
+
// Only include what you need
|
|
316
|
+
)
|
|
317
|
+
);
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
2. Use the `eva-purge` package to remove unused classes:
|
|
321
|
+
```bash
|
|
322
|
+
npm install @eva-css/eva-purge
|
|
323
|
+
eva-purge input.css output.css --html "**/*.html"
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Getting Help
|
|
327
|
+
|
|
328
|
+
- **Documentation**: [eva-css.xyz](https://eva-css.xyz)
|
|
329
|
+
- **GitHub Issues**: [github.com/nkdeus/eva/issues](https://github.com/nkdeus/eva/issues)
|
|
330
|
+
- **Examples**: See `demo/` folder in the repository
|
|
331
|
+
|
|
332
|
+
## Next Steps
|
|
333
|
+
|
|
334
|
+
1. ✅ Complete the migration
|
|
335
|
+
2. 📚 Read the [full documentation](./README.md)
|
|
336
|
+
3. 🎨 Explore the [OKLCH color system](./README.md#-oklch-color-system)
|
|
337
|
+
4. ⚡ Optimize your build with [custom classes](./README.md#custom-class-mode-custom-class-true)
|