postcss-enumerates-in-line 1.0.0 → 1.2.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 CHANGED
@@ -5,29 +5,20 @@
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
- ## 更新点: v1.0.0
8
+ ## 更新点: v1.2.0
9
9
 
10
- 0. パッケージ全般
10
+ - 以下の引用符に関する正規表現の不具合を修正
11
+ + `data(name="value")!`
12
+ + `aria(name="value")!`
13
+ + `attr(name="value")!`
11
14
 
12
- - サンプルプログラムの更新
13
- - メジャーアップデート
15
+ > `data(name='value')!`のように`'`で囲んでいる場合も含みます。
14
16
 
15
- 1. 色設定
16
-
17
- - CSSプロパティ値に色設定を行う`color[[...]]`関数を追加
18
- - プラグインのオプションに色テーマを追加する`appendUserColors(...)`を追加
19
- - プラグインオプション`prependDefaultColor`の初期設定を`false`に変更
20
-
21
- 2. ショートハンド設定
22
-
23
- - プラグインのオプションにユーザー定義ショートハンドを拡張する`appendShorthand(...)`を追加
24
-
25
- 3. CSSプロパティ
26
-
27
- - 条件付きCSSプロパティ`attr(<attributes>)!`を追加
28
-
29
-
30
- ## 実装予定
17
+ - `mq(...)!`の`width`と`height`において、説明の抜けていた設定方法を加筆
18
+ + `mq(width=-1000px)`: `max-width: 1000px`と同等 ~~(記述済み)~~
19
+ + `mq(width=1000px-2000px)`: `min-width: 1000px and max-width: 2000px`と同等 ~~(記述済み)~~
20
+ + `mq(width=1000px-)`: `min-width: 1000px`と同等 ~~(記述済み)~~
21
+ + `mq(width=1000px)`: `width: 1000px`と同等 **(説明漏れ)**
31
22
 
32
23
 
33
24
  ---
@@ -88,8 +79,7 @@
88
79
  ## 目次
89
80
 
90
81
  - [PostCSS Enumerates in Line](#postcss-enumerates-in-line)
91
- - [更新点: v1.0.0](#更新点-v100)
92
- - [実装予定](#実装予定)
82
+ - [更新点: v1.2.0](#更新点-v120)
93
83
  - [目次](#目次)
94
84
  - [CSSでの記述方法](#cssでの記述方法)
95
85
  - [条件付き書式](#条件付き書式)
@@ -296,20 +286,22 @@ body {
296
286
  }
297
287
  ```
298
288
 
299
- > `width`に指定可能な条件値は、`-<length>`・`<length>-<length>`・`<length>-`の3種類です。
289
+ > `width`に指定可能な条件値は、`-<length>`・`<length>-<length>`・`<length>-`・`<length>`の4種類です。
300
290
  >
301
291
  > `<length>`に指定可能なのは`px`・`rem`・`vw`など長さに関わる値です。
302
292
  >
303
293
  > + 1つのみある`<length>`の前に`-`を付けた場合、`<length>`以下のメディアクエリを意味します(適用されるメディア特性は`max-width`)
304
294
  > + 2つの`<length>`を`-`で接続した場合、その区間以内であるメディアクエリを意味します(適用されるメディア特性は`min-width`と`max-width`)
305
295
  > + 1つのみある`<length>`の後ろに`-`を付けた場合、`<length>`以上のメディアクエリを意味します(適用されるメディア特性は`min-width`)
296
+ > + `<length>`が1つのみあって`-`がない場合、ビューポートサイズが`<length>`とまったく等しい状態を意味します(適用されるメディア特性は`width`)
306
297
 
307
298
  ```scss
308
299
  body {
309
300
  @enums
310
301
  mq(width:-480px)!m2:1rem
311
302
  mq(width:640px-1024px)!mx:1rem
312
- mq(width:1280px)!m8:1rem
303
+ mq(width:1280px-)!m8:1rem
304
+ mq(width:540px)!m4:1rem
313
305
  ;
314
306
  }
315
307
  ```
@@ -323,7 +315,8 @@ body {
323
315
  @enums
324
316
  mq(height:-480px)!m2:1rem
325
317
  mq(height:640px-1024px)!mx:1rem
326
- mq(height:1280px)!m8:1rem
318
+ mq(height:1280px-)!m8:1rem
319
+ mq(height:540px)!m4:1rem
327
320
  ;
328
321
  }
329
322
  ```
@@ -332,7 +325,7 @@ body {
332
325
  >
333
326
  > `@media (aspect-ratio: 16/9)`のような除算記号(`/`)を使った表記はできません。
334
327
  >
335
- > `width`・`height`に似た表記が可能で、`-<number>`・`<number>-<number>`・`<number>-`の3種類と`<number>`が実際に指定可能な条件値です。
328
+ > `width`・`height`に似た表記が可能で、`-<number>`・`<number>-<number>`・`<number>-`・`<number>`の4種類が実際に指定可能な条件値です。
336
329
  >
337
330
  > + 1つのみある`<number>`の前に`-`を付けた場合、`<number>`以下のメディアクエリを意味します(適用されるメディア特性は`max-aspect-ratio`)
338
331
  > + 2つの`<number>`を`-`で接続した場合、その区間以内であるメディアクエリを意味します(適用されるメディア特性は`min-aspect-ratio`と`max-aspect-ratio`)
@@ -590,6 +583,8 @@ h1 {
590
583
  >
591
584
  > 未定義の色テーマや濃度レベルを指定した場合、エラーとして扱われ無視されます。
592
585
 
586
+ > また引数が何も指定されず`color[[]]`とだけ指定された場合、エラー処理として`#0000`へと変換します。
587
+
593
588
  この関数を使うことで、透過率が設定できる他、色テーマをプラグインのオプションである`appendUserColors(...)`でユーザー独自の定義を追加できる上に、`prependDefaultColor`を初期値の`false`以外にするとCSS変数として色情報が`:root`ブロックに出力されることでCSSファイルサイズが大きくなるなど、様々なデメリットが解消されるでしょう。
594
589
 
595
590
 
@@ -1085,6 +1080,8 @@ h1 {
1085
1080
 
1086
1081
  ただし構文上の制約から、最低1種類は引数として指定してください。
1087
1082
 
1083
+ 引数がなく`color[[]]`と記述してしまった場合、エラー処理として`#0000`へと変換されます。
1084
+
1088
1085
  > 1. 色テーマ名
1089
1086
  >
1090
1087
  > デフォルトカラーまたは`appendUserColor(...)`で登録したもの。
package/README_EN.md CHANGED
@@ -5,30 +5,20 @@
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 v1.0.0
8
+ ## Revision: in v1.2.0
9
9
 
10
- 0. About package
10
+ - fix regex problems of quote character (`'`, `"`) in below.
11
+ + `data(name="value")!`
12
+ + `aria(name="value")!`
13
+ + `attr(name="value")!`
11
14
 
12
- - Update sample programs.
13
- - Upgrade major version to v1.
15
+ > `data(name='value')!` etc. too.
14
16
 
15
- 1. Color settings
16
-
17
- - Added a function `color[[...]]` for value of CSS property which designate a color.
18
- - Added a plugin's option `appendUserColors(...)` for extending user color themes.
19
- - Changed a plugin's option `prependDefaultColor` that default value turn to `false`.
20
-
21
- 2. Shorthand settings
22
-
23
- - Added a plugin's option `appendShorthand(...)` for extending user shorthands which is used about CSS property name.
24
-
25
- 3. CSS property
26
-
27
- - Added conditional CSS property name about below.
28
- + `attr(<attributes>)`
29
-
30
-
31
- ## Maybe add functions
17
+ - Touch up a documents adding about `width` and `height` in `mq(...)!`.
18
+ + `mq(width=-1000px)`: As equal as `max-width: 1000px` ~~(Already wrote)~~
19
+ + `mq(width=1000px-2000px)`: As equal as `min-width: 1000px and max-width: 2000px` ~~(Already wrote)~~
20
+ + `mq(width=1000px-)`: As equal as `min-width: 1000px` ~~(Already wrote)~~
21
+ + `mq(width=1000px)`: As equal as `width: 1000px` **(Missing explanation)**
32
22
 
33
23
 
34
24
  ---
@@ -88,8 +78,7 @@ I think primary usage is [gulp] and [gulp-postcss]. However it also works on JS-
88
78
  ## Indexes
89
79
 
90
80
  - [PostCSS Enumerates in Line](#postcss-enumerates-in-line)
91
- - [Revision: in v1.0.0](#revision-in-v100)
92
- - [Maybe add functions](#maybe-add-functions)
81
+ - [Revision: in v1.2.0](#revision-in-v120)
93
82
  - [Indexes](#indexes)
94
83
  - [Method of writing in CSS files.](#method-of-writing-in-css-files)
95
84
  - [Conditional CSS property](#conditional-css-property)
@@ -297,20 +286,22 @@ body {
297
286
  }
298
287
  ```
299
288
 
300
- > In `width` case; there are 3 type of designatable value. `-<length>`, `<length>-<length>`, and `<length>-`.
289
+ > In `width` case; there are 4 type of designatable value. `-<length>`, `<length>-<length>`, `<length>-`, and `<length>`.
301
290
  >
302
291
  > You will be able to designate to `<length>` as these numeric values, that is related to length which tied with CSS sizing units; `px`, `rem`, `vw`, etc.
303
292
  >
304
293
  > + In `-<length>` case (the syntax is `<length>` with `-` prefix) -- this plugin recognize it as "This media query is smaller than `<length>`". (Applied media feature is `max-width`.)
305
294
  > + In `<length>-<length>` case (the syntax is `-` sandwiching by 2 `<length>`) -- this plugin recognize it as "This media query still is range of between first `<length>` and second `<length>`". (Applied media feature are `min-width` and `max-width`.)
306
295
  > + In `<length>-` case (the syntax is `<length>` with `-` postfix) -- this plugin recognize it as "This media query is larger than `<length>`". (Applied media feature is `min-width`.)
296
+ > + In `<length>` case (the syntax only is `<length>` and without any `-`) -- this plugin recognize it as "This viewport size is as just equal as `<length>`". (Applied media feature is `width`.)
307
297
 
308
298
  ```scss
309
299
  body {
310
300
  @enums
311
301
  mq(width:-480px)!m2:1rem
312
302
  mq(width:640px-1024px)!mx:1rem
313
- mq(width:1280px)!m8:1rem
303
+ mq(width:1280px-)!m8:1rem
304
+ mq(width:540px)!m4:1rem
314
305
  ;
315
306
  }
316
307
  ```
@@ -324,7 +315,8 @@ body {
324
315
  @enums
325
316
  mq(height:-480px)!m2:1rem
326
317
  mq(height:640px-1024px)!mx:1rem
327
- mq(height:1280px)!m8:1rem
318
+ mq(height:1280px-)!m8:1rem
319
+ mq(height:540px)!m4:1rem
328
320
  ;
329
321
  }
330
322
  ```
@@ -585,6 +577,8 @@ This function-like syntax takes 4 kind arguments in maximum.
585
577
  > 3. `100%`
586
578
  > 4. `hsl`
587
579
 
580
+ > And also if `color[[...]]` leads no arguments like a `color[[]]`, this package transform it to `#0000` as error handling.
581
+
588
582
  You will eliminate some problems as below if use this function.
589
583
  - Can apply opacity.
590
584
  - And that also apply to user defined color theme which added by `appendUserColors(...)` in package option.
@@ -1086,6 +1080,8 @@ Every kinds are optional arguments, so there are omittable.
1086
1080
 
1087
1081
  But, by and for syntax restriction, you need to designate arguments at least 1 kind and up.
1088
1082
 
1083
+ And also if there are no arguments like a `color[[]]`, this package transform it to `#0000` as error handling.
1084
+
1089
1085
  > 1. Color theme
1090
1086
  >
1091
1087
  > The name of default color theme, or that registered in `appendUserColor(...)` option.
package/index.mjs CHANGED
@@ -271,9 +271,9 @@ export const enumSpreader = (options = {}) => {
271
271
  if(/data\(.+?\)!/.test(param[i])) {
272
272
  setting.isData = []
273
273
  ;(!!param[i].match(/data\((.+?)\)!/)[1] ? param[i].match(/data\((.+?)\)!/)[1] : '').split(',').forEach(q => {
274
- let v1 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)([\~\|\^\$\*]?=)['"](.*)['"]$/)
274
+ let v1 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)([\~\|\^\$\*]?=)(?:(?=["])["](.*)["]|(?=['])['](.*)['])$/)
275
275
  if(!!v1) {
276
- setting.isData.push(`[data-${v1[1]}${v1[2]}"${v1[3].replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
276
+ setting.isData.push(`[data-${v1[1]}${v1[2]}"${(v1[3]||v1[4]).replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
277
277
  } else {
278
278
  let v2 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)$/)
279
279
  if(!!v2) {
@@ -288,9 +288,9 @@ export const enumSpreader = (options = {}) => {
288
288
  if(/aria\(.+?\)!/.test(param[i])) {
289
289
  setting.isAria = []
290
290
  ;(!!param[i].match(/aria\((.+?)\)!/)[1] ? param[i].match(/aria\((.+?)\)!/)[1] : '').split(',').forEach(q => {
291
- let v = q.match(/^([a-z]+)=['"](.*)['"]$/)
291
+ let v = q.match(/^([a-z]+)=(?:(?=["])["](.*)["]|(?=['])['](.*)['])$/)
292
292
  if(!!v) {
293
- setting.isAria.push(`[aria-${v[1]}="${v[2].replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
293
+ setting.isAria.push(`[aria-${v[1]}="${(v[2]||v[3]).replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
294
294
  }
295
295
  })
296
296
  setting.isAria = setting.isAria.join('')
@@ -300,9 +300,9 @@ export const enumSpreader = (options = {}) => {
300
300
  if(/attr\(.+?\)!/.test(param[i])) {
301
301
  setting.isAttr = []
302
302
  ;(!!param[i].match(/attr\((.+?)\)!/)[1] ? param[i].match(/attr\((.+?)\)!/)[1] : '').split(',').forEach(q => {
303
- let v1 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)([\~\|\^\$\*]?=)['"](.*)['"]$/)
303
+ let v1 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)([\~\|\^\$\*]?=)(?:(?=["])["](.*)["]|(?=['])['](.*)['])$/)
304
304
  if(!!v1) {
305
- setting.isAttr.push(`[${v1[1]}${v1[2]}"${v1[3].replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
305
+ setting.isAttr.push(`[${v1[1]}${v1[2]}"${(v1[3]||v1[4]).replace('\%','%25').replace('\"','%22').replace('\'','%27').replace('\`','%60').replace('\\','%5D')}"]`)
306
306
  } else {
307
307
  let v2 = q.match(/^([A-Za-z\d_](?:[A-Za-z\d_\-]*[A-Za-z\d_])?)$/)
308
308
  if(!!v2) {
@@ -482,6 +482,7 @@ const replaceCssPropertyValueWBracket = value => value.replace(/\^/g, ' ')
482
482
  .replace(/\[\[([^}]+)\]\]/g,(_,expr)=>`[[${expr.replace(/([+\*/]|(?<=[0-9a-zA-Z\)])[-%](?=[0-9a-zA-Z\(]))/g,' $1 ')}]]`)
483
483
  .replace('[[', '(')
484
484
  .replace(']]', ')')
485
+ .replace('color()', '#0000')
485
486
  .replace(/ +/g, ' ')
486
487
 
487
488
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "postcss-enumerates-in-line",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/hadukinei/postcss-enumerates-in-line"