esm-styles 0.3.0 → 0.3.2
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 +26 -6
- package/dist/build.js +0 -0
- package/doc/ai-guide.md +31 -2
- package/doc/api-reference.md +30 -14
- package/doc/best-practices.md +794 -0
- package/doc/usage-guide.md +67 -16
- package/package.json +1 -1
- package/dist/lib/getCss.d.ts +0 -14
- package/dist/lib/getCss.js +0 -260
- package/dist/lib/utils/common.d.ts +0 -28
- package/dist/lib/utils/common.js +0 -47
- package/dist/lib/utils/endValue.d.ts +0 -2
- package/dist/lib/utils/endValue.js +0 -10
- package/dist/lib/utils/media.d.ts +0 -24
- package/dist/lib/utils/media.js +0 -93
- package/dist/lib/utils/obj2css.d.ts +0 -15
- package/dist/lib/utils/obj2css.js +0 -79
- package/dist/lib/utils/selectors.d.ts +0 -15
- package/dist/lib/utils/selectors.js +0 -87
- package/dist/lib/utils/tags.d.ts +0 -10
- package/dist/lib/utils/tags.js +0 -128
- package/dist/lib/utils/traversal.d.ts +0 -25
- package/dist/lib/utils/traversal.js +0 -78
- package/dist/watch.js +0 -37
package/README.md
CHANGED
|
@@ -108,8 +108,15 @@ export default {
|
|
|
108
108
|
outputPath: 'css',
|
|
109
109
|
sourceFilesSuffix: '.styles.mjs',
|
|
110
110
|
|
|
111
|
-
// Input layers
|
|
112
|
-
|
|
111
|
+
// Input floors (replaces layers)
|
|
112
|
+
floors: [
|
|
113
|
+
{ source: 'defaults', layer: 'defaults' },
|
|
114
|
+
{ source: 'components', layer: 'components' },
|
|
115
|
+
{ source: 'layout', layer: 'layout' },
|
|
116
|
+
],
|
|
117
|
+
|
|
118
|
+
// Specify which floors to include in main CSS
|
|
119
|
+
importFloors: ['defaults', 'components', 'layout'],
|
|
113
120
|
|
|
114
121
|
// Output
|
|
115
122
|
mainCssFile: 'styles.css',
|
|
@@ -417,15 +424,28 @@ export default {
|
|
|
417
424
|
|
|
418
425
|
## Advanced Features
|
|
419
426
|
|
|
420
|
-
### Layering
|
|
427
|
+
### Layering with Floors
|
|
421
428
|
|
|
422
|
-
Organize your styles in
|
|
429
|
+
Organize your styles in floors for better control over specificity and output:
|
|
423
430
|
|
|
424
431
|
```js
|
|
425
|
-
//
|
|
432
|
+
// Configuration example
|
|
433
|
+
floors: [
|
|
434
|
+
{ source: 'defaults', layer: 'defaults' },
|
|
435
|
+
{ source: 'components', layer: 'components' },
|
|
436
|
+
{ source: 'layout', layer: 'layout' },
|
|
437
|
+
{ source: 'utilities' }, // No layer wrapper
|
|
438
|
+
{ source: 'overrides', outputPath: 'special' }, // Custom output path
|
|
439
|
+
]
|
|
426
440
|
```
|
|
427
441
|
|
|
428
|
-
|
|
442
|
+
Each floor can:
|
|
443
|
+
|
|
444
|
+
- Be wrapped in a CSS layer (optional)
|
|
445
|
+
- Have a custom output path (optional)
|
|
446
|
+
- Be included or excluded from the main CSS file via `importFloors`
|
|
447
|
+
|
|
448
|
+
The build process wraps floors in their respective layers and generates a main CSS file with proper import order.
|
|
429
449
|
|
|
430
450
|
### CSS Variable Inheritance
|
|
431
451
|
|
package/dist/build.js
CHANGED
|
File without changes
|
package/doc/ai-guide.md
CHANGED
|
@@ -31,7 +31,7 @@ button {
|
|
|
31
31
|
p: { fontSize: '16px' }, // -> p { font-size: 16px; }
|
|
32
32
|
|
|
33
33
|
// Non-HTML tags become class selectors
|
|
34
|
-
|
|
34
|
+
heading: { display: 'flex' }, // -> .heading { display: flex; }
|
|
35
35
|
card: { padding: '20px' } // -> .card { padding: 20px; }
|
|
36
36
|
}
|
|
37
37
|
```
|
|
@@ -91,6 +91,28 @@ button {
|
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
### ⚠️ CRITICAL: Ampersand (&) Syntax is NOT Supported
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
// ❌ WRONG: These will NOT work (common mistake from SCSS/Sass)
|
|
98
|
+
{
|
|
99
|
+
button: {
|
|
100
|
+
'&:hover': { opacity: 0.9 }, // ❌ Ampersand not supported
|
|
101
|
+
'&.active': { color: 'red' }, // ❌ Will not work
|
|
102
|
+
'&[disabled]': { opacity: 0.5 } // ❌ Will not work
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ✅ CORRECT: Use direct selectors instead
|
|
107
|
+
{
|
|
108
|
+
button: {
|
|
109
|
+
':hover': { opacity: 0.9 }, // ✅ Direct pseudo-class
|
|
110
|
+
active: { color: 'red' }, // ✅ Class name (if not HTML tag)
|
|
111
|
+
'[disabled]': { opacity: 0.5 } // ✅ Direct attribute selector
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
94
116
|
### Multiple Selectors
|
|
95
117
|
|
|
96
118
|
```js
|
|
@@ -150,6 +172,8 @@ export default {
|
|
|
150
172
|
// Use variable references - gets converted to var(--color-primary)
|
|
151
173
|
backgroundColor: $theme.color.primary,
|
|
152
174
|
color: $theme.color.textOnPrimary,
|
|
175
|
+
// in case of concatenation, use .var property, otherwise it will be [object Object]
|
|
176
|
+
border: `1px solid ${$theme.color.primary.var}`,
|
|
153
177
|
},
|
|
154
178
|
}
|
|
155
179
|
```
|
|
@@ -184,7 +208,12 @@ export default {
|
|
|
184
208
|
basePath: './src/styles',
|
|
185
209
|
sourcePath: 'source',
|
|
186
210
|
outputPath: 'css',
|
|
187
|
-
|
|
211
|
+
floors: [
|
|
212
|
+
{ source: 'base', layer: 'base' },
|
|
213
|
+
{ source: 'components', layer: 'components' },
|
|
214
|
+
{ source: 'utilities', layer: 'utilities' },
|
|
215
|
+
],
|
|
216
|
+
importFloors: ['base', 'components', 'utilities'],
|
|
188
217
|
mainCssFile: 'styles.css',
|
|
189
218
|
|
|
190
219
|
// Media shorthand definitions
|
package/doc/api-reference.md
CHANGED
|
@@ -120,6 +120,12 @@ Represents a set of CSS property declarations.
|
|
|
120
120
|
The `esm-styles.config.js` file exports a configuration object with the following structure:
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
|
+
interface FloorConfig {
|
|
124
|
+
source: string
|
|
125
|
+
layer?: string
|
|
126
|
+
outputPath?: string
|
|
127
|
+
}
|
|
128
|
+
|
|
123
129
|
interface ESMStylesConfig {
|
|
124
130
|
// Paths
|
|
125
131
|
basePath: string
|
|
@@ -128,7 +134,8 @@ interface ESMStylesConfig {
|
|
|
128
134
|
sourceFilesSuffix?: string
|
|
129
135
|
|
|
130
136
|
// Input
|
|
131
|
-
|
|
137
|
+
floors: FloorConfig[]
|
|
138
|
+
importFloors?: string[]
|
|
132
139
|
|
|
133
140
|
// Output
|
|
134
141
|
mainCssFile: string
|
|
@@ -146,19 +153,28 @@ interface ESMStylesConfig {
|
|
|
146
153
|
|
|
147
154
|
#### Properties
|
|
148
155
|
|
|
149
|
-
| Property | Type
|
|
150
|
-
| -------------------- |
|
|
151
|
-
| `basePath` | string
|
|
152
|
-
| `sourcePath` | string
|
|
153
|
-
| `outputPath` | string
|
|
154
|
-
| `sourceFilesSuffix` | string
|
|
155
|
-
| `
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
156
|
+
| Property | Type | Description | Default |
|
|
157
|
+
| -------------------- | ------------- | ---------------------------------- | ------------- |
|
|
158
|
+
| `basePath` | string | Base directory for styles | - |
|
|
159
|
+
| `sourcePath` | string | Source files directory | - |
|
|
160
|
+
| `outputPath` | string | Output CSS directory | - |
|
|
161
|
+
| `sourceFilesSuffix` | string | Suffix for source files | '.styles.mjs' |
|
|
162
|
+
| `floors` | FloorConfig[] | Array of floor configurations | - |
|
|
163
|
+
| `importFloors` | string[] | Floor names to include in main CSS | - |
|
|
164
|
+
| `mainCssFile` | string | Output CSS file name | - |
|
|
165
|
+
| `globalVariables` | string | Global variables file name | - |
|
|
166
|
+
| `globalRootSelector` | string | Root selector for variables | ':root' |
|
|
167
|
+
| `media` | object | Media types and variables | - |
|
|
168
|
+
| `mediaSelectors` | object | Media selector configurations | - |
|
|
169
|
+
| `mediaQueries` | object | Named media query shorthands | - |
|
|
170
|
+
|
|
171
|
+
#### FloorConfig Properties
|
|
172
|
+
|
|
173
|
+
| Property | Type | Description | Default |
|
|
174
|
+
| ------------ | ------ | -------------------------------------------- | ------- |
|
|
175
|
+
| `source` | string | Source file name (without suffix) | - |
|
|
176
|
+
| `layer` | string | CSS layer name to wrap the floor styles in | - |
|
|
177
|
+
| `outputPath` | string | Custom output path for this floor's CSS file | - |
|
|
162
178
|
|
|
163
179
|
### Media Selectors
|
|
164
180
|
|