lism-css 0.22.2 → 0.23.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 (66) hide show
  1. package/dist/config/default-config.d.ts +137 -49
  2. package/dist/config/default-config.js +8 -6
  3. package/dist/config/defaults/breakpoints.d.ts +15 -0
  4. package/dist/config/defaults/breakpoints.js +10 -0
  5. package/dist/config/defaults/props.d.ts +21 -30
  6. package/dist/config/defaults/props.js +33 -29
  7. package/dist/config/defaults/token-scope.d.ts +9 -0
  8. package/dist/config/defaults/token-scope.js +7 -0
  9. package/dist/config/defaults/token-var-prefix.d.ts +11 -0
  10. package/dist/config/defaults/token-var-prefix.js +11 -0
  11. package/dist/config/defaults/tokens.d.ts +118 -21
  12. package/dist/config/defaults/tokens.js +112 -24
  13. package/dist/config/index.d.ts +285 -105
  14. package/dist/config/index.js +18 -15
  15. package/dist/config/presets/props-full.d.ts +20 -0
  16. package/dist/config/presets/props-full.js +28 -0
  17. package/dist/css/base/set.css +1 -1
  18. package/dist/css/base.css +1 -1
  19. package/dist/css/full.css +1 -0
  20. package/dist/css/full_no_layer.css +1 -0
  21. package/dist/css/main.css +1 -1
  22. package/dist/css/main_no_layer.css +1 -1
  23. package/dist/css/props.css +1 -1
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.js +1 -0
  26. package/dist/lib/getBpData.d.ts +2 -2
  27. package/dist/lib/getBpData.js +7 -7
  28. package/dist/lib/getLismProps.d.ts +5 -3
  29. package/dist/lib/getLismProps.js +59 -54
  30. package/dist/lib/getMaybeTokenValue.d.ts +1 -7
  31. package/dist/lib/getMaybeTokenValue.js +10 -22
  32. package/dist/lib/getTokenVarName.d.ts +13 -0
  33. package/dist/lib/getTokenVarName.js +8 -0
  34. package/dist/lib/getTokenVarName.test.d.ts +1 -0
  35. package/dist/lib/isTokenValue.js +11 -22
  36. package/dist/lib/types/CustomPropRegistry.d.ts +9 -0
  37. package/dist/lib/types/CustomTraitRegistry.d.ts +9 -0
  38. package/dist/lib/types/FullModeRegistry.d.ts +26 -0
  39. package/dist/lib/types/PropValueTypes.d.ts +45 -13
  40. package/dist/lib/types/ResponsiveProps.d.ts +57 -13
  41. package/dist/lib/types/ResponsiveProps.module-augmentation.test.d.ts +1 -0
  42. package/dist/lib/warnUnsupportedBp.js +1 -1
  43. package/dist/scss/auto_output.test.d.ts +1 -0
  44. package/package.json +23 -33
  45. package/src/scss/_auto_output.scss +54 -42
  46. package/src/scss/_prop-config-full.gen.scss +1317 -0
  47. package/src/scss/{_prop-config.scss → _prop-config.gen.scss} +37 -13
  48. package/src/scss/_setting.scss +6 -11
  49. package/src/scss/auto_output.test.ts +91 -0
  50. package/src/scss/base/index.scss +1 -3
  51. package/src/scss/base/set/index.scss +5 -0
  52. package/src/scss/base/tokens/_tokens.gen.scss +69 -0
  53. package/src/scss/base/tokens/_tokens.scss +31 -30
  54. package/src/scss/full.scss +12 -0
  55. package/src/scss/full_no_layer.scss +32 -0
  56. package/src/scss/props/index.scss +0 -1
  57. package/src/scss/trait/is/_wrapper.scss +1 -1
  58. package/bin/__build-css.cjs +0 -92
  59. package/bin/build-config.js +0 -155
  60. package/bin/build-css.js +0 -90
  61. package/bin/cli.mjs +0 -79
  62. package/bin/script-build-css.js +0 -6
  63. package/src/scss/base/tokens/_shadow.scss +0 -23
  64. package/src/scss/base/tokens/_space.scss +0 -30
  65. package/src/scss/base/tokens/_typography.scss +0 -69
  66. package/src/scss/props/_lh.scss +0 -16
@@ -1,155 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
- // CLI実行時にsrcからとると見つかれないので dist からとる
5
- import getMaybeTokenValue from '../dist/lib/getMaybeTokenValue.js';
6
-
7
- // ES modules用の__dirname取得
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- /**
12
- * ユーティリティ値を生成
13
- * @param {Object} propConfig - プロパティ設定
14
- * @returns {Object} ユーティリティ値のオブジェクト
15
- */
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;
45
- }
46
-
47
- /**
48
- * プロパティ設定をSCSS形式に変換
49
- * @param {string} propKey - プロパティに対応する省略型のキー名
50
- * @param {Object} propConfig - プロパティ設定
51
- * @returns {string} SCSS形式の文字列
52
- */
53
- function generatePropScss(propKey, propConfig, TOKENS) {
54
- const { prop = '', bp, isVar, alwaysVar, 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 (important !== undefined) {
118
- scss += ` important: ${important},\n`;
119
- }
120
-
121
- scss += ` ),`;
122
-
123
- return scss;
124
- }
125
-
126
- /**
127
- * メイン処理
128
- */
129
- export default async function buildConfig(CONFIG) {
130
- const { tokens: TOKENS, props: PROPS } = CONFIG;
131
- console.log('_prop-config.scssを生成中...');
132
-
133
- let scssContent = '';
134
-
135
- scssContent += '$props: (\n';
136
- // 各プロパティをSCSS形式に変換
137
- Object.entries(PROPS).forEach(([propKey, propConfig], index, array) => {
138
- const propContent = generatePropScss(propKey, propConfig, TOKENS);
139
- if (!propContent) return;
140
- scssContent += propContent;
141
-
142
- // 最後の要素でない場合は改行を追加
143
- if (index < array.length - 1) {
144
- scssContent += '\n';
145
- }
146
- });
147
-
148
- scssContent += '\n);\n';
149
-
150
- // ファイルに出力
151
- const outputPath = path.join(__dirname, '../src/scss/_prop-config.scss');
152
- await fs.promises.writeFile(outputPath, scssContent, 'utf8');
153
-
154
- console.log(`✅ _prop-config.scssを生成しました: ${outputPath}`);
155
- }
package/bin/build-css.js DELETED
@@ -1,90 +0,0 @@
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
- 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
- }
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 DELETED
@@ -1,79 +0,0 @@
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 '../dist/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, '../dist/config/default-config.js');
20
-
21
- // ユーザー設定ファイルを検索(優先順: .js → .mjs)
22
- const CONFIG_SEARCH = ['lism.config.js', 'lism.config.mjs'];
23
- function findUserConfigPath() {
24
- for (const name of CONFIG_SEARCH) {
25
- const abs = path.resolve(projectRoot, name);
26
- if (fs.existsSync(abs)) return abs;
27
- }
28
- return null;
29
- }
30
- const userConfigPath = findUserConfigPath();
31
-
32
- // コマンドライン引数の先頭をサブコマンドとして解釈(デフォルトは build-config)
33
- const args = process.argv.slice(2);
34
- const command = args[0] || '';
35
-
36
- async function main() {
37
- // 指定がない場合、build-config を実行
38
- if (command === 'build') {
39
- // default-config を常に読み込む(ESM default export を取得)
40
- const defaultConfigModule = await import(pathToFileURL(defaultConfigPath).href);
41
- const defaultConfig = defaultConfigModule?.default || {};
42
-
43
- // user の lism.config.{js,mjs} は存在する時のみ読み込む
44
- let userConfig = {};
45
- if (userConfigPath) {
46
- const userConfigModule = await import(pathToFileURL(userConfigPath).href);
47
- userConfig = userConfigModule?.default || {};
48
-
49
- console.log('===== 📁 userConfig =====');
50
- console.log(userConfig);
51
- console.log('==========');
52
- }
53
-
54
- // 設定をディープマージ
55
- const CONFIG = objDeepMerge(defaultConfig, userConfig);
56
-
57
- // 動的インポートで同ディレクトリのスクリプトを実行
58
- await buildConfig(CONFIG); // SCSSの設定ファイルを出力
59
- await buildCSS();
60
- return;
61
- }
62
-
63
- if (!command) {
64
- console.log('Usage: lism-css <command>');
65
- console.log(' <command>:');
66
- console.log(' - build : Build the CSS');
67
- return;
68
- }
69
-
70
- // 未知のサブコマンドはエラー表示
71
- console.error(`Unknown command: ${command}`);
72
- process.exit(1);
73
- }
74
-
75
- main().catch((error) => {
76
- // 例外は標準エラー出力に流して終了コード1で終了
77
- console.error(error);
78
- process.exit(1);
79
- });
@@ -1,6 +0,0 @@
1
- import buildCSS from './build-css.js';
2
- import buildConfig from './build-config.js';
3
- import { CONFIG } from '../config/index.ts';
4
-
5
- await buildConfig(CONFIG);
6
- await buildCSS();
@@ -1,23 +0,0 @@
1
- /* --------------------------------------------------
2
- shadow
3
- Memo: :root だけで --bxsh-- をセットしてしまうと --shc がその時点で固定されるので、
4
- 要素ごとに --shc を上書きできるよう、再セット用の set--bxsh クラスを併用する。
5
- -------------------------------------------------- */
6
- :root {
7
- --shc: var(--shadow);
8
-
9
- --shsz--10: 0px 1px 3px;
10
- --shsz--20: 0px 2px 6px;
11
- --shsz--30: 0px 4px 12px;
12
- --shsz--40: 0px 8px 24px;
13
- --shsz--50: 0px 16px 48px;
14
- }
15
-
16
- :root,
17
- .set--bxsh {
18
- --bxsh--10: var(--shsz--10) var(--shc);
19
- --bxsh--20: var(--shsz--20) var(--shc);
20
- --bxsh--30: var(--shsz--30) var(--shc);
21
- --bxsh--40: var(--shsz--40) var(--shc);
22
- --bxsh--50: var(--shsz--50) var(--shc);
23
- }
@@ -1,30 +0,0 @@
1
- /* --------------------------------------------------
2
- SPACEトークンの定義
3
- Memo: set--s で、SPACEトークンを再定義できる。
4
- -------------------------------------------------- */
5
- :root,
6
- .set--s {
7
- /**
8
- * 余白: フィボナッチ数列をベースに設計する
9
- */
10
- --s-unit: calc(var(--fz--base) * 0.5); // 計算単位 ≒ 8px
11
-
12
- --s10: var(--s-unit); // ≒ 8px
13
- --s20: calc(var(--s-unit) * 2); // ≒ 16px
14
- --s30: calc(var(--s-unit) * 3); // ≒ 24px
15
- --s40: calc(var(--s-unit) * 5); // ≒ 40px
16
- --s50: calc(var(--s-unit) * 8); // ≒ 64px
17
- --s60: calc(var(--s-unit) * 13); // ≒ 104px
18
- --s70: calc(var(--s-unit) * 21); // ≒ 168px
19
- --s80: calc(var(--s-unit) * 34); // ≒ 272px
20
-
21
- // ~40までの前半部分は間を埋める
22
- --s5: calc(var(--s-unit) * 0.5); // ≒ 4px
23
- --s15: calc(var(--s-unit) * 1.5); // ≒ 12px
24
- --s25: calc(var(--s-unit) * 2.5); // ≒ 20px
25
- --s35: calc(var(--s-unit) * 4); // ≒ 32px
26
- }
27
- .set--s {
28
- // 何も指定しなければ em 単位に変換する
29
- --s-unit: 0.5em;
30
- }
@@ -1,69 +0,0 @@
1
- /* --------------------------------------------------
2
- ハーフレディング管理変数
3
- -------------------------------------------------- */
4
- @property --hl {
5
- syntax: '<length>';
6
- inherits: true;
7
- initial-value: 0.25rem;
8
- }
9
-
10
- /* --------------------------------------------------
11
- typography トークンの定義
12
- -------------------------------------------------- */
13
- :root {
14
- /**
15
- * font-size
16
- */
17
- // font-size: 倍音列でのスケーリング。単位は em
18
- --fz--base: 1rem;
19
- --fz-mol: 8; // 倍音列の分母(7~ に対応)
20
- --fz--5xl: calc(1em * var(--fz-mol) / (var(--fz-mol) - 6));
21
- --fz--4xl: calc(1em * var(--fz-mol) / (var(--fz-mol) - 5));
22
- --fz--3xl: calc(1em * var(--fz-mol) / (var(--fz-mol) - 4));
23
- --fz--2xl: calc(1em * var(--fz-mol) / (var(--fz-mol) - 3));
24
- --fz--xl: calc(1em * var(--fz-mol) / (var(--fz-mol) - 2));
25
- --fz--l: calc(1em * var(--fz-mol) / (var(--fz-mol) - 1));
26
- --fz--m: 1em;
27
- --fz--s: calc(1em * var(--fz-mol) / (var(--fz-mol) + 1));
28
- --fz--xs: calc(1em * var(--fz-mol) / (var(--fz-mol) + 2));
29
- --fz--2xs: calc(1em * var(--fz-mol) / (var(--fz-mol) + 3));
30
-
31
- /**
32
- * font-family
33
- * Memo: system-ui は 游ゴシックが適用されてしまう。
34
- */
35
- // Base font: -apple-system: safari&firefox / 'BlinkMacSystemFont': Chrome / 'Hiragino Sans': Mac / 'Segoe UI Emoji': Windows用
36
- --ff--base: -apple-system, 'BlinkMacSystemFont', 'Hiragino Sans', sans-serif, 'Segoe UI Emoji';
37
-
38
- // Mono font: SFMono, Menlo: Mac / Consolas: Win / Liberation Mono: Linux
39
- --ff--mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
40
-
41
- // Accent font: This is just one example.
42
- --ff--accent: 'Garamond', 'Baskerville', 'Times New Roman', serif;
43
-
44
- /**
45
- * font-weight
46
- */
47
- --fw--light: 300;
48
- --fw--normal: 400;
49
- --fw--bold: 600;
50
-
51
- /**
52
- * letter-spacing
53
- */
54
- --lts--base: normal;
55
- --lts--s: -0.025em;
56
- --lts--l: 0.05em;
57
- --lts--xl: 0.1em;
58
-
59
- /**
60
- * ハーフレディング: unit の倍数で構成する
61
- */
62
- --hl-unit: calc(var(--fz--base) * 0.125); /* 計算単位 ≒ 2px */
63
-
64
- --hl--xs: var(--hl-unit);
65
- --hl--s: calc(var(--hl-unit) * 2);
66
- --hl--base: calc(var(--hl-unit) * 3);
67
- --hl--l: calc(var(--hl-unit) * 4);
68
- // --hl--xl: calc(var(--hl-unit) * 5);
69
- }
@@ -1,16 +0,0 @@
1
- .-lh\:1 {
2
- --hl: 0px;
3
- // line-height: 1;
4
- }
5
- .-lh\:base {
6
- --hl: var(--hl--base);
7
- }
8
- .-lh\:xs {
9
- --hl: var(--hl--xs);
10
- }
11
- .-lh\:s {
12
- --hl: var(--hl--s);
13
- }
14
- .-lh\:l {
15
- --hl: var(--hl--l);
16
- }