lism-css 0.9.4 → 0.10.1

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.
Files changed (182) hide show
  1. package/README.md +5 -5
  2. package/bin/__build-css.cjs +54 -54
  3. package/bin/build-config.js +120 -120
  4. package/bin/build-css.js +52 -52
  5. package/bin/cli.mjs +33 -33
  6. package/config/__prop_list.js +42 -42
  7. package/config/__props.scss +20 -20
  8. package/config/default-config.ts +3 -3
  9. package/config/defaults/props.ts +326 -326
  10. package/config/defaults/states.ts +38 -38
  11. package/config/defaults/tokens.ts +25 -25
  12. package/config/helper/getSvgUrl.ts +16 -16
  13. package/config/helper/minifyHtml.ts +11 -11
  14. package/config/helper.test.ts +231 -231
  15. package/config/helper.ts +43 -49
  16. package/config/index.ts +4 -4
  17. package/config/tsconfig.json +16 -16
  18. package/dist/components/Dummy/Dummy.d.ts +6 -9
  19. package/dist/components/Dummy/index.js +5 -10
  20. package/dist/components/Group/Group.d.ts +3 -0
  21. package/dist/components/Group/index.d.ts +1 -0
  22. package/dist/components/Group/index.js +8 -0
  23. package/dist/components/HTML/HTML.d.ts +10 -0
  24. package/dist/components/Heading/Heading.d.ts +7 -0
  25. package/dist/components/Heading/index.d.ts +1 -0
  26. package/dist/components/Heading/index.js +9 -0
  27. package/dist/components/Inline/Inline.d.ts +3 -0
  28. package/dist/components/Inline/index.d.ts +1 -0
  29. package/dist/components/Inline/index.js +8 -0
  30. package/dist/components/Layer/Layer.d.ts +1 -2
  31. package/dist/components/Layer/index.js +3 -4
  32. package/dist/components/Link/Link.d.ts +2 -0
  33. package/dist/components/Link/index.d.ts +1 -0
  34. package/dist/components/Link/index.js +8 -0
  35. package/dist/components/LinkBox/LinkBox.d.ts +3 -2
  36. package/dist/components/LinkBox/index.js +5 -5
  37. package/dist/components/Lism/Lism.d.ts +7 -8
  38. package/dist/components/List/List.d.ts +3 -0
  39. package/dist/components/List/ListItem.d.ts +3 -0
  40. package/dist/components/List/ListItem.js +8 -0
  41. package/dist/components/List/index.d.ts +2 -0
  42. package/dist/components/List/index.js +8 -0
  43. package/dist/components/Text/Text.d.ts +3 -0
  44. package/dist/components/Text/index.d.ts +1 -0
  45. package/dist/components/Text/index.js +8 -0
  46. package/dist/components/atomic/Decorator/getProps.d.ts +1 -3
  47. package/dist/components/atomic/Decorator/getProps.js +10 -10
  48. package/dist/components/atomic/Icon/getProps.d.ts +1 -2
  49. package/dist/components/atomic/Icon/getProps.js +35 -34
  50. package/dist/components/atomic/Media/Media.d.ts +1 -4
  51. package/dist/components/atomic/Media/Media.stories.d.ts +1 -2
  52. package/dist/components/atomic/Media/index.js +4 -5
  53. package/dist/components/index.d.ts +8 -1
  54. package/dist/components/index.js +50 -36
  55. package/dist/config/helper.d.ts +1 -1
  56. package/dist/css/main.css +1 -1
  57. package/dist/css/main_no_layer.css +1 -1
  58. package/dist/css/modules/atomic.css +1 -1
  59. package/dist/css/modules/layout.css +1 -1
  60. package/dist/lib/getLismProps.d.ts +3 -2
  61. package/dist/lib/getMaybeCssVar.js +15 -10
  62. package/package.json +2 -1
  63. package/packages/astro/Box/Box.astro +6 -4
  64. package/packages/astro/Center/Center.astro +6 -3
  65. package/packages/astro/Cluster/Cluster.astro +6 -3
  66. package/packages/astro/Columns/Columns.astro +6 -3
  67. package/packages/astro/Container/Container.astro +7 -5
  68. package/packages/astro/Decorator/Decorator.astro +8 -5
  69. package/packages/astro/Divider/Divider.astro +5 -4
  70. package/packages/astro/Dummy/Dummy.astro +9 -12
  71. package/packages/astro/Flex/Flex.astro +6 -3
  72. package/packages/astro/Flow/Flow.astro +7 -3
  73. package/packages/astro/FluidCols/FluidCols.astro +7 -3
  74. package/packages/astro/Frame/Frame.astro +6 -3
  75. package/packages/astro/Grid/Grid.astro +6 -3
  76. package/packages/astro/Group/Group.astro +11 -0
  77. package/packages/astro/Group/index.ts +1 -0
  78. package/packages/astro/HTML/_index_memo.js +7 -7
  79. package/packages/astro/HTML/a.astro +5 -4
  80. package/packages/astro/HTML/button.astro +5 -4
  81. package/packages/astro/HTML/div.astro +5 -4
  82. package/packages/astro/HTML/h.astro +5 -4
  83. package/packages/astro/HTML/img.astro +5 -4
  84. package/packages/astro/HTML/li.astro +5 -4
  85. package/packages/astro/HTML/ol.astro +5 -4
  86. package/packages/astro/HTML/p.astro +5 -4
  87. package/packages/astro/HTML/span.astro +5 -4
  88. package/packages/astro/HTML/ul.astro +5 -4
  89. package/packages/astro/Heading/Heading.astro +13 -0
  90. package/packages/astro/Heading/index.ts +1 -0
  91. package/packages/astro/Icon/Icon.astro +13 -10
  92. package/packages/astro/Icon/SVG.astro +16 -16
  93. package/packages/astro/Inline/Inline.astro +11 -0
  94. package/packages/astro/Inline/index.ts +1 -0
  95. package/packages/astro/Layer/Layer.astro +6 -6
  96. package/packages/astro/Link/Link.astro +10 -0
  97. package/packages/astro/Link/index.ts +1 -0
  98. package/packages/astro/LinkBox/LinkBox.astro +9 -9
  99. package/packages/astro/Lism/Lism.astro +5 -7
  100. package/packages/astro/List/List.astro +11 -0
  101. package/packages/astro/List/ListItem.astro +11 -0
  102. package/packages/astro/List/index.ts +2 -0
  103. package/packages/astro/Media/Media.astro +6 -9
  104. package/packages/astro/SideMain/SideMain.astro +7 -3
  105. package/packages/astro/Spacer/Spacer.astro +6 -4
  106. package/packages/astro/Stack/Stack.astro +6 -3
  107. package/packages/astro/SwitchCols/SwitchCols.astro +7 -3
  108. package/packages/astro/Text/Text.astro +11 -0
  109. package/packages/astro/Text/index.ts +1 -0
  110. package/packages/astro/Wrapper/Wrapper.astro +8 -5
  111. package/packages/astro/env.d.ts +3 -3
  112. package/packages/astro/index.ts +9 -0
  113. package/packages/astro/tsconfig.json +10 -10
  114. package/packages/astro/types.ts +10 -42
  115. package/src/scss/__memo/_lh-auto-all.scss +12 -12
  116. package/src/scss/__memo/_lh-auto-h.scss +17 -17
  117. package/src/scss/__memo/_lh-manual.scss +27 -27
  118. package/src/scss/_auto_output.scss +174 -174
  119. package/src/scss/_mixin.scss +32 -32
  120. package/src/scss/_prop-config.scss +850 -850
  121. package/src/scss/_query.scss +26 -26
  122. package/src/scss/_setting.scss +6 -6
  123. package/src/scss/_with_layer.scss +13 -13
  124. package/src/scss/base/_html.scss +47 -47
  125. package/src/scss/base/set/_bp.scss +8 -8
  126. package/src/scss/base/set/_cqUnit.scss +22 -22
  127. package/src/scss/base/set/_gutter.scss +1 -1
  128. package/src/scss/base/set/_hov.scss +10 -10
  129. package/src/scss/base/set/_innerRs.scss +1 -1
  130. package/src/scss/base/set/_plain.scss +15 -15
  131. package/src/scss/base/set/_transition.scss +2 -2
  132. package/src/scss/base/tokens/_property.scss +3 -3
  133. package/src/scss/base/tokens/_shadow.scss +12 -12
  134. package/src/scss/base/tokens/_tokens.scss +77 -77
  135. package/src/scss/base/tokens/_typography.scss +69 -69
  136. package/src/scss/main_no_layer.scss +1 -1
  137. package/src/scss/modules/atomic/_divider.scss +4 -4
  138. package/src/scss/modules/atomic/_icon.scss +4 -4
  139. package/src/scss/modules/atomic/_spacer.scss +2 -2
  140. package/src/scss/modules/atomic/index.scss +0 -1
  141. package/src/scss/modules/layout/_center.scss +3 -3
  142. package/src/scss/modules/layout/_cluster.scss +3 -3
  143. package/src/scss/modules/layout/_columns.scss +3 -3
  144. package/src/scss/modules/layout/_flex.scss +4 -4
  145. package/src/scss/modules/layout/_flow.scss +16 -16
  146. package/src/scss/modules/layout/_fluidCols.scss +4 -4
  147. package/src/scss/modules/layout/_frame.scss +8 -8
  148. package/src/scss/modules/layout/_grid.scss +9 -9
  149. package/src/scss/modules/layout/_sideMain.scss +12 -12
  150. package/src/scss/modules/layout/_stack.scss +2 -2
  151. package/src/scss/modules/layout/_switchCols.scss +5 -5
  152. package/src/scss/modules/state/_container.scss +4 -4
  153. package/src/scss/modules/state/_layer.scss +3 -3
  154. package/src/scss/modules/state/_linkbox.scss +9 -9
  155. package/src/scss/modules/state/_vertical.scss +3 -3
  156. package/src/scss/modules/state/_wrapper.scss +8 -8
  157. package/src/scss/props/_border.scss +18 -18
  158. package/src/scss/props/_hover.scss +26 -26
  159. package/src/scss/props/_lh.scss +6 -6
  160. package/src/scss/props/_size.scss +7 -7
  161. package/src/scss/reset.scss +137 -137
  162. package/src/scss/utility/_cbox.scss +10 -10
  163. package/src/scss/utility/_clipText.scss +2 -2
  164. package/src/scss/utility/_hidden.scss +9 -9
  165. package/src/scss/utility/_itemDivider.scss +7 -7
  166. package/src/scss/utility/_linkExpand.scss +9 -9
  167. package/src/scss/utility/_snap.scss +5 -5
  168. package/src/scss/utility/_trimHL.scss +11 -11
  169. package/dist/components/Dummy/getContent.d.ts +0 -12
  170. package/dist/components/Dummy/getContent.js +0 -9
  171. package/dist/components/Dummy/texts.d.ts +0 -22
  172. package/dist/components/Dummy/texts.js +0 -39
  173. package/dist/components/Layer/getProps.d.ts +0 -5
  174. package/dist/components/atomic/Media/getProps.d.ts +0 -9
  175. package/dist/components/atomic/Media/getProps.js +0 -8
  176. package/dist/components/getFilterProps.d.ts +0 -10
  177. package/dist/components/getFilterProps.js +0 -23
  178. package/dist/components/getFilterProps.test.d.ts +0 -1
  179. package/dist/components/setMaybeTransformStyles.d.ts +0 -12
  180. package/dist/components/setMaybeTransformStyles.js +0 -7
  181. package/dist/components/setMaybeTransformStyles.test.d.ts +0 -1
  182. package/src/scss/modules/atomic/_media.scss +0 -3
package/README.md CHANGED
@@ -30,7 +30,7 @@ For Next.js, load it in `layout.js` (App Router) or `_app.js` (Pages Router).
30
30
  For HTML sites, you can load CSS via CDN:
31
31
 
32
32
  ```html
33
- <link href="https://cdn.jsdelivr.net/npm/lism-css/dist/css/main.css" rel="stylesheet" />
33
+ <link href="https://cdn.jsdelivr.net/npm/lism-css@0.9.4/dist/css/main.css" rel="stylesheet" />
34
34
  ```
35
35
 
36
36
  ## Usage
@@ -38,11 +38,11 @@ For HTML sites, you can load CSS via CDN:
38
38
  ### React
39
39
 
40
40
  ```jsx
41
- import { Box, Flex, Stack, HTML } from 'lism-css/react';
41
+ import { Box, Flex, Stack, Text } from 'lism-css/react';
42
42
 
43
43
  <Stack g="20">
44
44
  <Box p="20" bgc="base-2">
45
- <HTML.p fz="l">Lorem ipsum text...</HTML.p>
45
+ <Text fz="l">Lorem ipsum text...</Text>
46
46
  </Box>
47
47
  </Stack>
48
48
  ```
@@ -51,12 +51,12 @@ import { Box, Flex, Stack, HTML } from 'lism-css/react';
51
51
 
52
52
  ```astro
53
53
  ---
54
- import { Box, Flex, Stack, HTML } from 'lism-css/astro';
54
+ import { Box, Flex, Stack, Text } from 'lism-css/astro';
55
55
  ---
56
56
 
57
57
  <Stack g="20">
58
58
  <Box p="20" bgc="base-2">
59
- <HTML.p fz="l">Lorem ipsum text...</HTML.p>
59
+ <Text fz="l">Lorem ipsum text...</Text>
60
60
  </Box>
61
61
  </Stack>
62
62
  ```
@@ -18,9 +18,9 @@ const cssnano = require('cssnano');
18
18
 
19
19
  // consoleの色付け
20
20
  const COLOR = {
21
- red: '\u001b[31m',
22
- green: '\u001b[32m',
23
- reset: '\x1b[0m',
21
+ red: '\u001b[31m',
22
+ green: '\u001b[32m',
23
+ reset: '\x1b[0m',
24
24
  };
25
25
 
26
26
  // 環境変数・引数
@@ -28,65 +28,65 @@ const COLOR = {
28
28
  // const TARGET_DIR = process.argv[2] || '';
29
29
 
30
30
  (() => {
31
- // パス(絶対パスに変換)
32
- let src = path.resolve(__dirname, '../src/scss');
33
- let dist = path.resolve(__dirname, '../dist/css');
34
- compileSCSS(src, dist);
35
-
36
- // component
37
- src = path.resolve(__dirname, '../src/components');
38
- dist = path.resolve(__dirname, '../dist/components');
39
- console.log('compileSCSS', src, dist);
40
- compileSCSS(src, dist);
31
+ // パス(絶対パスに変換)
32
+ let src = path.resolve(__dirname, '../src/scss');
33
+ let dist = path.resolve(__dirname, '../dist/css');
34
+ compileSCSS(src, dist);
35
+
36
+ // component
37
+ src = path.resolve(__dirname, '../src/components');
38
+ dist = path.resolve(__dirname, '../dist/components');
39
+ console.log('compileSCSS', src, dist);
40
+ compileSCSS(src, dist);
41
41
  })();
42
42
 
43
43
  // scssファイル処理
44
44
  async function compileSCSS(src, dist) {
45
- let files = [];
46
-
47
- const ignore = ['**/_*.scss'];
48
- files = glob.sync(src + '/**/*.scss', { ignore });
49
- // console.log('files', files);
50
-
51
- for (const filePath of files) {
52
- console.log(COLOR.green + 'Start sassRender: ' + COLOR.reset + filePath);
53
-
54
- const fileName = filePath.replace(src + '/', '');
55
- const srcPath = path.resolve(__dirname, src, fileName);
56
- const distPath = path.resolve(__dirname, dist, fileName).replace('.scss', '.css').replace('/index.css', '.css');
57
-
58
- try {
59
- // dart sass コンパイル
60
- const compiledCSS = sass.compile(srcPath, {
61
- style: 'expanded', // 圧縮はcssnanoに任せる
62
- });
63
-
64
- // postcss実行
65
- postcss([autoprefixer, cssnano])
66
- .process(compiledCSS.css, { from: undefined })
67
- .then((postcssResult) => {
68
- writeCSS(distPath, postcssResult.css);
69
- });
70
-
71
- // console.log(COLOR.green + 'Completed.');
72
- } catch (error) {
73
- console.log(COLOR.red + '\n========== ! ERROR ==========' + COLOR.reset);
74
- console.log(error);
75
- console.log(COLOR.red + '========== / ERROR ========== \n' + COLOR.reset);
76
- }
77
- }
45
+ let files = [];
46
+
47
+ const ignore = ['**/_*.scss'];
48
+ files = glob.sync(src + '/**/*.scss', { ignore });
49
+ // console.log('files', files);
50
+
51
+ for (const filePath of files) {
52
+ console.log(COLOR.green + 'Start sassRender: ' + COLOR.reset + filePath);
53
+
54
+ const fileName = filePath.replace(src + '/', '');
55
+ const srcPath = path.resolve(__dirname, src, fileName);
56
+ const distPath = path.resolve(__dirname, dist, fileName).replace('.scss', '.css').replace('/index.css', '.css');
57
+
58
+ try {
59
+ // dart sass コンパイル
60
+ const compiledCSS = sass.compile(srcPath, {
61
+ style: 'expanded', // 圧縮はcssnanoに任せる
62
+ });
63
+
64
+ // postcss実行
65
+ postcss([autoprefixer, cssnano])
66
+ .process(compiledCSS.css, { from: undefined })
67
+ .then((postcssResult) => {
68
+ writeCSS(distPath, postcssResult.css);
69
+ });
70
+
71
+ // console.log(COLOR.green + 'Completed.');
72
+ } catch (error) {
73
+ console.log(COLOR.red + '\n========== ! ERROR ==========' + COLOR.reset);
74
+ console.log(error);
75
+ console.log(COLOR.red + '========== / ERROR ========== \n' + COLOR.reset);
76
+ }
77
+ }
78
78
  }
79
79
 
80
80
  // 書き出し処理
81
81
  function writeCSS(filePath, css) {
82
- const dir = path.dirname(filePath);
82
+ const dir = path.dirname(filePath);
83
83
 
84
- // ディレクトリがなければ作成
85
- if (!fs.existsSync(dir)) {
86
- console.log('mkdir ' + dir);
87
- fs.mkdirSync(dir, { recursive: true });
88
- }
84
+ // ディレクトリがなければ作成
85
+ if (!fs.existsSync(dir)) {
86
+ console.log('mkdir ' + dir);
87
+ fs.mkdirSync(dir, { recursive: true });
88
+ }
89
89
 
90
- // css書き出し
91
- fs.writeFileSync(filePath, css);
90
+ // css書き出し
91
+ fs.writeFileSync(filePath, css);
92
92
  }
@@ -14,34 +14,34 @@ const __dirname = path.dirname(__filename);
14
14
  * @returns {Object} ユーティリティ値のオブジェクト
15
15
  */
16
16
  function generateUtilities(propConfig, TOKENS) {
17
- const { utils = {}, presets = [], token = '', tokenClass = 0 } = propConfig;
18
- const utilities = {};
19
-
20
- // tokenをクラス化するのであれば presetsへ追加
21
- if (token && tokenClass === 1) {
22
- const tokenValues = TOKENS[token];
23
- if (tokenValues && Array.isArray(tokenValues)) {
24
- presets.push(...tokenValues);
25
- } else if (tokenValues && typeof tokenValues === 'object') {
26
- presets.push(...(tokenValues.values || []));
27
- }
28
- }
29
-
30
- // presetsが定義されている場合
31
- if (presets.length > 0) {
32
- presets.forEach((preset) => {
33
- utilities[preset] = getMaybeTokenValue(token, preset, TOKENS);
34
- });
35
- }
36
-
37
- // utilsが定義されている場合
38
- if (utils) {
39
- Object.entries(utils).forEach(([key, value]) => {
40
- utilities[key] = value;
41
- });
42
- }
43
-
44
- return utilities;
17
+ const { utils = {}, presets = [], token = '', tokenClass = 0 } = propConfig;
18
+ const utilities = {};
19
+
20
+ // tokenをクラス化するのであれば presetsへ追加
21
+ if (token && tokenClass === 1) {
22
+ const tokenValues = TOKENS[token];
23
+ if (tokenValues && Array.isArray(tokenValues)) {
24
+ presets.push(...tokenValues);
25
+ } else if (tokenValues && typeof tokenValues === 'object') {
26
+ presets.push(...(tokenValues.values || []));
27
+ }
28
+ }
29
+
30
+ // presetsが定義されている場合
31
+ if (presets.length > 0) {
32
+ presets.forEach((preset) => {
33
+ utilities[preset] = getMaybeTokenValue(token, preset, TOKENS);
34
+ });
35
+ }
36
+
37
+ // utilsが定義されている場合
38
+ if (utils) {
39
+ Object.entries(utils).forEach(([key, value]) => {
40
+ utilities[key] = value;
41
+ });
42
+ }
43
+
44
+ return utilities;
45
45
  }
46
46
 
47
47
  /**
@@ -51,108 +51,108 @@ function generateUtilities(propConfig, TOKENS) {
51
51
  * @returns {string} SCSS形式の文字列
52
52
  */
53
53
  function generatePropScss(propKey, propConfig, TOKENS) {
54
- const { prop = '', bp, isVar, alwaysVar, overwriteBaseVar, important } = propConfig;
55
-
56
- // styleが定義されている場合はそれを使用、なければpropKeyをそのまま使用
57
- const utilities = generateUtilities(propConfig, TOKENS);
58
-
59
- // ユーティリティが存在するかどうか
60
- const hasUtilities = Object.keys(utilities).length > 0;
61
-
62
- // 出力するCSSがない場合
63
- if (!hasUtilities && !bp) {
64
- return '';
65
- }
66
-
67
- let scss = `\t'${propKey}': (\n`;
68
- if (isVar) {
69
- scss += `\t\tprop: '--${propKey}',\n`;
70
- } else {
71
- // propName を prop-name に変換(キャメルケースをケバブケースに変換)
72
- scss += `\t\tprop: '${prop.replace(/([A-Z])/g, '-$1').toLowerCase()}',\n`;
73
- }
74
-
75
- if (hasUtilities) {
76
- const exs = propConfig.exUtility || null;
77
-
78
- scss += `\t\tutilities: (\n`;
79
- Object.entries(utilities).forEach(([utilKey, value]) => {
80
- // キーに特殊文字が含まれる場合はエスケープ(/,%, : の前に \\ をつける(最終的にscss側の処理で \ ひとつになるようにここでは \\ ))
81
- const escapedKey = utilKey.replace(/\//g, '\\\\/').replace(/%/g, '\\\\%').replace(/:/g, '\\\\:');
82
-
83
- // exUtility としても定義されている場合はスキップ
84
- if (undefined === exs?.[utilKey]) {
85
- scss += `\t\t\t'${escapedKey}': '${value}',\n`;
86
- }
87
- });
88
- scss += `\t\t),\n`;
89
-
90
- if (exs) {
91
- scss += `\t\texUtility: (\n`;
92
-
93
- for (const [exKey, exProps] of Object.entries(exs)) {
94
- if (typeof exProps === 'object') {
95
- scss += `\t\t\t'${exKey}': (\n`;
96
- for (const _prop in exProps) {
97
- if (exProps[_prop]) {
98
- scss += `\t\t\t\t'${_prop}': '${exProps[_prop]}',\n`;
99
- }
100
- }
101
- scss += `\t\t\t),\n`;
102
- }
103
- }
104
- scss += `\t\t),\n`;
105
- }
106
- }
107
-
108
- if (bp !== undefined) {
109
- scss += `\t\tbp: ${bp},\n`;
110
- }
111
- if (isVar !== undefined) {
112
- scss += `\t\tisVar: ${isVar},\n`;
113
- }
114
- if (alwaysVar !== undefined) {
115
- scss += `\t\talwaysVar: ${alwaysVar},\n`;
116
- }
117
- if (overwriteBaseVar !== undefined) {
118
- scss += `\t\toverwriteBaseVar: ${overwriteBaseVar},\n`;
119
- }
120
- if (important !== undefined) {
121
- scss += `\t\timportant: ${important},\n`;
122
- }
123
-
124
- scss += `\t),`;
125
-
126
- return scss;
54
+ const { prop = '', bp, isVar, alwaysVar, overwriteBaseVar, important } = propConfig;
55
+
56
+ // styleが定義されている場合はそれを使用、なければpropKeyをそのまま使用
57
+ const utilities = generateUtilities(propConfig, TOKENS);
58
+
59
+ // ユーティリティが存在するかどうか
60
+ const hasUtilities = Object.keys(utilities).length > 0;
61
+
62
+ // 出力するCSSがない場合
63
+ if (!hasUtilities && !bp) {
64
+ return '';
65
+ }
66
+
67
+ let scss = ` '${propKey}': (\n`;
68
+ if (isVar) {
69
+ scss += ` prop: '--${propKey}',\n`;
70
+ } else {
71
+ // propName を prop-name に変換(キャメルケースをケバブケースに変換)
72
+ scss += ` prop: '${prop.replace(/([A-Z])/g, '-$1').toLowerCase()}',\n`;
73
+ }
74
+
75
+ if (hasUtilities) {
76
+ const exs = propConfig.exUtility || null;
77
+
78
+ scss += ` utilities: (\n`;
79
+ Object.entries(utilities).forEach(([utilKey, value]) => {
80
+ // キーに特殊文字が含まれる場合はエスケープ(/,%, : の前に \\ をつける(最終的にscss側の処理で \ ひとつになるようにここでは \\ ))
81
+ const escapedKey = utilKey.replace(/\//g, '\\\\/').replace(/%/g, '\\\\%').replace(/:/g, '\\\\:');
82
+
83
+ // exUtility としても定義されている場合はスキップ
84
+ if (undefined === exs?.[utilKey]) {
85
+ scss += ` '${escapedKey}': '${value}',\n`;
86
+ }
87
+ });
88
+ scss += ` ),\n`;
89
+
90
+ if (exs) {
91
+ scss += ` exUtility: (\n`;
92
+
93
+ for (const [exKey, exProps] of Object.entries(exs)) {
94
+ if (typeof exProps === 'object') {
95
+ scss += ` '${exKey}': (\n`;
96
+ for (const _prop in exProps) {
97
+ if (exProps[_prop]) {
98
+ scss += ` '${_prop}': '${exProps[_prop]}',\n`;
99
+ }
100
+ }
101
+ scss += ` ),\n`;
102
+ }
103
+ }
104
+ scss += ` ),\n`;
105
+ }
106
+ }
107
+
108
+ if (bp !== undefined) {
109
+ scss += ` bp: ${bp},\n`;
110
+ }
111
+ if (isVar !== undefined) {
112
+ scss += ` isVar: ${isVar},\n`;
113
+ }
114
+ if (alwaysVar !== undefined) {
115
+ scss += ` alwaysVar: ${alwaysVar},\n`;
116
+ }
117
+ if (overwriteBaseVar !== undefined) {
118
+ scss += ` overwriteBaseVar: ${overwriteBaseVar},\n`;
119
+ }
120
+ if (important !== undefined) {
121
+ scss += ` important: ${important},\n`;
122
+ }
123
+
124
+ scss += ` ),`;
125
+
126
+ return scss;
127
127
  }
128
128
 
129
129
  /**
130
130
  * メイン処理
131
131
  */
132
132
  export default async function buildConfig(CONFIG) {
133
- const { tokens: TOKENS, props: PROPS } = CONFIG;
134
- console.log('_prop-config.scssを生成中...');
133
+ const { tokens: TOKENS, props: PROPS } = CONFIG;
134
+ console.log('_prop-config.scssを生成中...');
135
135
 
136
- let scssContent = '';
136
+ let scssContent = '';
137
137
 
138
- scssContent += '$props: (\n';
139
- // 各プロパティをSCSS形式に変換
140
- Object.entries(PROPS).forEach(([propKey, propConfig], index, array) => {
141
- const propContent = generatePropScss(propKey, propConfig, TOKENS);
142
- if (!propContent) return;
143
- scssContent += propContent;
138
+ scssContent += '$props: (\n';
139
+ // 各プロパティをSCSS形式に変換
140
+ Object.entries(PROPS).forEach(([propKey, propConfig], index, array) => {
141
+ const propContent = generatePropScss(propKey, propConfig, TOKENS);
142
+ if (!propContent) return;
143
+ scssContent += propContent;
144
144
 
145
- // 最後の要素でない場合は改行を追加
146
- if (index < array.length - 1) {
147
- scssContent += '\n';
148
- }
149
- });
145
+ // 最後の要素でない場合は改行を追加
146
+ if (index < array.length - 1) {
147
+ scssContent += '\n';
148
+ }
149
+ });
150
150
 
151
- scssContent += '\n);\n';
151
+ scssContent += '\n);\n';
152
152
 
153
- // ファイルに出力
154
- const outputPath = path.join(__dirname, '../src/scss/_prop-config.scss');
155
- await fs.promises.writeFile(outputPath, scssContent, 'utf8');
153
+ // ファイルに出力
154
+ const outputPath = path.join(__dirname, '../src/scss/_prop-config.scss');
155
+ await fs.promises.writeFile(outputPath, scssContent, 'utf8');
156
156
 
157
- console.log(`✅ _prop-config.scssを生成しました: ${outputPath}`);
157
+ console.log(`✅ _prop-config.scssを生成しました: ${outputPath}`);
158
158
  }
package/bin/build-css.js CHANGED
@@ -17,9 +17,9 @@ import cssnano from 'cssnano';
17
17
 
18
18
  // console の色付け
19
19
  const COLOR = {
20
- red: '\u001b[31m',
21
- green: '\u001b[32m',
22
- reset: '\x1b[0m',
20
+ red: '\u001b[31m',
21
+ green: '\u001b[32m',
22
+ reset: '\x1b[0m',
23
23
  };
24
24
 
25
25
  // __dirname(ESM)
@@ -28,63 +28,63 @@ const __dirname = path.dirname(__filename);
28
28
 
29
29
  // scssファイル処理
30
30
  export async function compileSCSS(src, dist) {
31
- let files = [];
32
-
33
- // NOTE: CLI 経由で実行されると cwd がプロジェクト側になるため、
34
- // glob の ignore が相対解決されずに全件ヒットすることがある。
35
- // cwd を明示してパターンを相対指定、absolute で絶対パスを受け取る。
36
- const ignore = ['**/_*.scss'];
37
- files = globSync('**/*.scss', { cwd: src, ignore, absolute: true });
38
-
39
- console.log('▶️ [compileSCSS] files:', files);
40
-
41
- for (const filePath of files) {
42
- // console.log(COLOR.green + 'Start sassRender: ' + COLOR.reset + filePath);
43
-
44
- const fileName = filePath.replace(src + '/', '');
45
- const srcPath = path.resolve(__dirname, src, fileName);
46
- const distPath = path.resolve(__dirname, dist, fileName).replace('.scss', '.css').replace('/index.css', '.css');
47
-
48
- try {
49
- // dart sass コンパイル(同期処理)
50
- const compiledCSS = sass.compile(srcPath, {
51
- style: 'expanded', // 圧縮は cssnano に任せる
52
- });
53
-
54
- // postcss 実行(完了まで await)
55
- const postcssResult = await postcss([autoprefixer, cssnano]).process(compiledCSS.css, { from: undefined });
56
- writeCSS(distPath, postcssResult.css);
57
- } catch (error) {
58
- console.log(COLOR.red + '\n========== ! ERROR ==========' + COLOR.reset);
59
- console.log(error);
60
- console.log(COLOR.red + '========== / ERROR ========== \n' + COLOR.reset);
61
- }
62
- }
31
+ let files = [];
32
+
33
+ // NOTE: CLI 経由で実行されると cwd がプロジェクト側になるため、
34
+ // glob の ignore が相対解決されずに全件ヒットすることがある。
35
+ // cwd を明示してパターンを相対指定、absolute で絶対パスを受け取る。
36
+ const ignore = ['**/_*.scss'];
37
+ files = globSync('**/*.scss', { cwd: src, ignore, absolute: true });
38
+
39
+ console.log('▶️ [compileSCSS] files:', files);
40
+
41
+ for (const filePath of files) {
42
+ // console.log(COLOR.green + 'Start sassRender: ' + COLOR.reset + filePath);
43
+
44
+ const fileName = filePath.replace(src + '/', '');
45
+ const srcPath = path.resolve(__dirname, src, fileName);
46
+ const distPath = path.resolve(__dirname, dist, fileName).replace('.scss', '.css').replace('/index.css', '.css');
47
+
48
+ try {
49
+ // dart sass コンパイル(同期処理)
50
+ const compiledCSS = sass.compile(srcPath, {
51
+ style: 'expanded', // 圧縮は cssnano に任せる
52
+ });
53
+
54
+ // postcss 実行(完了まで await)
55
+ const postcssResult = await postcss([autoprefixer, cssnano]).process(compiledCSS.css, { from: undefined });
56
+ writeCSS(distPath, postcssResult.css);
57
+ } catch (error) {
58
+ console.log(COLOR.red + '\n========== ! ERROR ==========' + COLOR.reset);
59
+ console.log(error);
60
+ console.log(COLOR.red + '========== / ERROR ========== \n' + COLOR.reset);
61
+ }
62
+ }
63
63
  }
64
64
 
65
65
  // 書き出し処理
66
66
  function writeCSS(filePath, css) {
67
- const dir = path.dirname(filePath);
67
+ const dir = path.dirname(filePath);
68
68
 
69
- // ディレクトリがなければ作成
70
- if (!fs.existsSync(dir)) {
71
- console.log('mkdir ' + dir);
72
- fs.mkdirSync(dir, { recursive: true });
73
- }
69
+ // ディレクトリがなければ作成
70
+ if (!fs.existsSync(dir)) {
71
+ console.log('mkdir ' + dir);
72
+ fs.mkdirSync(dir, { recursive: true });
73
+ }
74
74
 
75
- // css書き出し
76
- fs.writeFileSync(filePath, css);
75
+ // css書き出し
76
+ fs.writeFileSync(filePath, css);
77
77
  }
78
78
 
79
79
  // デフォルトエクスポート(他から await 可能)
80
80
  export default async function buildCSS() {
81
- // パス(絶対パスに変換)
82
- let src = path.resolve(__dirname, '../src/scss');
83
- let dist = path.resolve(__dirname, '../dist/css');
84
- await compileSCSS(src, dist);
85
-
86
- // component
87
- // src = path.resolve(__dirname, '../src/components');
88
- // dist = path.resolve(__dirname, '../dist/components');
89
- // await compileSCSS(src, dist);
81
+ // パス(絶対パスに変換)
82
+ let src = path.resolve(__dirname, '../src/scss');
83
+ let dist = path.resolve(__dirname, '../dist/css');
84
+ await compileSCSS(src, dist);
85
+
86
+ // component
87
+ // src = path.resolve(__dirname, '../src/components');
88
+ // dist = path.resolve(__dirname, '../dist/components');
89
+ // await compileSCSS(src, dist);
90
90
  }
package/bin/cli.mjs CHANGED
@@ -24,46 +24,46 @@ const args = process.argv.slice(2);
24
24
  const command = args[0] || '';
25
25
 
26
26
  async function main() {
27
- // 指定がない場合、build-config を実行
28
- if (command === 'build') {
29
- // default-config を常に読み込む(ESM default export を取得)
30
- const defaultConfigModule = await import(pathToFileURL(defaultConfigPath).href);
31
- const defaultConfig = defaultConfigModule?.default || {};
27
+ // 指定がない場合、build-config を実行
28
+ if (command === 'build') {
29
+ // default-config を常に読み込む(ESM default export を取得)
30
+ const defaultConfigModule = await import(pathToFileURL(defaultConfigPath).href);
31
+ const defaultConfig = defaultConfigModule?.default || {};
32
32
 
33
- // user の lism.config.js は存在する時のみ読み込む
34
- let userConfig = {};
35
- if (fs.existsSync(userConfigPath)) {
36
- const userConfigModule = await import(pathToFileURL(userConfigPath).href);
37
- userConfig = userConfigModule?.default || {};
33
+ // user の lism.config.js は存在する時のみ読み込む
34
+ let userConfig = {};
35
+ if (fs.existsSync(userConfigPath)) {
36
+ const userConfigModule = await import(pathToFileURL(userConfigPath).href);
37
+ userConfig = userConfigModule?.default || {};
38
38
 
39
- console.log('===== 📁 userConfig =====');
40
- console.log(userConfig);
41
- console.log('==========');
42
- }
39
+ console.log('===== 📁 userConfig =====');
40
+ console.log(userConfig);
41
+ console.log('==========');
42
+ }
43
43
 
44
- // 設定をディープマージ
45
- const CONFIG = objDeepMerge(defaultConfig, userConfig);
44
+ // 設定をディープマージ
45
+ const CONFIG = objDeepMerge(defaultConfig, userConfig);
46
46
 
47
- // 動的インポートで同ディレクトリのスクリプトを実行
48
- await buildConfig(CONFIG); // SCSSの設定ファイルを出力
49
- await buildCSS();
50
- return;
51
- }
47
+ // 動的インポートで同ディレクトリのスクリプトを実行
48
+ await buildConfig(CONFIG); // SCSSの設定ファイルを出力
49
+ await buildCSS();
50
+ return;
51
+ }
52
52
 
53
- if (!command) {
54
- console.log('Usage: lism-css <command>');
55
- console.log(' <command>:');
56
- console.log(' - build : Build the CSS');
57
- return;
58
- }
53
+ if (!command) {
54
+ console.log('Usage: lism-css <command>');
55
+ console.log(' <command>:');
56
+ console.log(' - build : Build the CSS');
57
+ return;
58
+ }
59
59
 
60
- // 未知のサブコマンドはエラー表示
61
- console.error(`Unknown command: ${command}`);
62
- process.exit(1);
60
+ // 未知のサブコマンドはエラー表示
61
+ console.error(`Unknown command: ${command}`);
62
+ process.exit(1);
63
63
  }
64
64
 
65
65
  main().catch((error) => {
66
- // 例外は標準エラー出力に流して終了コード1で終了
67
- console.error(error);
68
- process.exit(1);
66
+ // 例外は標準エラー出力に流して終了コード1で終了
67
+ console.error(error);
68
+ process.exit(1);
69
69
  });