|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | const valueParser = require('postcss-value-parser');
|
|---|
| 3 | const listStyleTypes = require('./listStyleTypes.json');
|
|---|
| 4 |
|
|---|
| 5 | const definedTypes = new Set(listStyleTypes['list-style-type']);
|
|---|
| 6 |
|
|---|
| 7 | const definedPosition = new Set(['inside', 'outside']);
|
|---|
| 8 |
|
|---|
| 9 | /**
|
|---|
| 10 | * @param {import('postcss-value-parser').ParsedValue} listStyle
|
|---|
| 11 | * @return {string}
|
|---|
| 12 | */
|
|---|
| 13 | module.exports = function listStyleNormalizer(listStyle) {
|
|---|
| 14 | const order = { type: '', position: '', image: '' };
|
|---|
| 15 |
|
|---|
| 16 | listStyle.walk((decl) => {
|
|---|
| 17 | if (decl.type === 'word') {
|
|---|
| 18 | if (definedTypes.has(decl.value)) {
|
|---|
| 19 | // its a type field
|
|---|
| 20 | order.type = `${order.type} ${decl.value}`;
|
|---|
| 21 | } else if (definedPosition.has(decl.value)) {
|
|---|
| 22 | order.position = `${order.position} ${decl.value}`;
|
|---|
| 23 | } else if (decl.value === 'none') {
|
|---|
| 24 | if (
|
|---|
| 25 | order.type
|
|---|
| 26 | .split(' ')
|
|---|
| 27 | .filter((e) => e !== '' && e !== ' ')
|
|---|
| 28 | .includes('none')
|
|---|
| 29 | ) {
|
|---|
| 30 | order.image = `${order.image} ${decl.value}`;
|
|---|
| 31 | } else {
|
|---|
| 32 | order.type = `${order.type} ${decl.value}`;
|
|---|
| 33 | }
|
|---|
| 34 | } else {
|
|---|
| 35 | order.type = `${order.type} ${decl.value}`;
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | if (decl.type === 'function') {
|
|---|
| 39 | order.image = `${order.image} ${valueParser.stringify(decl)}`;
|
|---|
| 40 | }
|
|---|
| 41 | });
|
|---|
| 42 |
|
|---|
| 43 | return `${order.type.trim()} ${order.position.trim()} ${order.image.trim()}`.trim();
|
|---|
| 44 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.