lism-css 0.9.3 → 0.10.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 +5 -5
- package/bin/__build-css.cjs +54 -54
- package/bin/build-config.js +120 -120
- package/bin/build-css.js +52 -52
- package/bin/cli.mjs +33 -33
- package/config/__prop_list.js +42 -42
- package/config/__props.scss +20 -20
- package/config/default-config.ts +3 -3
- package/config/defaults/props.ts +326 -326
- package/config/defaults/states.ts +38 -38
- package/config/defaults/tokens.ts +25 -25
- package/config/helper/getSvgUrl.ts +16 -16
- package/config/helper/minifyHtml.ts +11 -11
- package/config/helper.test.ts +231 -231
- package/config/helper.ts +43 -49
- package/config/index.ts +4 -4
- package/config/tsconfig.json +16 -16
- package/dist/components/Box/Box.stories.d.ts +7 -0
- package/dist/components/Center/Center.stories.d.ts +8 -0
- package/dist/components/Cluster/Cluster.stories.d.ts +7 -0
- package/dist/components/Columns/Columns.stories.d.ts +8 -0
- package/dist/components/Container/Container.stories.d.ts +8 -0
- package/dist/components/Dummy/Dummy.d.ts +6 -9
- package/dist/components/Dummy/index.js +5 -10
- package/dist/components/Flex/Flex.stories.d.ts +9 -0
- package/dist/components/Flow/Flow.stories.d.ts +9 -0
- package/dist/components/FluidCols/FluidCols.stories.d.ts +7 -0
- package/dist/components/Frame/Frame.stories.d.ts +7 -0
- package/dist/components/Grid/Grid.stories.d.ts +8 -0
- package/dist/components/Group/Group.d.ts +3 -0
- package/dist/components/Group/index.d.ts +1 -0
- package/dist/components/Group/index.js +8 -0
- package/dist/components/HTML/HTML.d.ts +10 -0
- package/dist/components/Heading/Heading.d.ts +7 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/Heading/index.js +9 -0
- package/dist/components/Inline/Inline.d.ts +3 -0
- package/dist/components/Inline/index.d.ts +1 -0
- package/dist/components/Inline/index.js +8 -0
- package/dist/components/Layer/Layer.d.ts +1 -2
- package/dist/components/Layer/Layer.stories.d.ts +8 -0
- package/dist/components/Layer/index.js +3 -4
- package/dist/components/Link/Link.d.ts +2 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/Link/index.js +8 -0
- package/dist/components/LinkBox/LinkBox.d.ts +3 -2
- package/dist/components/LinkBox/LinkBox.stories.d.ts +7 -0
- package/dist/components/LinkBox/index.js +5 -5
- package/dist/components/Lism/Lism.d.ts +10 -8
- package/dist/components/Lism/Lism.stories.d.ts +1 -650
- package/dist/components/List/List.d.ts +3 -0
- package/dist/components/List/ListItem.d.ts +3 -0
- package/dist/components/List/ListItem.js +8 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/List/index.js +8 -0
- package/dist/components/SideMain/SideMain.stories.d.ts +9 -0
- package/dist/components/Stack/Stack.stories.d.ts +8 -0
- package/dist/components/SwitchCols/SwitchCols.stories.d.ts +9 -0
- package/dist/components/Text/Text.d.ts +3 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/Text/index.js +8 -0
- package/dist/components/Wrapper/Wrapper.stories.d.ts +10 -0
- package/dist/components/atomic/Decorator/Decorator.stories.d.ts +10 -0
- package/dist/components/atomic/Decorator/getProps.d.ts +5 -8
- package/dist/components/atomic/Decorator/getProps.js +10 -10
- package/dist/components/atomic/Divider/Divider.stories.d.ts +8 -0
- package/dist/components/atomic/Divider/getProps.d.ts +2 -2
- package/dist/components/atomic/Icon/Icon.d.ts +6 -2
- package/dist/components/atomic/Icon/Icon.stories.d.ts +15 -0
- package/dist/components/atomic/Icon/getProps.d.ts +11 -8
- package/dist/components/atomic/Icon/getProps.js +35 -34
- package/dist/components/atomic/Icon/index.d.ts +1 -0
- package/dist/components/atomic/Media/Media.d.ts +3 -2
- package/dist/components/atomic/Media/Media.stories.d.ts +8 -0
- package/dist/components/atomic/Media/index.js +4 -5
- package/dist/components/atomic/Spacer/Spacer.stories.d.ts +9 -0
- package/dist/components/atomic/Spacer/getProps.d.ts +2 -2
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +50 -36
- package/dist/config/helper.d.ts +1 -1
- package/dist/css/base.css +1 -1
- package/dist/css/main.css +1 -1
- package/dist/css/main_no_layer.css +1 -1
- package/dist/css/modules/atomic.css +1 -1
- package/dist/css/modules/layout.css +1 -1
- package/dist/lib/getLayoutProps.d.ts +4 -3
- package/dist/lib/getLismProps.d.ts +13 -11
- package/dist/lib/getLismProps.js +69 -73
- package/dist/lib/getMaybeCssVar.js +15 -10
- package/dist/lib/getMaybeTokenValue.d.ts +2 -2
- package/dist/lib/types/LayoutProps.d.ts +26 -26
- package/dist/lib/types.d.ts +2 -2
- package/package.json +17 -10
- package/packages/astro/Box/Box.astro +6 -5
- package/packages/astro/Center/Center.astro +7 -1
- package/packages/astro/Cluster/Cluster.astro +7 -1
- package/packages/astro/Columns/Columns.astro +7 -1
- package/packages/astro/Container/Container.astro +7 -3
- package/packages/astro/Decorator/Decorator.astro +10 -8
- package/packages/astro/Divider/Divider.astro +6 -6
- package/packages/astro/Dummy/Dummy.astro +9 -8
- package/packages/astro/Flex/Flex.astro +7 -1
- package/packages/astro/Flow/Flow.astro +8 -1
- package/packages/astro/FluidCols/FluidCols.astro +8 -1
- package/packages/astro/Frame/Frame.astro +7 -1
- package/packages/astro/Grid/Grid.astro +7 -1
- package/packages/astro/Group/Group.astro +11 -0
- package/packages/astro/Group/index.ts +1 -0
- package/packages/astro/HTML/_index_memo.js +7 -7
- package/packages/astro/HTML/a.astro +6 -1
- package/packages/astro/HTML/button.astro +6 -1
- package/packages/astro/HTML/div.astro +6 -1
- package/packages/astro/HTML/h.astro +7 -0
- package/packages/astro/HTML/img.astro +6 -1
- package/packages/astro/HTML/li.astro +6 -1
- package/packages/astro/HTML/ol.astro +6 -1
- package/packages/astro/HTML/p.astro +6 -1
- package/packages/astro/HTML/span.astro +6 -1
- package/packages/astro/HTML/ul.astro +6 -1
- package/packages/astro/Heading/Heading.astro +13 -0
- package/packages/astro/Heading/index.ts +1 -0
- package/packages/astro/Icon/Icon.astro +15 -17
- package/packages/astro/Icon/SVG.astro +16 -16
- package/packages/astro/Inline/Inline.astro +11 -0
- package/packages/astro/Inline/index.ts +1 -0
- package/packages/astro/Layer/Layer.astro +7 -4
- package/packages/astro/Link/Link.astro +10 -0
- package/packages/astro/Link/index.ts +1 -0
- package/packages/astro/LinkBox/LinkBox.astro +9 -8
- package/packages/astro/Lism/Lism.astro +6 -9
- package/packages/astro/List/List.astro +11 -0
- package/packages/astro/List/ListItem.astro +11 -0
- package/packages/astro/List/index.ts +2 -0
- package/packages/astro/Media/Media.astro +9 -8
- package/packages/astro/SideMain/SideMain.astro +8 -1
- package/packages/astro/Spacer/Spacer.astro +7 -6
- package/packages/astro/Stack/Stack.astro +7 -1
- package/packages/astro/SwitchCols/SwitchCols.astro +8 -1
- package/packages/astro/Text/Text.astro +11 -0
- package/packages/astro/Text/index.ts +1 -0
- package/packages/astro/Wrapper/Wrapper.astro +9 -1
- package/packages/astro/env.d.ts +10 -0
- package/packages/astro/{index.js → index.ts} +9 -0
- package/packages/astro/tsconfig.json +12 -0
- package/packages/astro/types.ts +19 -0
- package/src/scss/__memo/_lh-auto-all.scss +12 -12
- package/src/scss/__memo/_lh-auto-h.scss +17 -17
- package/src/scss/__memo/_lh-manual.scss +27 -27
- package/src/scss/_auto_output.scss +174 -174
- package/src/scss/_mixin.scss +32 -32
- package/src/scss/_prop-config.scss +850 -850
- package/src/scss/_query.scss +26 -26
- package/src/scss/_setting.scss +6 -6
- package/src/scss/_with_layer.scss +13 -13
- package/src/scss/base/_html.scss +47 -47
- package/src/scss/base/set/_bp.scss +8 -8
- package/src/scss/base/set/_cqUnit.scss +22 -22
- package/src/scss/base/set/_gutter.scss +1 -1
- package/src/scss/base/set/_hov.scss +10 -10
- package/src/scss/base/set/_innerRs.scss +1 -1
- package/src/scss/base/set/_plain.scss +15 -15
- package/src/scss/base/set/_transition.scss +2 -2
- package/src/scss/base/tokens/_property.scss +3 -3
- package/src/scss/base/tokens/_shadow.scss +12 -11
- package/src/scss/base/tokens/_tokens.scss +77 -77
- package/src/scss/base/tokens/_typography.scss +69 -69
- package/src/scss/main_no_layer.scss +1 -1
- package/src/scss/modules/atomic/_divider.scss +4 -4
- package/src/scss/modules/atomic/_icon.scss +4 -4
- package/src/scss/modules/atomic/_spacer.scss +2 -2
- package/src/scss/modules/atomic/index.scss +0 -1
- package/src/scss/modules/layout/_center.scss +3 -3
- package/src/scss/modules/layout/_cluster.scss +3 -3
- package/src/scss/modules/layout/_columns.scss +3 -3
- package/src/scss/modules/layout/_flex.scss +4 -4
- package/src/scss/modules/layout/_flow.scss +16 -16
- package/src/scss/modules/layout/_fluidCols.scss +4 -4
- package/src/scss/modules/layout/_frame.scss +8 -8
- package/src/scss/modules/layout/_grid.scss +9 -9
- package/src/scss/modules/layout/_sideMain.scss +12 -12
- package/src/scss/modules/layout/_stack.scss +2 -2
- package/src/scss/modules/layout/_switchCols.scss +5 -5
- package/src/scss/modules/state/_container.scss +4 -4
- package/src/scss/modules/state/_layer.scss +3 -3
- package/src/scss/modules/state/_linkbox.scss +9 -9
- package/src/scss/modules/state/_vertical.scss +3 -3
- package/src/scss/modules/state/_wrapper.scss +8 -8
- package/src/scss/props/_border.scss +18 -18
- package/src/scss/props/_hover.scss +26 -26
- package/src/scss/props/_lh.scss +6 -6
- package/src/scss/props/_size.scss +7 -7
- package/src/scss/reset.scss +137 -137
- package/src/scss/utility/_cbox.scss +10 -10
- package/src/scss/utility/_clipText.scss +2 -2
- package/src/scss/utility/_hidden.scss +9 -9
- package/src/scss/utility/_itemDivider.scss +7 -7
- package/src/scss/utility/_linkExpand.scss +9 -9
- package/src/scss/utility/_snap.scss +5 -5
- package/src/scss/utility/_trimHL.scss +11 -11
- package/dist/components/Dummy/getContent.d.ts +0 -13
- package/dist/components/Dummy/getContent.js +0 -10
- package/dist/components/Dummy/texts.d.ts +0 -22
- package/dist/components/Dummy/texts.js +0 -39
- package/dist/components/Layer/getProps.d.ts +0 -5
- package/dist/components/atomic/Media/getProps.d.ts +0 -9
- package/dist/components/atomic/Media/getProps.js +0 -8
- package/dist/components/getFilterProps.d.ts +0 -10
- package/dist/components/getFilterProps.js +0 -23
- package/dist/components/getFilterProps.test.d.ts +0 -1
- package/dist/components/setMaybeTransformStyles.d.ts +0 -12
- package/dist/components/setMaybeTransformStyles.js +0 -7
- package/dist/components/setMaybeTransformStyles.test.d.ts +0 -1
- package/packages/astro/OverlayLink/OverlayLink.astro +0 -10
- package/packages/astro/OverlayLink/index.js +0 -1
- package/packages/astro/helper.js +0 -6
- package/src/scss/modules/atomic/_media.scss +0 -3
- /package/packages/astro/Box/{index.js → index.ts} +0 -0
- /package/packages/astro/Center/{index.js → index.ts} +0 -0
- /package/packages/astro/Cluster/{index.js → index.ts} +0 -0
- /package/packages/astro/Columns/{index.js → index.ts} +0 -0
- /package/packages/astro/Container/{index.js → index.ts} +0 -0
- /package/packages/astro/Decorator/{index.js → index.ts} +0 -0
- /package/packages/astro/Divider/{index.js → index.ts} +0 -0
- /package/packages/astro/Dummy/{index.js → index.ts} +0 -0
- /package/packages/astro/Flex/{index.js → index.ts} +0 -0
- /package/packages/astro/Flow/{index.js → index.ts} +0 -0
- /package/packages/astro/FluidCols/{index.js → index.ts} +0 -0
- /package/packages/astro/Frame/{index.js → index.ts} +0 -0
- /package/packages/astro/Grid/{index.js → index.ts} +0 -0
- /package/packages/astro/HTML/{index.js → index.ts} +0 -0
- /package/packages/astro/Icon/{index.js → index.ts} +0 -0
- /package/packages/astro/Layer/{index.js → index.ts} +0 -0
- /package/packages/astro/LinkBox/{index.js → index.ts} +0 -0
- /package/packages/astro/Lism/{index.js → index.ts} +0 -0
- /package/packages/astro/Media/{index.js → index.ts} +0 -0
- /package/packages/astro/SideMain/{index.js → index.ts} +0 -0
- /package/packages/astro/Spacer/{index.js → index.ts} +0 -0
- /package/packages/astro/Stack/{index.js → index.ts} +0 -0
- /package/packages/astro/SwitchCols/{index.js → index.ts} +0 -0
- /package/packages/astro/Wrapper/{index.js → index.ts} +0 -0
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,
|
|
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
|
-
<
|
|
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,
|
|
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
|
-
<
|
|
59
|
+
<Text fz="l">Lorem ipsum text...</Text>
|
|
60
60
|
</Box>
|
|
61
61
|
</Stack>
|
|
62
62
|
```
|
package/bin/__build-css.cjs
CHANGED
|
@@ -18,9 +18,9 @@ const cssnano = require('cssnano');
|
|
|
18
18
|
|
|
19
19
|
// consoleの色付け
|
|
20
20
|
const COLOR = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
82
|
+
const dir = path.dirname(filePath);
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
// ディレクトリがなければ作成
|
|
85
|
+
if (!fs.existsSync(dir)) {
|
|
86
|
+
console.log('mkdir ' + dir);
|
|
87
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
88
|
+
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// css書き出し
|
|
91
|
+
fs.writeFileSync(filePath, css);
|
|
92
92
|
}
|
package/bin/build-config.js
CHANGED
|
@@ -14,34 +14,34 @@ const __dirname = path.dirname(__filename);
|
|
|
14
14
|
* @returns {Object} ユーティリティ値のオブジェクト
|
|
15
15
|
*/
|
|
16
16
|
function generateUtilities(propConfig, TOKENS) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
134
|
-
|
|
133
|
+
const { tokens: TOKENS, props: PROPS } = CONFIG;
|
|
134
|
+
console.log('_prop-config.scssを生成中...');
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
let scssContent = '';
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
// 最後の要素でない場合は改行を追加
|
|
146
|
+
if (index < array.length - 1) {
|
|
147
|
+
scssContent += '\n';
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
scssContent += '\n);\n';
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
// ファイルに出力
|
|
154
|
+
const outputPath = path.join(__dirname, '../src/scss/_prop-config.scss');
|
|
155
|
+
await fs.promises.writeFile(outputPath, scssContent, 'utf8');
|
|
156
156
|
|
|
157
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
67
|
+
const dir = path.dirname(filePath);
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
// ディレクトリがなければ作成
|
|
70
|
+
if (!fs.existsSync(dir)) {
|
|
71
|
+
console.log('mkdir ' + dir);
|
|
72
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
73
|
+
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// css書き出し
|
|
76
|
+
fs.writeFileSync(filePath, css);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// デフォルトエクスポート(他から await 可能)
|
|
80
80
|
export default async function buildCSS() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
console.log('===== 📁 userConfig =====');
|
|
40
|
+
console.log(userConfig);
|
|
41
|
+
console.log('==========');
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// 設定をディープマージ
|
|
45
|
+
const CONFIG = objDeepMerge(defaultConfig, userConfig);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
// 動的インポートで同ディレクトリのスクリプトを実行
|
|
48
|
+
await buildConfig(CONFIG); // SCSSの設定ファイルを出力
|
|
49
|
+
await buildCSS();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
62
|
-
|
|
60
|
+
// 未知のサブコマンドはエラー表示
|
|
61
|
+
console.error(`Unknown command: ${command}`);
|
|
62
|
+
process.exit(1);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
main().catch((error) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// 例外は標準エラー出力に流して終了コード1で終了
|
|
67
|
+
console.error(error);
|
|
68
|
+
process.exit(1);
|
|
69
69
|
});
|