postcss-enumerates-in-line 0.3.2 → 0.4.0
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 +279 -49
- package/README_EN.md +291 -50
- package/index.d.ts +48 -3
- package/index.mjs +246 -84
- package/package.json +1 -1
package/README_EN.md
CHANGED
|
@@ -5,24 +5,28 @@
|
|
|
5
5
|
|[<img width="24" height="24" align="left" src="README.img/1f1ef-1f1f5.png" alt="🇯🇵"> 日本語](README.md)|[<img width="24" height="24" align="left" src="README.img/1f1fa-1f1f8.png" alt="🇺🇸"> English](README_EN.md)|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
## Revision: in v0.
|
|
8
|
+
## Revision: in v0.4.0
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
10
|
+
1. Color settings
|
|
11
|
+
|
|
12
|
+
- Added a function `color[[...]]` for value of CSS property which designate a color.
|
|
13
|
+
- Added a plugin's option `appendUserColors(...)` for extending user color themes.
|
|
14
|
+
- Changed a plugin's option `prependDefaultColor` that default value turn to `false`.
|
|
15
|
+
|
|
16
|
+
2. Shorthand settings
|
|
17
|
+
|
|
18
|
+
- Added a plugin's option `appendShorthand(...)` for extending user shorthands which is used about CSS property name.
|
|
19
|
+
|
|
20
|
+
3. CSS property
|
|
21
|
+
|
|
22
|
+
- Added conditional CSS property name about below.
|
|
23
|
+
+ `attr(<attributes>)`
|
|
19
24
|
|
|
20
25
|
|
|
21
26
|
## Maybe add functions
|
|
22
27
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- Refine `[[...]]` syntax, and add to use `color-alpha[[...]]` syntax which is enable to add alpha channel to default colors (using in CSS property value).
|
|
28
|
+
- Update sample programs.
|
|
29
|
+
- Upgrade major version to v1.
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
---
|
|
@@ -50,17 +54,12 @@ Specific speaking, it takes the syntax like above -- language in [SCSS].
|
|
|
50
54
|
>
|
|
51
55
|
> There are shorthands; `my` means convined `margin-top` and `margin-bottom`, `ff` means `font-family`, and `fs` means `font-size`.
|
|
52
56
|
> What are defining about shorthands, c.f. [Shorthands of property names](#shorthands-of-property-names).
|
|
57
|
+
> And you can extend user shorthands yourself.
|
|
53
58
|
>
|
|
54
59
|
> You would separate CSS styles by `:` character so, property name appears in before and property value appears in after against `:`.
|
|
55
60
|
> Whitespace characters (like a ` `) treat as separator of CSS styles. If you want to write whitespaces at property values, then may replace these by `^` character.
|
|
56
61
|
>
|
|
57
62
|
|
|
58
|
-
~~There are no imprements about state transition like a hover, media queries, dark mode, etc.; because I am wishing only to aim for enumerating CSS styles.~~
|
|
59
|
-
|
|
60
|
-
~~> What do I want to say; this plugin do not have any `hover:`, `md:`, and `dark:` etc. at [Tailwind CSS].~~
|
|
61
|
-
|
|
62
|
-
☑️In version 0.3.0 and upper.
|
|
63
|
-
|
|
64
63
|
And also if you prepend below syntaxes into CSS property, would be available about conditional CSS properties.
|
|
65
64
|
|
|
66
65
|
- `hover!`: :hover
|
|
@@ -68,6 +67,7 @@ And also if you prepend below syntaxes into CSS property, would be available abo
|
|
|
68
67
|
- `mq(<mediaQueries>)!`: @media screen and <mediaQueries>
|
|
69
68
|
- `data(<customDataElements>)!`: [data-<customDataElement>]
|
|
70
69
|
- `aria(<ariaAttributes>)!`: [aria-<ariaAttributes>]
|
|
70
|
+
- `attr(<attributes>)!`: [<attributes>]
|
|
71
71
|
|
|
72
72
|
> There are syntax descriptions after indexes.
|
|
73
73
|
|
|
@@ -86,7 +86,7 @@ I think primary usage is [gulp] and [gulp-postcss]. However it also works on JS-
|
|
|
86
86
|
## Indexes
|
|
87
87
|
|
|
88
88
|
- [PostCSS Enumerates in Line](#postcss-enumerates-in-line)
|
|
89
|
-
- [Revision: in v0.
|
|
89
|
+
- [Revision: in v0.4.0](#revision-in-v040)
|
|
90
90
|
- [Maybe add functions](#maybe-add-functions)
|
|
91
91
|
- [Indexes](#indexes)
|
|
92
92
|
- [Method of writing in CSS files.](#method-of-writing-in-css-files)
|
|
@@ -96,6 +96,7 @@ I think primary usage is [gulp] and [gulp-postcss]. However it also works on JS-
|
|
|
96
96
|
- [Media Queries](#media-queries)
|
|
97
97
|
- [Custom data attribute](#custom-data-attribute)
|
|
98
98
|
- [ARIA attributes](#aria-attributes)
|
|
99
|
+
- [Attribute property](#attribute-property)
|
|
99
100
|
- [Special characters](#special-characters)
|
|
100
101
|
- [COLON Character](#colon-character)
|
|
101
102
|
- [EXCLAMATION character](#exclamation-character)
|
|
@@ -103,6 +104,7 @@ I think primary usage is [gulp] and [gulp-postcss]. However it also works on JS-
|
|
|
103
104
|
- [double SQUARE BRACKET character](#double-square-bracket-character)
|
|
104
105
|
- [Default colors](#default-colors)
|
|
105
106
|
- [Shorthands of property names](#shorthands-of-property-names)
|
|
107
|
+
- [User defined shorthands](#user-defined-shorthands)
|
|
106
108
|
- [How to use this plugin](#how-to-use-this-plugin)
|
|
107
109
|
- [How to use with gulp](#how-to-use-with-gulp)
|
|
108
110
|
- [package.json](#packagejson)
|
|
@@ -121,6 +123,10 @@ I think primary usage is [gulp] and [gulp-postcss]. However it also works on JS-
|
|
|
121
123
|
- [Arguments of option settings](#arguments-of-option-settings)
|
|
122
124
|
- [prependDefaultColor](#prependdefaultcolor)
|
|
123
125
|
- [prependDefaultStyle](#prependdefaultstyle)
|
|
126
|
+
- [appendShorthand](#appendshorthand)
|
|
127
|
+
- [appendUserColor](#appendusercolor)
|
|
128
|
+
- [color\[\[...\]\] function](#color-function)
|
|
129
|
+
- [prependDefaultColor option](#prependdefaultcolor-option)
|
|
124
130
|
|
|
125
131
|
<div class="x--hr"></div>
|
|
126
132
|
|
|
@@ -163,7 +169,7 @@ h1 {
|
|
|
163
169
|
|
|
164
170
|
You can extend a syntax to `<condition>!<CssPropertyName>:<CssPropertyValue>` like above.
|
|
165
171
|
|
|
166
|
-
Each condition (`hover!`, `dark!`, `mq(...)!`, `data(...)!`, and `
|
|
172
|
+
Each condition (`hover!`, `dark!`, `mq(...)!`, `data(...)!`, `aria(...)!`, and `attr(...)!`) are able to mate with others.
|
|
167
173
|
|
|
168
174
|
```scss
|
|
169
175
|
h1 {
|
|
@@ -171,7 +177,7 @@ h1 {
|
|
|
171
177
|
}
|
|
172
178
|
```
|
|
173
179
|
|
|
174
|
-
But can you not prepend consecutively same conditional type about `mq(...)!`, `data(...)!`, and `
|
|
180
|
+
But can you not prepend consecutively same conditional type about `mq(...)!`, `data(...)!`, `aria(...)!`, and `attr(...)!`.
|
|
175
181
|
Because these are only able to add the 1 type by 1 CSS property.
|
|
176
182
|
|
|
177
183
|
If you want to enumerate conditions, please use by `,` splitting that located between `(` and`)`.
|
|
@@ -447,6 +453,36 @@ The ARIA attributes (which are as arguments of `aria(...)` function) can be desc
|
|
|
447
453
|
> + `\`: %5D
|
|
448
454
|
|
|
449
455
|
|
|
456
|
+
#### Attribute property
|
|
457
|
+
|
|
458
|
+
This package equips dedicated conditional syntaxes about custom data attribute (`[data-*]`) and ARIA attribute (`[aria-*]`); however it can treat other attributes (`[*]`) by written in `attr(...)!`.
|
|
459
|
+
|
|
460
|
+
That means `data(foo="bar")!` as equal as `attr(data-foo="bar")!`.
|
|
461
|
+
|
|
462
|
+
If you wish to combine multiple attributes consecutively, can describe by `,` splitting syntax.
|
|
463
|
+
|
|
464
|
+
```scss
|
|
465
|
+
/* 🚧Before */
|
|
466
|
+
h1 {
|
|
467
|
+
@emums attr(download)!ct:red attr(title="heading",data-tags~="hello")!bw2:1px;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* 🚀After */
|
|
471
|
+
h1[download] {
|
|
472
|
+
color: red;
|
|
473
|
+
}
|
|
474
|
+
h1[title="heading"][data-tags~="hello"] {
|
|
475
|
+
border-bottom-width: 1px;
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
The attributes (which are as arguments of `attr(...)` function) can be described in these combination; `attribute name`, `conditional operator`, `attribute value`.
|
|
480
|
+
|
|
481
|
+
If do you need a attribute value (that means you want to need only attribute name like as `*[download]`), should not designate `conditional operator` and `attribute value`,
|
|
482
|
+
|
|
483
|
+
For details, may see a section of [custom data attribute](#custom-data-attribute).
|
|
484
|
+
|
|
485
|
+
|
|
450
486
|
### Special characters
|
|
451
487
|
|
|
452
488
|
There are 5 characters which behave especially; `:`, `^`, `!`, `[[`, and `]]`.
|
|
@@ -512,48 +548,56 @@ Because there ware annoying `^` characters they appear many and many times about
|
|
|
512
548
|
|
|
513
549
|
This is experimental function. I am improving a transform compiler, so you will face at risk that would not insert whitespace characters to both end of calculation operators normally at your wish.
|
|
514
550
|
|
|
515
|
-
It works to replace whitespace to `^` characters as this case too. But I recommend to take a surefire way, it is supplements by `^` characters manually without `[[` and `]]`.
|
|
551
|
+
> It works to replace whitespace to `^` characters as this case too. But I recommend to take a surefire way, it is supplements by `^` characters manually without `[[` and `]]`.
|
|
516
552
|
|
|
553
|
+
---
|
|
517
554
|
|
|
518
|
-
|
|
555
|
+
Apart from the above, you can describe a distinctive syntax `color[[...]]` into a CSS property value.
|
|
519
556
|
|
|
520
|
-
|
|
557
|
+
```scss
|
|
558
|
+
h1 {
|
|
559
|
+
@enums ct:color[[yellow,600]];
|
|
560
|
+
}
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
There are able to take multiple arguments with `,` separation for what use to retrieve the color value that are managed by this package.
|
|
521
564
|
|
|
522
|
-
|
|
565
|
+
The above behavior is same as both `prependDefaultColor` (this is package option) turning to `true` and writing `@enums ct:var(--color-yellow-600);` in CSS property.
|
|
523
566
|
|
|
524
567
|
```scss
|
|
525
|
-
|
|
526
|
-
@enums ct:
|
|
568
|
+
h1 {
|
|
569
|
+
@enums ct:color[[cyan,400,95%,rgb]];
|
|
527
570
|
}
|
|
528
571
|
```
|
|
529
572
|
|
|
530
|
-
|
|
573
|
+
This function-like syntax takes 4 kind arguments in maximum.
|
|
531
574
|
|
|
532
|
-
|
|
575
|
+
1. Color theme (e.g. `cyan`)
|
|
576
|
+
2. Intensity level (e.g. `400`; which can be described in regex as `/[\d]+/`)
|
|
577
|
+
3. Alpha value (e.g. `95%`; which can be described in regex as `/[\d]+[%]/`)
|
|
578
|
+
4. Output style (e.g. `rgb`|`hsl`|`oklch`; these are interpreted as same in uppercase or lowercase)
|
|
533
579
|
|
|
534
|
-
|
|
580
|
+
> If unspecified kind occurred in `color[...]` function, this package will apply as below.
|
|
581
|
+
> 1. `base`
|
|
582
|
+
> 2. `400`
|
|
583
|
+
> 3. `100%`
|
|
584
|
+
> 4. `hsl`
|
|
535
585
|
|
|
536
|
-
|
|
537
|
-
|
|
586
|
+
You will eliminate some problems as below if use this function.
|
|
587
|
+
- Can apply opacity.
|
|
588
|
+
- And that also apply to user defined color theme which added by `appendUserColors(...)` in package option.
|
|
589
|
+
- Can minimize CSS file size because there are no color settings in CSS variables. The `prependDefaultColor` option is still in a default value as `false`.
|
|
538
590
|
|
|
539
|
-
html {
|
|
540
|
-
color: #{c.$color-red-400}99; // D14D4199
|
|
541
|
-
}
|
|
542
|
-
```
|
|
543
591
|
|
|
544
|
-
|
|
592
|
+
### Default colors
|
|
545
593
|
|
|
546
|
-
|
|
547
|
-
/* 🚧Before */
|
|
548
|
-
html {
|
|
549
|
-
color: color-alpha[[red,400,60%,oklch]];
|
|
550
|
-
}
|
|
594
|
+
Default colors forked from [Flexoki] v2.0 to this package.
|
|
551
595
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
596
|
+
[<img src="README.img/default_color.png" alt="Default color">](README.img/default_color.png)
|
|
597
|
+
|
|
598
|
+
As saying in the section of `color[[...]]`, you can extend original color theme yourself by using `appendUserColors(...)` in package option.
|
|
599
|
+
|
|
600
|
+
See also [Arguments of option settings](#arguments-of-option-settings) in detail.
|
|
557
601
|
|
|
558
602
|
|
|
559
603
|
### Shorthands of property names
|
|
@@ -650,6 +694,13 @@ For example, `border-top-width:1px` as same as `bw8:1px`.
|
|
|
650
694
|
Numeric character (from `1` to `9`) are related to position of Ten-key pad.
|
|
651
695
|
|
|
652
696
|
|
|
697
|
+
#### User defined shorthands
|
|
698
|
+
|
|
699
|
+
You can extend shorthands which used in CSS property name, by designate a package option `appendShorthand(...)`.
|
|
700
|
+
|
|
701
|
+
See also [Arguments of option settings](#arguments-of-option-settings) in detail.
|
|
702
|
+
|
|
703
|
+
|
|
653
704
|
## How to use this plugin
|
|
654
705
|
|
|
655
706
|
### How to use with gulp
|
|
@@ -864,9 +915,9 @@ For lively using example about this package, you may mainly see a file `src/css/
|
|
|
864
915
|
|
|
865
916
|
How to dealing with CSS about color settings that will add automatically.
|
|
866
917
|
|
|
867
|
-
Default value:
|
|
918
|
+
Default value: false (boolean|string)
|
|
868
919
|
|
|
869
|
-
If you designate to `true` (
|
|
920
|
+
If you designate to `true` (or designate `"hsl"` including `"HSL"`), this package output color settings in HSL type to CSS files like below.
|
|
870
921
|
|
|
871
922
|
```css
|
|
872
923
|
:root {
|
|
@@ -924,3 +975,193 @@ You want to append your original reset CSS, please designate CSS blocks (string[
|
|
|
924
975
|
It only works appending CSS styles, you cannot remove reset CSS styles which defined in this package.
|
|
925
976
|
|
|
926
977
|
In the case of working perfectly original CSS styles, you may designate `false` to this option, and write these in your SCSS files.
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
### appendShorthand
|
|
981
|
+
|
|
982
|
+
Append user defined shorthands about CSS property name.
|
|
983
|
+
|
|
984
|
+
Default value: [] (string[string,string[]])
|
|
985
|
+
|
|
986
|
+
```javascript
|
|
987
|
+
appendShorthand: [
|
|
988
|
+
['pos', ['position']],
|
|
989
|
+
],
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
When did you designate a value related to `appendShorthand(...)` like above, `pos` will work as a shorthand as `position`.
|
|
993
|
+
|
|
994
|
+
```javascript
|
|
995
|
+
appendShorthand: [
|
|
996
|
+
['bw246', ['border-bottom-width', 'border-left-width', 'border-right-width']],
|
|
997
|
+
],
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
You can also designate in a bulk as multiple property names.
|
|
1001
|
+
|
|
1002
|
+
```javascript
|
|
1003
|
+
appendShorthand: [
|
|
1004
|
+
['lh', ['line-height']],
|
|
1005
|
+
],
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
There is a shorthand already that named as `fh` tied with `line-height`, and however you can prepare additional shorthands `lh` as alias by this option.
|
|
1009
|
+
|
|
1010
|
+
```javascript
|
|
1011
|
+
appendShorthand: [
|
|
1012
|
+
['o', ['opacity']],
|
|
1013
|
+
],
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
But even if you try to register a shorthand `o` like above, there is already registered it which tied with `outline`. So ignored.
|
|
1017
|
+
|
|
1018
|
+
You cannot overwrite settings of shorthand.
|
|
1019
|
+
|
|
1020
|
+
Besides if this package saw a condition of unworkable syntax, that will be ignored.
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
### appendUserColor
|
|
1024
|
+
|
|
1025
|
+
Append user defined color themes.
|
|
1026
|
+
|
|
1027
|
+
Default value: [] ({theme: <string>, levels: {level: <number>, rgb: <string>, hsl: <string>, oklch: <string>}[]}[])
|
|
1028
|
+
|
|
1029
|
+
```javascript
|
|
1030
|
+
appendUserColor: [
|
|
1031
|
+
{
|
|
1032
|
+
theme: 'blood',
|
|
1033
|
+
levels: [
|
|
1034
|
+
{
|
|
1035
|
+
level: 400,
|
|
1036
|
+
rgb: '#660000',
|
|
1037
|
+
hsl: 'hsl(0 100% 20%)',
|
|
1038
|
+
oklch: 'oklch(0.3204 0.1315 29.23)',
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
level: 600,
|
|
1042
|
+
rgb: '#D1001C',
|
|
1043
|
+
hsl: 'hsl(352 100% 41%)',
|
|
1044
|
+
oklch: 'oklch(0.5418 0.2202 26.04)',
|
|
1045
|
+
},
|
|
1046
|
+
]
|
|
1047
|
+
},
|
|
1048
|
+
]
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
If you designate like above, this package will register `blood` (that is written in an option value `theme`) as new color theme, then can be available to use these intensity levels `400` and `600`.
|
|
1052
|
+
|
|
1053
|
+
> Cannot register a name of color theme in which is already registered as default color or other user defined color themes.
|
|
1054
|
+
|
|
1055
|
+
There are 2 methods for how do you retrieve registered colors.
|
|
1056
|
+
|
|
1057
|
+
1. `color[[...]]`
|
|
1058
|
+
2. `prependDefaultColor`
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
#### color[[...]] function
|
|
1062
|
+
|
|
1063
|
+
```scss
|
|
1064
|
+
/* 🚧Before */
|
|
1065
|
+
h1 {
|
|
1066
|
+
@enums ct:color[[red,400]];
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/* 🚀After */
|
|
1070
|
+
h1 {
|
|
1071
|
+
color: hsl(5 61% 53.7%);
|
|
1072
|
+
}
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
This function-like CSS property value can take arguments which are 4 kinds maximum.
|
|
1076
|
+
|
|
1077
|
+
Color theme (e.g. `red`), intensity level (e.g. `400`), alpha value (e.g. `100%`), and output style (e.g. `rgb`).
|
|
1078
|
+
|
|
1079
|
+
Every kinds are optional arguments, so there are omittable.
|
|
1080
|
+
|
|
1081
|
+
But, by and for syntax restriction, you need to designate arguments at least 1 kind and up.
|
|
1082
|
+
|
|
1083
|
+
> 1. Color theme
|
|
1084
|
+
>
|
|
1085
|
+
> The name of default color theme, or that registered in `appendUserColor(...)` option.
|
|
1086
|
+
>
|
|
1087
|
+
> When you omit this value in `color[[...]]`, this package will apply a default value `base`.
|
|
1088
|
+
>
|
|
1089
|
+
> If you designate to this value as undefined name of color theme, this package will ignore it in internal erroring disposer.
|
|
1090
|
+
|
|
1091
|
+
> 2. Intensity level
|
|
1092
|
+
>
|
|
1093
|
+
> The intensity level is a integer value between `0` (almost white) and `999` (almost black).
|
|
1094
|
+
>
|
|
1095
|
+
> When you omit this value in `color[[...]]`, this package will apply a default value `400`.
|
|
1096
|
+
>
|
|
1097
|
+
> At default color theme, Intensity level takes easily recognizable number.
|
|
1098
|
+
> But there are no limitation about range of interger value, when you registered by `appendUserColor(...)` option.
|
|
1099
|
+
>
|
|
1100
|
+
> If you designate to this value which unregistered intensity level at the color theme, this package will ignore it in internal erroring disposer.
|
|
1101
|
+
|
|
1102
|
+
> 3. Alpha value
|
|
1103
|
+
>
|
|
1104
|
+
> The alpha value is a percentage value between `0%` (perfect transparency) and `100%` (perfect intransparency).
|
|
1105
|
+
>
|
|
1106
|
+
> When you omit this value in `color[[...]]`, this package will apply a default value `100%`.
|
|
1107
|
+
>
|
|
1108
|
+
> This value is available as decimal notation with `%` character like a `50.5%`.
|
|
1109
|
+
>
|
|
1110
|
+
> But you cannot designate without `%` character like a `1`, for example you will wish "I want to present a alpha value by decimal notation style which ranged among `0`, `0.5`, and `1`."
|
|
1111
|
+
>
|
|
1112
|
+
> In above case, this package couldn't understand about `1`, "This number is what? Alpha value or intensity level?"
|
|
1113
|
+
>
|
|
1114
|
+
> Therefore you need to treat postfixing a PERCENT (`%`) character absolutely.
|
|
1115
|
+
|
|
1116
|
+
> 4. Output style
|
|
1117
|
+
>
|
|
1118
|
+
> The output style is a string literal, how to print to CSS files.
|
|
1119
|
+
>
|
|
1120
|
+
> When you omit this value in `color[[...]]`, this package will apply a default value `hsl`.
|
|
1121
|
+
>
|
|
1122
|
+
> You can choose in this value as `hsl`, ` rgb`, and `oklch`.
|
|
1123
|
+
> These are interpreted as same in uppercase or lowercase.
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
#### prependDefaultColor option
|
|
1127
|
+
|
|
1128
|
+
```javascript
|
|
1129
|
+
enumSpreader({
|
|
1130
|
+
prependDefaultColor: true,
|
|
1131
|
+
// ...
|
|
1132
|
+
})
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
If you turn to other value than `false` in a package option `prependDefaultColor`, this print CSS variables about color themes to CSS files.
|
|
1136
|
+
|
|
1137
|
+
> Available value is only `hsl`, `rgb`, `oklch`, and `true` (is equal as `hsl`).
|
|
1138
|
+
>
|
|
1139
|
+
> In the case of string literal (`hsl`, `rgb`, and `oklch`), there are interpreted as same in uppercase or lowercase.
|
|
1140
|
+
|
|
1141
|
+
```css
|
|
1142
|
+
:root {
|
|
1143
|
+
--color-red-400: hsl(5 61% 53.7%);
|
|
1144
|
+
}
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
You may designate to output CSS color values by using this settings.
|
|
1148
|
+
|
|
1149
|
+
```scss
|
|
1150
|
+
/* 🚧Before */
|
|
1151
|
+
h1 {
|
|
1152
|
+
@enums ct:var(--color-red-400);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/* 🚀After */
|
|
1156
|
+
h1 {
|
|
1157
|
+
color: hsl(5 61% 53.7%);
|
|
1158
|
+
}
|
|
1159
|
+
```
|
|
1160
|
+
|
|
1161
|
+
The advantage of this method is a point that you can also use color settings even if are over the out of "PostCSS Enumerates in Line" package.
|
|
1162
|
+
|
|
1163
|
+
However, there are disadvantages.
|
|
1164
|
+
- You cannot apply an alpha value because there is no way to extract a real CSS color value from CSS variables.
|
|
1165
|
+
- Huge CSS variables for CSS color settings will be outputted in CSS files.It maybe impacts to page loading speed.
|
|
1166
|
+
|
|
1167
|
+
Please use them according to wanted situation.
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare module "postcss-enumerates-in-line"
|
|
2
2
|
|
|
3
3
|
interface EnumsEnumeratesInLineOptions extends object {
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ interface EnumsEnumeratesInLineOptions extends object {
|
|
|
9
9
|
* But if set 'HSL' (also available 'hsl'), prints which styled in `hsl(0 100% 50%)`.
|
|
10
10
|
* Then if set 'OKLCH' (also available 'oklch'), prints which styled in `oklch(63% 26 29.93)`.
|
|
11
11
|
*/
|
|
12
|
-
prependDefaultColor?: true | '',
|
|
12
|
+
prependDefaultColor?: true | false | '',
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @param {boolean|string[]} prependDefaultStyle - Enable to print default CSS styles.
|
|
@@ -17,6 +17,51 @@ interface EnumsEnumeratesInLineOptions extends object {
|
|
|
17
17
|
* If set true, this will print default CSS styles which defined of the package.
|
|
18
18
|
* If set {string[]} (like a ['a {text-decoration: underline}', 'a:hover {text-decoration: none}']), this will print CSS styles both package's default one and designate one.
|
|
19
19
|
*/
|
|
20
|
-
prependDefaultStyle?: true | [''],
|
|
20
|
+
prependDefaultStyle?: true | false | [''],
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {UserColor[]} appendUserColor - Append user color settings to default color.
|
|
24
|
+
*/
|
|
25
|
+
appendUserColor?: [],
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {Object{<string>,<string>[]}[]} appendShorthand - Append user shorthand settings to default shorthand.
|
|
29
|
+
*/
|
|
30
|
+
appendShorthand?: []
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface UserColor extends object {
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} theme - The name of color theme.
|
|
36
|
+
*/
|
|
37
|
+
theme: '',
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {UserColorLevel[]} levels - Color levels
|
|
41
|
+
*/
|
|
42
|
+
levels: [],
|
|
21
43
|
}
|
|
44
|
+
|
|
45
|
+
interface UserColorLevel extends object {
|
|
46
|
+
/**
|
|
47
|
+
* @param {number} level - Light/Dark level
|
|
48
|
+
*/
|
|
49
|
+
level: 0,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {string} rgb - Color value which styles in RGB.
|
|
53
|
+
*/
|
|
54
|
+
rgb: '',
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {string} hsl - Color value which styles in HSL.
|
|
58
|
+
*/
|
|
59
|
+
hsl: '',
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} oklch - Color value which styles in OKLCH.
|
|
63
|
+
*/
|
|
64
|
+
oklch: '',
|
|
65
|
+
}
|
|
66
|
+
|
|
22
67
|
export declare function enumSpreader(options?: EnumsEnumeratesInLineOptions): import('postcss').Plugin
|