lism-css 0.3.4 → 0.5.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.
Files changed (253) hide show
  1. package/README.md +2 -2
  2. package/bin/build-config.js +157 -0
  3. package/bin/build-css.cjs +92 -0
  4. package/bin/build-css.js +90 -0
  5. package/bin/cli.mjs +69 -0
  6. package/bin/script-build-css.js +6 -0
  7. package/config/__prop_list.js +44 -0
  8. package/config/__props.scss +25 -0
  9. package/config/default-config.js +9 -0
  10. package/config/defaults/__props-memo.js +45 -0
  11. package/config/defaults/props.js +370 -0
  12. package/config/defaults/states.js +42 -0
  13. package/config/defaults/tokens.js +26 -0
  14. package/config/helper/getSvgUrl.js +28 -0
  15. package/config/helper/minifyHtml.js +22 -0
  16. package/config/helper.js +67 -0
  17. package/config/index.js +15 -0
  18. package/config.js +2 -0
  19. package/dist/components/Accordion/AccIcon.js +1 -1
  20. package/dist/components/Accordion/getProps.js +15 -17
  21. package/dist/components/Accordion/index.js +4 -4
  22. package/dist/components/Accordion/index2.js +28 -23
  23. package/dist/components/Accordion/setAccordion.js +11 -11
  24. package/dist/components/Box/index.js +5 -6
  25. package/dist/components/Center/index.js +2 -2
  26. package/dist/components/Cluster/index.js +8 -0
  27. package/dist/components/Columns/index.js +5 -6
  28. package/dist/components/Container/index.js +3 -3
  29. package/dist/components/Dummy/index.js +9 -14
  30. package/dist/components/Dummy/texts.js +6 -6
  31. package/dist/components/Flex/index.js +5 -6
  32. package/dist/components/Flow/index.js +8 -0
  33. package/dist/components/Frame/index.js +5 -6
  34. package/dist/components/Grid/index.js +5 -6
  35. package/dist/components/HTML/index.js +5 -0
  36. package/dist/components/HTML/index2.js +44 -0
  37. package/dist/components/Layer/index.js +5 -5
  38. package/dist/components/LinkBox/index.js +6 -6
  39. package/dist/components/Lism/Link.js +5 -5
  40. package/dist/components/Lism/Text.js +4 -4
  41. package/dist/components/Lism/index.js +5 -4
  42. package/dist/components/Modal/Body.js +5 -5
  43. package/dist/components/Modal/CloseBtn.js +13 -0
  44. package/dist/components/Modal/Inner.js +5 -5
  45. package/dist/components/Modal/OpenBtn.js +9 -0
  46. package/dist/components/Modal/getProps.js +12 -13
  47. package/dist/components/Modal/index.js +4 -5
  48. package/dist/components/Modal/index2.js +12 -12
  49. package/dist/components/Stack/index.js +5 -5
  50. package/dist/components/Tabs/Tab.js +7 -9
  51. package/dist/components/Tabs/TabList.js +4 -4
  52. package/dist/components/Tabs/TabPanel.js +6 -7
  53. package/dist/components/Tabs/getProps.js +1 -8
  54. package/dist/components/Tabs/index2.js +14 -23
  55. package/dist/components/WithSide/index.js +4 -5
  56. package/dist/components/atomic/Decorator/getProps.js +13 -0
  57. package/dist/components/{Decorator → atomic/Decorator}/index.js +1 -1
  58. package/dist/components/atomic/Divider/getProps.js +10 -0
  59. package/dist/components/atomic/Divider/index.js +9 -0
  60. package/dist/components/atomic/Icon/getProps.js +59 -0
  61. package/dist/components/{Icon → atomic/Icon}/index.js +1 -1
  62. package/dist/components/atomic/Media/getProps.js +9 -0
  63. package/dist/components/atomic/Media/index.js +9 -0
  64. package/dist/components/atomic/Spacer/getProps.js +21 -0
  65. package/dist/components/atomic/Spacer/index.js +9 -0
  66. package/dist/components/getFilterProps.js +8 -18
  67. package/dist/components/getLayoutProps.js +27 -0
  68. package/dist/config/default-config.js +11 -0
  69. package/dist/config/defaults/props.js +342 -0
  70. package/dist/config/defaults/states.js +36 -0
  71. package/dist/config/defaults/tokens.js +29 -0
  72. package/dist/config/helper/getSvgUrl.js +4 -0
  73. package/dist/config/helper.js +31 -0
  74. package/dist/config/index.js +11 -0
  75. package/dist/index.js +50 -50
  76. package/dist/lib/getBpData.js +1 -1
  77. package/dist/lib/getLismProps.js +109 -177
  78. package/dist/lib/getMaybeCssVar.js +30 -54
  79. package/dist/lib/getMaybeTokenValue.js +26 -0
  80. package/dist/lib/getUtilKey.js +13 -0
  81. package/dist/lib/isPresetValue.js +3 -3
  82. package/dist/lib/isTokenValue.js +6 -5
  83. package/package.json +16 -3
  84. package/packages/astro/Accordion/AccBody.astro +5 -6
  85. package/packages/astro/Accordion/AccHeader.astro +4 -4
  86. package/packages/astro/Accordion/AccHeaderLabel.astro +12 -0
  87. package/packages/astro/Accordion/AccIcon.astro +1 -1
  88. package/packages/astro/Accordion/AccLabel.astro +1 -1
  89. package/packages/astro/Accordion/Accordion.astro +1 -1
  90. package/packages/astro/Accordion/index.js +2 -1
  91. package/packages/astro/Box/Box.astro +2 -3
  92. package/packages/astro/Center/Center.astro +2 -8
  93. package/packages/astro/Cluster/Cluster.astro +5 -0
  94. package/packages/astro/Cluster/index.js +1 -0
  95. package/packages/astro/Columns/Columns.astro +2 -8
  96. package/packages/astro/Container/Container.astro +3 -4
  97. package/packages/astro/Decorator/Decorator.astro +2 -2
  98. package/packages/astro/Divider/Divider.astro +3 -3
  99. package/packages/astro/Dummy/Dummy.astro +3 -2
  100. package/packages/astro/Flex/Flex.astro +1 -10
  101. package/packages/astro/Flex/index.js +0 -1
  102. package/packages/astro/Flow/Flow.astro +5 -0
  103. package/packages/astro/Flow/index.js +1 -0
  104. package/packages/astro/Frame/Frame.astro +1 -8
  105. package/packages/astro/Grid/Grid.astro +1 -9
  106. package/packages/astro/Grid/index.js +0 -1
  107. package/packages/astro/HTML/a.astro +5 -0
  108. package/packages/astro/HTML/button.astro +5 -0
  109. package/packages/astro/HTML/div.astro +5 -0
  110. package/packages/astro/HTML/h.astro +6 -0
  111. package/packages/astro/HTML/img.astro +5 -0
  112. package/packages/astro/HTML/index.js +12 -0
  113. package/packages/astro/HTML/li.astro +5 -0
  114. package/packages/astro/HTML/ol.astro +5 -0
  115. package/packages/astro/HTML/p.astro +5 -0
  116. package/packages/astro/HTML/span.astro +5 -0
  117. package/packages/astro/HTML/ul.astro +5 -0
  118. package/packages/astro/Icon/Icon.astro +3 -5
  119. package/packages/astro/Layer/Layer.astro +3 -10
  120. package/packages/astro/LinkBox/LinkBox.astro +4 -5
  121. package/packages/astro/Lism/Link.astro +2 -2
  122. package/packages/astro/Lism/Lism.astro +4 -3
  123. package/packages/astro/Lism/Text.astro +2 -2
  124. package/packages/astro/Lism/index.js +0 -1
  125. package/packages/astro/{Lism → Media}/Media.astro +1 -9
  126. package/packages/astro/Media/index.js +1 -0
  127. package/packages/astro/Modal/Body.astro +4 -5
  128. package/packages/astro/Modal/CloseBtn.astro +24 -0
  129. package/packages/astro/Modal/Inner.astro +4 -4
  130. package/packages/astro/Modal/Modal.astro +4 -5
  131. package/packages/astro/Modal/OpenBtn.astro +14 -0
  132. package/packages/astro/Modal/index.js +3 -4
  133. package/packages/astro/OverlayLink/OverlayLink.astro +1 -1
  134. package/packages/astro/Spacer/Spacer.astro +3 -3
  135. package/packages/astro/Stack/Stack.astro +2 -4
  136. package/packages/astro/Tabs/Tab.astro +2 -11
  137. package/packages/astro/Tabs/TabList.astro +4 -4
  138. package/packages/astro/Tabs/TabPanel.astro +4 -4
  139. package/packages/astro/Tabs/Tabs.astro +6 -10
  140. package/packages/astro/Test/Test.astro +1 -1
  141. package/packages/astro/Test/TestItem.astro +1 -1
  142. package/packages/astro/WithSide/WithSide.astro +1 -8
  143. package/packages/astro/index.js +6 -2
  144. package/packages/types/index.d.ts +31 -38
  145. package/src/scss/{_props.scss → __props copy.scss } +146 -169
  146. package/src/scss/__props.scss +786 -0
  147. package/src/scss/_auto_output.scss +102 -76
  148. package/src/scss/_prop-config.scss +862 -0
  149. package/src/scss/_setting.scss +2 -3
  150. package/src/scss/_with_layer.scss +19 -14
  151. package/src/scss/base/_dom.scss +35 -26
  152. package/src/scss/base/_property.scss +4 -16
  153. package/src/scss/base/_tokens.scss +105 -116
  154. package/src/scss/base/index.scss +18 -42
  155. package/src/scss/base/set/_hover.scss +13 -0
  156. package/src/scss/base/set/_innerRs.scss +3 -0
  157. package/src/scss/base/set/_mask.scss +6 -0
  158. package/src/scss/base/set/_plain.scss +14 -0
  159. package/src/scss/base/set/_shadow.scss +27 -0
  160. package/src/scss/base/set/_snap.scss +8 -0
  161. package/src/scss/base/set/_transition.scss +20 -0
  162. package/src/scss/main.scss +0 -1
  163. package/src/scss/main_no_layer.scss +6 -14
  164. package/src/scss/modules/atomic/_divider.scss +6 -0
  165. package/src/scss/{layout → modules/atomic}/_icon.scss +3 -9
  166. package/src/scss/modules/atomic/_media.scss +3 -0
  167. package/src/scss/{layout → modules/atomic}/_spacer.scss +1 -1
  168. package/src/scss/modules/atomic/index.scss +6 -0
  169. package/src/scss/{dynamic → modules/dynamic}/_accordion.scss +24 -24
  170. package/src/scss/modules/dynamic/_modal.scss +33 -0
  171. package/src/scss/{dynamic → modules/dynamic}/_tabs.scss +4 -5
  172. package/src/scss/{layout/_flex.scss → modules/layout/_cluster.scss} +1 -4
  173. package/src/scss/modules/layout/_columns.scss +9 -0
  174. package/src/scss/modules/layout/_flex.scss +3 -0
  175. package/src/scss/modules/layout/_flow.scss +46 -0
  176. package/src/scss/{layout → modules/layout}/_frame.scss +1 -1
  177. package/src/scss/modules/layout/_grid.scss +35 -0
  178. package/src/scss/{layout → modules/layout}/_withSide.scss +3 -3
  179. package/src/scss/{layout → modules/layout}/index.scss +4 -6
  180. package/src/scss/modules/state/_container.scss +37 -0
  181. package/src/scss/{state → modules/state}/_linkbox.scss +1 -1
  182. package/src/scss/modules/state/index.scss +5 -0
  183. package/src/scss/props/_border.scss +25 -40
  184. package/src/scss/props/_hover.scss +12 -23
  185. package/src/scss/props/_size.scss +17 -0
  186. package/src/scss/props/index.scss +1 -2
  187. package/src/scss/reset.scss +1 -1
  188. package/src/scss/utility/_cbox.scss +5 -4
  189. package/src/scss/utility/_hidden.scss +14 -0
  190. package/src/scss/utility/_itemDivider.scss +11 -0
  191. package/src/scss/utility/_linkExpand.scss +10 -0
  192. package/src/scss/utility/_trimHL.scss +29 -13
  193. package/src/scss/utility/index.scss +3 -45
  194. package/dist/components/Box/getProps.js +0 -7
  195. package/dist/components/Columns/getProps.js +0 -6
  196. package/dist/components/Decorator/getProps.js +0 -17
  197. package/dist/components/Divider/getProps.js +0 -11
  198. package/dist/components/Divider/index.js +0 -9
  199. package/dist/components/Flex/Cluster.js +0 -8
  200. package/dist/components/Flex/FlexItem.js +0 -8
  201. package/dist/components/Flex/getProps.js +0 -13
  202. package/dist/components/Frame/getProps.js +0 -7
  203. package/dist/components/Grid/GridItem.js +0 -9
  204. package/dist/components/Grid/getProps.js +0 -28
  205. package/dist/components/Icon/getProps.js +0 -60
  206. package/dist/components/Layer/getProps.js +0 -9
  207. package/dist/components/Lism/Media.js +0 -9
  208. package/dist/components/Modal/CloseIconBtn.js +0 -19
  209. package/dist/components/Modal/Footer.js +0 -9
  210. package/dist/components/Modal/Header.js +0 -9
  211. package/dist/components/Spacer/getProps.js +0 -21
  212. package/dist/components/Spacer/index.js +0 -9
  213. package/dist/components/WithSide/getProps.js +0 -14
  214. package/dist/components/getInsetProps.js +0 -8
  215. package/dist/components/getMediaProps.js +0 -7
  216. package/dist/components/getTransformProps.js +0 -8
  217. package/dist/config/prop_list.js +0 -386
  218. package/dist/config/tokens.js +0 -43
  219. package/dist/config.js +0 -9
  220. package/dist/css/base.css +0 -1
  221. package/dist/css/dynamic.css +0 -1
  222. package/dist/css/layout.css +0 -1
  223. package/dist/css/main.css +0 -1
  224. package/dist/css/main_no_layer.css +0 -1
  225. package/dist/css/props.css +0 -1
  226. package/dist/css/reset.css +0 -1
  227. package/dist/css/state.css +0 -1
  228. package/dist/css/utility.css +0 -1
  229. package/dist/lib/getMaybeUtilValue.js +0 -6
  230. package/packages/astro/Flex/Cluster.astro +0 -11
  231. package/packages/astro/Grid/GridItem.astro +0 -15
  232. package/packages/astro/Modal/CloseIconBtn.astro +0 -24
  233. package/packages/astro/Modal/Footer.astro +0 -14
  234. package/packages/astro/Modal/Header.astro +0 -14
  235. package/src/scss/dynamic/_modal.scss +0 -30
  236. package/src/scss/layout/_columns.scss +0 -13
  237. package/src/scss/layout/_divider.scss +0 -3
  238. package/src/scss/layout/_grid.scss +0 -9
  239. package/src/scss/props/__memo.scss +0 -15
  240. package/src/scss/props/_color.scss +0 -7
  241. package/src/scss/props/_transition.scss +0 -20
  242. package/src/scss/state/_container.scss +0 -34
  243. package/src/scss/state/_flow.scss +0 -45
  244. package/src/scss/state/_size.scss +0 -22
  245. package/src/scss/state/index.scss +0 -12
  246. /package/dist/components/{Icon → atomic/Icon}/SVG.js +0 -0
  247. /package/dist/components/{Icon → atomic/Icon}/presets.js +0 -0
  248. /package/packages/astro/{helper/index.js → helper.js} +0 -0
  249. /package/src/scss/{dynamic → modules/dynamic}/index.scss +0 -0
  250. /package/src/scss/{layout → modules/layout}/_center.scss +0 -0
  251. /package/src/scss/{layout → modules/layout}/_stack.scss +0 -0
  252. /package/src/scss/{state → modules/state}/_gutter.scss +0 -0
  253. /package/src/scss/{state → modules/state}/_layer.scss +0 -0
package/README.md CHANGED
@@ -33,11 +33,11 @@ For HTML sites, you can also load CSS via CDN.
33
33
  ### 3. Using Components
34
34
 
35
35
  ```jsx
36
- import { Box, Text, ... } from 'lism-css/react';
36
+ import { Box, HTML, ... } from 'lism-css/react';
37
37
 
38
38
  // ...
39
39
  <Box p='20' bgc="base-2">
40
- <Text fz="l">Lorem ipsum text...</Text>
40
+ <HTML.p fz="l">Lorem ipsum text...</HTML.p>
41
41
  </Box>
42
42
  // ...
43
43
  ```
@@ -0,0 +1,157 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import getMaybeTokenValue from '../src/lib/getMaybeTokenValue.js';
5
+
6
+ // ES modules用の__dirname取得
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ /**
11
+ * ユーティリティ値を生成
12
+ * @param {Object} propConfig - プロパティ設定
13
+ * @returns {Object} ユーティリティ値のオブジェクト
14
+ */
15
+ function generateUtilities(propConfig, TOKENS) {
16
+ const { utils = {}, presets = [], token = '', tokenClass = 0 } = propConfig;
17
+ const utilities = {};
18
+
19
+ // tokenをクラス化するのであれば presetsへ追加
20
+ if (token && tokenClass) {
21
+ const tokenValues = TOKENS[token];
22
+ if (tokenValues && Array.isArray(tokenValues)) {
23
+ presets.push(...tokenValues);
24
+ } else if (tokenValues && typeof tokenValues === 'object') {
25
+ presets.push(...(tokenValues.values || []));
26
+ }
27
+ }
28
+
29
+ // presetsが定義されている場合
30
+ if (presets.length > 0) {
31
+ presets.forEach((preset) => {
32
+ utilities[preset] = getMaybeTokenValue(token, preset, TOKENS);
33
+ });
34
+ }
35
+
36
+ // utilsが定義されている場合
37
+ if (utils) {
38
+ Object.entries(utils).forEach(([key, value]) => {
39
+ utilities[key] = value;
40
+ });
41
+ }
42
+
43
+ return utilities;
44
+ }
45
+
46
+ /**
47
+ * プロパティ設定をSCSS形式に変換
48
+ * @param {string} propKey - プロパティに対応する省略型のキー名
49
+ * @param {Object} propConfig - プロパティ設定
50
+ * @returns {string} SCSS形式の文字列
51
+ */
52
+ function generatePropScss(propKey, propConfig, TOKENS) {
53
+ const { prop = '', bp, isVar, alwaysVar, overwriteBaseVar, important } = propConfig;
54
+
55
+ // styleが定義されている場合はそれを使用、なければpropKeyをそのまま使用
56
+ const utilities = generateUtilities(propConfig, TOKENS);
57
+
58
+ // ユーティリティが存在するかどうか
59
+ const hasUtilities = Object.keys(utilities).length > 0;
60
+
61
+ // 出力するCSSがない場合
62
+ if (!hasUtilities && !bp) {
63
+ return '';
64
+ }
65
+
66
+ let scss = `\t'${propKey}': (\n`;
67
+ if (isVar) {
68
+ scss += `\t\tprop: '--${propKey}',\n`;
69
+ } else {
70
+ // propName を prop-name に変換(キャメルケースをケバブケースに変換)
71
+ scss += `\t\tprop: '${prop.replace(/([A-Z])/g, '-$1').toLowerCase()}',\n`;
72
+ }
73
+
74
+ if (hasUtilities) {
75
+ const exs = propConfig.exUtility || null;
76
+
77
+ scss += `\t\tutilities: (\n`;
78
+ Object.entries(utilities).forEach(([utilKey, value]) => {
79
+ // キーに特殊文字が含まれる場合はエスケープ(/,%, : の前に \\ をつける(最終的にscss側の処理で \ ひとつになるようにここでは \\ ))
80
+ const escapedKey = utilKey.replace(/\//g, '\\\\/').replace(/%/g, '\\\\%').replace(/:/g, '\\\\:');
81
+
82
+ // exUtility としても定義されている場合はスキップ
83
+ if (undefined === exs?.[utilKey]) {
84
+ scss += `\t\t\t'${escapedKey}': '${value}',\n`;
85
+ }
86
+ });
87
+ scss += `\t\t),\n`;
88
+
89
+ if (exs) {
90
+ scss += `\t\texUtility: (\n`;
91
+
92
+ for (const [exKey, exProps] of Object.entries(exs)) {
93
+ if (typeof exProps === 'object') {
94
+ scss += `\t\t\t'${exKey}': (\n`;
95
+ for (const _prop in exProps) {
96
+ if (exProps[_prop]) {
97
+ scss += `\t\t\t\t'${_prop}': '${exProps[_prop]}',\n`;
98
+ }
99
+ }
100
+ scss += `\t\t\t),\n`;
101
+ }
102
+ }
103
+ scss += `\t\t),\n`;
104
+ }
105
+ }
106
+
107
+ if (bp !== undefined) {
108
+ scss += `\t\tbp: ${bp},\n`;
109
+ }
110
+ if (isVar !== undefined) {
111
+ scss += `\t\tisVar: ${isVar},\n`;
112
+ }
113
+ if (alwaysVar !== undefined) {
114
+ scss += `\t\talwaysVar: ${alwaysVar},\n`;
115
+ }
116
+ if (overwriteBaseVar !== undefined) {
117
+ scss += `\t\toverwriteBaseVar: ${overwriteBaseVar},\n`;
118
+ }
119
+ if (important !== undefined) {
120
+ scss += `\t\timportant: ${important},\n`;
121
+ }
122
+
123
+ scss += `\t),`;
124
+
125
+ return scss;
126
+ }
127
+
128
+ /**
129
+ * メイン処理
130
+ */
131
+ export default async function buildConfig(CONFIG) {
132
+ const { tokens: TOKENS, props: PROPS } = CONFIG;
133
+ console.log('_prop-config.scssを生成中...');
134
+
135
+ let scssContent = `// 自動生成されたファイル. 生成日時: ${new Date().toISOString()}\n`;
136
+
137
+ scssContent += '$props: (\n';
138
+ // 各プロパティをSCSS形式に変換
139
+ Object.entries(PROPS).forEach(([propKey, propConfig], index, array) => {
140
+ const propContent = generatePropScss(propKey, propConfig, TOKENS);
141
+ if (!propContent) return;
142
+ scssContent += propContent;
143
+
144
+ // 最後の要素でない場合は改行を追加
145
+ if (index < array.length - 1) {
146
+ scssContent += '\n';
147
+ }
148
+ });
149
+
150
+ scssContent += '\n);\n';
151
+
152
+ // ファイルに出力
153
+ const outputPath = path.join(__dirname, '../src/scss/_prop-config.scss');
154
+ await fs.promises.writeFile(outputPath, scssContent, 'utf8');
155
+
156
+ console.log(`✅ _prop-config.scssを生成しました: ${outputPath}`);
157
+ }
@@ -0,0 +1,92 @@
1
+ /* eslint no-console: 0 */
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ // glob
6
+ const glob = require('glob');
7
+
8
+ // node-sass
9
+ // const sass = require('node-sass');
10
+ const sass = require('sass');
11
+ // const globImporter = require('node-sass-glob-importer');
12
+
13
+ // postcss
14
+ const postcss = require('postcss');
15
+ const autoprefixer = require('autoprefixer');
16
+ const cssnano = require('cssnano');
17
+ // const mqpacker = require('css-mqpacker');
18
+
19
+ // consoleの色付け
20
+ const COLOR = {
21
+ red: '\u001b[31m',
22
+ green: '\u001b[32m',
23
+ reset: '\x1b[0m',
24
+ };
25
+
26
+ // 環境変数・引数
27
+ // const envTYPE = process.env.TYPE || '';
28
+ // const TARGET_DIR = process.argv[2] || '';
29
+
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);
41
+ })();
42
+
43
+ // scssファイル処理
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
+ }
78
+ }
79
+
80
+ // 書き出し処理
81
+ function writeCSS(filePath, css) {
82
+ const dir = path.dirname(filePath);
83
+
84
+ // ディレクトリがなければ作成
85
+ if (!fs.existsSync(dir)) {
86
+ console.log('mkdir ' + dir);
87
+ fs.mkdirSync(dir, { recursive: true });
88
+ }
89
+
90
+ // css書き出し
91
+ fs.writeFileSync(filePath, css);
92
+ }
@@ -0,0 +1,90 @@
1
+ /* eslint no-console: 0 */
2
+ import path from 'path';
3
+ import fs from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ // glob(CJS互換モジュールだが、ESM からもデフォルト import で利用可能)
7
+ import { globSync } from 'glob';
8
+
9
+ // dart-sass
10
+ // import legacySass from 'node-sass';
11
+ import * as sass from 'sass';
12
+
13
+ // postcss
14
+ import postcss from 'postcss';
15
+ import autoprefixer from 'autoprefixer';
16
+ import cssnano from 'cssnano';
17
+
18
+ // console の色付け
19
+ const COLOR = {
20
+ red: '\u001b[31m',
21
+ green: '\u001b[32m',
22
+ reset: '\x1b[0m',
23
+ };
24
+
25
+ // __dirname(ESM)
26
+ const __filename = fileURLToPath(import.meta.url);
27
+ const __dirname = path.dirname(__filename);
28
+
29
+ // scssファイル処理
30
+ 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
+ }
63
+ }
64
+
65
+ // 書き出し処理
66
+ function writeCSS(filePath, css) {
67
+ const dir = path.dirname(filePath);
68
+
69
+ // ディレクトリがなければ作成
70
+ if (!fs.existsSync(dir)) {
71
+ console.log('mkdir ' + dir);
72
+ fs.mkdirSync(dir, { recursive: true });
73
+ }
74
+
75
+ // css書き出し
76
+ fs.writeFileSync(filePath, css);
77
+ }
78
+
79
+ // デフォルトエクスポート(他から await 可能)
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);
90
+ }
package/bin/cli.mjs ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath, pathToFileURL } from 'url';
5
+ import buildConfig from './build-config.js';
6
+ import buildCSS from './build-css.js';
7
+ import { objDeepMerge } from '../config/helper.js';
8
+
9
+ // NOTE: build-config.js を実行するための簡易CLIエントリ
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ // プロジェクトルート取得
14
+ const projectRoot = process.cwd();
15
+
16
+ console.log('🤖 projectRoot:', projectRoot);
17
+
18
+ // 設定ファイルのパス
19
+ const defaultConfigPath = path.resolve(__dirname, '../config/default-config.js');
20
+ const userConfigPath = path.resolve(projectRoot, 'lism.config.js');
21
+
22
+ // コマンドライン引数の先頭をサブコマンドとして解釈(デフォルトは build-config)
23
+ const args = process.argv.slice(2);
24
+ const command = args[0] || '';
25
+
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 || {};
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 || {};
38
+
39
+ console.log('===== 📁 userConfig =====');
40
+ console.log(userConfig);
41
+ console.log('==========');
42
+ }
43
+
44
+ // 設定をディープマージ
45
+ const CONFIG = objDeepMerge(defaultConfig, userConfig);
46
+
47
+ // 動的インポートで同ディレクトリのスクリプトを実行
48
+ await buildConfig(CONFIG); // SCSSの設定ファイルを出力
49
+ await buildCSS();
50
+ return;
51
+ }
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
+ }
59
+
60
+ // 未知のサブコマンドはエラー表示
61
+ console.error(`Unknown command: ${command}`);
62
+ process.exit(1);
63
+ }
64
+
65
+ main().catch((error) => {
66
+ // 例外は標準エラー出力に流して終了コード1で終了
67
+ console.error(error);
68
+ process.exit(1);
69
+ });
@@ -0,0 +1,6 @@
1
+ import buildCSS from './build-css.js';
2
+ import buildConfig from './build-config.js';
3
+ import { CONFIG } from '../config/index.js';
4
+
5
+ await buildConfig(CONFIG);
6
+ await buildCSS();
@@ -0,0 +1,44 @@
1
+ const PROPS = {
2
+ // size
3
+ // mask
4
+ // mski: { style: 'maskImage' },
5
+ // mskbd: { style: 'maskBorder' },
6
+ // msktyp: { style: 'maskType' },
7
+ // mskclp: { style: 'maskClip' },
8
+ // mskcmp: { style: 'maskComposite' },
9
+ // mskmd: { style: 'maskMode' },
10
+ // msko: { style: 'maskOrigin' },
11
+ // mskp: { style: 'maskPosition' },
12
+ // mskr: { style: 'maskRepeat' },
13
+ // msksz: { style: 'maskSize' },
14
+ // bdtlrs: { style: 'borderTopLeftRadius', token: 'bdrs' },
15
+ // bdtrrs: { style: 'borderTopRightRadius', token: 'bdrs' },
16
+ // bdblrs: { style: 'borderBottomLeftRadius', token: 'bdrs' },
17
+ // bdbrrs: { style: 'borderBottomRightRadius', token: 'bdrs' },
18
+ // bdssrs: { style: 'borderStartStartRadius', token: 'bdrs' },
19
+ // bdsers: { style: 'borderStartEndRadius', token: 'bdrs' },
20
+ // bdesrs: { style: 'borderEndStartRadius', token: 'bdrs' },
21
+ // bdeers: { style: 'borderEndEndRadius', token: 'bdrs' },
22
+ // transition
23
+ //display
24
+ // iis: { style: 'insetInlineStart', token: 'space' },
25
+ // iie: { style: 'insetInlineEnd', token: 'space' },
26
+ // ibs: { style: 'insetBlockStart', token: 'space' },
27
+ // ibe: { style: 'insetBlockEnd', token: 'space' },
28
+ // isolation
29
+ // flip: {},
30
+ // Spacing
31
+ // grid
32
+ // transform系
33
+ // trf: { style: 'transform' },
34
+ // trfo: { style: 'transformOrigin' },
35
+ // float
36
+ // fl: { style: 'float', utils: { left: 'l', right: 'r' } },
37
+ // cl: { style: 'clear', utils: { left: 'l', right: 'r', both: 'b' } },
38
+ // object-fit
39
+ // objf: { style: 'objectFit', utils: { cover: 'cv', contain: 'cn' } },
40
+ // objp: { style: 'objectPosition' },
41
+ // filter
42
+ // fltr: { style: 'filter' }, // fltr?
43
+ // bdfltr: { style: 'backdropFilter' }, // bdfltr?
44
+ };
@@ -0,0 +1,25 @@
1
+ @use 'sass:map';
2
+ @use 'sass:string';
3
+
4
+ $props: (
5
+ // 'objf': (
6
+ // prop: 'object-fit',
7
+ // utilities: (
8
+ // 'cn': 'contain',
9
+ // 'cv': 'cover',
10
+ // ),
11
+ // ),
12
+ // 'bxsz': (
13
+ // prop: 'box-sizing',
14
+ // utilities: (
15
+ // 'cb': 'content-box',
16
+ // 'bb': 'border-box',
17
+ // ),
18
+ // ),
19
+ // 'iso': (
20
+ // prop: 'isolation',
21
+ // utilities: (
22
+ // 'i': 'isolate',
23
+ // ),
24
+ // ),
25
+ );
@@ -0,0 +1,9 @@
1
+ import TOKENS from './defaults/tokens.js';
2
+ import PROPS from './defaults/props.js';
3
+ import STATES from './defaults/states.js';
4
+
5
+ export default {
6
+ tokens: TOKENS,
7
+ props: PROPS,
8
+ states: STATES,
9
+ };
@@ -0,0 +1,45 @@
1
+ /**
2
+ --size- → --szー
3
+ トークンはハイフン二つ
4
+
5
+ globalトークン、 --target-- → --target- かな
6
+ → --(\w)+?-- で検索。
7
+
8
+
9
+ ・flow, container → l--、 frame→is--では?
10
+ ・普通のクラス設計、BEMにもどす
11
+
12
+ */
13
+
14
+ // tier 1 layout・フォントは超短縮系に省略. 覚えてもらう必要があるもの。
15
+ // p m g flex grid ai ac ji jc lh lts
16
+
17
+ // 方向指定、一文字のもの(p,m,g) はそのまま繋げる。 start/endのみハイフン。
18
+ // 2文字以上のものは、すべてハイフンで繋ぐ
19
+
20
+ // tier 2 わかる程度に省略/名称変換
21
+ // ovwrap wbreak
22
+
23
+ // tier 3 非省略
24
+ // whitespace translate rotate scale order
25
+ // -whitespace:nowrap (-whspace?)
26
+
27
+ // wrap-anywhere と break-keep, break-all,
28
+ // -ovwrap:anywhere, -wordbreak:keep -wordbreak:all
29
+
30
+ // 値のキーワード単体で容易に対応するプロパティが想像できるものは、ユーティリティクラスで {-prop} 部分が省略可能とします。
31
+ // .underline .italic .uppercase, .-lowercase, .emphasis
32
+ // .relative .absolute .fixed, ...
33
+ // .block flex block in-block in-flex, ...
34
+
35
+ // -txd:none
36
+
37
+ // -d:none
38
+ // -v:visible, -v:hidden isolate
39
+
40
+ // prop省略系?→utility
41
+ // .u--colorBox .u--trimLeading u--srOnly
42
+
43
+ // .underline
44
+ // --under-offset, --under-c, --under-thickness
45
+ //