@tbela99/css-parser 0.0.1-rc4 → 0.0.1-rc6

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 CHANGED
@@ -16,6 +16,7 @@ $ npm install @tbela99/css-parser
16
16
  - efficient minification, see [benchmark](https://tbela99.github.io/css-parser/benchmark/index.html)
17
17
  - replace @import at-rules with actual css content of the imported rule
18
18
  - automatically generate nested css rules
19
+ - expand nested css
19
20
  - works the same way in node and web browser
20
21
 
21
22
  ### Performance
@@ -160,7 +161,7 @@ Single JavaScript file
160
161
  <script src="dist/index-umd-web.js"></script>
161
162
  ```
162
163
 
163
- ## Example
164
+ ## Example 1
164
165
 
165
166
  ### Automatic CSS Nesting
166
167
 
@@ -216,6 +217,63 @@ table.colortable {
216
217
  }
217
218
  ```
218
219
 
220
+ ## Example 2
221
+
222
+ ### Nested CSS Expansion
223
+
224
+ CSS
225
+
226
+ ```css
227
+ table.colortable {
228
+ & td {
229
+ text-align: center;
230
+ &.c {
231
+ text-transform: uppercase
232
+ }
233
+ &:first-child,&:first-child+td {
234
+ border: 1px solid #000
235
+ }
236
+ }
237
+ & th {
238
+ text-align: center;
239
+ background: #000;
240
+ color: #fff
241
+ }
242
+ }
243
+ ```
244
+
245
+ Javascript
246
+ ```javascript
247
+ import {parse, render} from '@tbela99/css-parser';
248
+
249
+
250
+ const options = {minify: true};
251
+
252
+ const {code} = await parse(css, options).then(result => render(result.ast, {minify: false, expandNestingRules: true}));
253
+ //
254
+ console.debug(code);
255
+ ```
256
+
257
+ Result
258
+
259
+ ```css
260
+
261
+ table.colortable td {
262
+ text-align:center;
263
+ }
264
+ table.colortable td.c {
265
+ text-transform:uppercase;
266
+ }
267
+ table.colortable td:first-child, table.colortable td:first-child+td {
268
+ border:1px solid black;
269
+ }
270
+ table.colortable th {
271
+ text-align:center;
272
+ background:black;
273
+ color:white;
274
+ }
275
+ ```
276
+
219
277
  ## AST
220
278
 
221
279
  ### Comment
@@ -297,6 +297,55 @@ var map = {
297
297
  "border-width": {
298
298
  shorthand: "border"
299
299
  },
300
+ overflow: {
301
+ shorthand: "overflow",
302
+ pattern: "overflow-x overflow-y",
303
+ keywords: [
304
+ "auto",
305
+ "visible",
306
+ "hidden",
307
+ "clip",
308
+ "scroll"
309
+ ],
310
+ "default": [
311
+ ],
312
+ mapping: {
313
+ "visible visible": "visible",
314
+ "auto auto": "auto",
315
+ "hidden hidden": "hidden",
316
+ "scroll scroll": "scroll"
317
+ },
318
+ properties: {
319
+ "overflow-x": {
320
+ "default": [
321
+ ],
322
+ keywords: [
323
+ "auto",
324
+ "visible",
325
+ "hidden",
326
+ "clip",
327
+ "scroll"
328
+ ]
329
+ },
330
+ "overflow-y": {
331
+ "default": [
332
+ ],
333
+ keywords: [
334
+ "auto",
335
+ "visible",
336
+ "hidden",
337
+ "clip",
338
+ "scroll"
339
+ ]
340
+ }
341
+ }
342
+ },
343
+ "overflow-x": {
344
+ shorthand: "overflow"
345
+ },
346
+ "overflow-y": {
347
+ shorthand: "overflow"
348
+ },
300
349
  outline: {
301
350
  shorthand: "outline",
302
351
  pattern: "outline-color outline-style outline-width",