lism-css 0.14.0 → 0.15.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.ja.md +2 -2
- package/README.md +4 -3
- package/bin/build-config.js +1 -4
- package/bin/cli.mjs +13 -3
- package/config/defaults/props.ts +11 -14
- package/config/defaults/tokens.ts +1 -1
- package/config/defaults/traits.ts +4 -0
- package/dist/components/Lism/Lism.d.ts +2 -1
- package/dist/config/default-config.d.ts +5 -12
- package/dist/config/defaults/props.d.ts +5 -14
- package/dist/config/defaults/props.js +7 -12
- package/dist/config/defaults/tokens.d.ts +1 -1
- package/dist/config/defaults/tokens.js +1 -1
- package/dist/config/defaults/traits.d.ts +4 -0
- package/dist/config/defaults/traits.js +5 -1
- package/dist/config/index.d.ts +10 -24
- package/dist/css/base/set.css +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/props.css +1 -1
- package/dist/css/trait.css +1 -0
- package/dist/css/utility.css +1 -1
- package/dist/lib/getLismProps.d.ts +5 -5
- package/dist/lib/getLismProps.js +101 -102
- package/dist/lib/types/TraitProps.d.ts +2 -2
- package/package.json +1 -1
- package/packages/astro/index.ts +3 -0
- package/packages/astro/layout/Flex/Flex.astro +3 -2
- package/packages/astro/layout/Flow/Flow.astro +2 -2
- package/packages/astro/types.ts +3 -0
- package/src/scss/_auto_output.scss +12 -11
- package/src/scss/_prop-config.scss +1 -11
- package/src/scss/_with_layer.scss +8 -4
- package/src/scss/base/_html.scss +3 -3
- package/src/scss/base/set/{_innerRs.scss → _bdrsInner.scss} +1 -1
- package/src/scss/base/set/_hov.scss +4 -4
- package/src/scss/base/set/_revert.scss +6 -0
- package/src/scss/base/set/index.scss +2 -4
- package/src/scss/base/tokens/_shadow.scss +18 -12
- package/src/scss/base/tokens/_tokens.scss +1 -12
- package/src/scss/main_no_layer.scss +4 -1
- package/src/scss/props/_hover.scss +27 -16
- package/src/scss/props/_size.scss +1 -1
- package/src/scss/{primitives/trait → trait}/_boxLink.scss +1 -1
- package/src/scss/{primitives/trait → trait}/_container.scss +2 -2
- package/src/scss/{base/set/_gutter.scss → trait/_hasGutter.scss} +1 -1
- package/src/scss/trait/_hasMask.scss +6 -0
- package/src/scss/trait/_hasSnap.scss +11 -0
- package/src/scss/trait/_hasTransition.scss +8 -0
- package/src/scss/{primitives/trait → trait}/index.scss +7 -1
- package/src/scss/utility/index.scss +0 -1
- package/dist/css/primitives/trait.css +0 -1
- package/src/scss/base/set/_mask.scss +0 -6
- package/src/scss/base/set/_transition.scss +0 -11
- package/src/scss/utility/_snap.scss +0 -8
- /package/src/scss/{primitives/trait → trait}/_coverLink.scss +0 -0
- /package/src/scss/{primitives/trait → trait}/_layer.scss +0 -0
- /package/src/scss/{primitives/trait → trait}/_wrapper.scss +0 -0
|
@@ -15,7 +15,6 @@ interface PropConfig {
|
|
|
15
15
|
isVar?: number;
|
|
16
16
|
bp?: 0 | 1;
|
|
17
17
|
alwaysVar?: number;
|
|
18
|
-
overwriteBaseVar?: number;
|
|
19
18
|
important?: number;
|
|
20
19
|
exUtility?: Record<string, unknown>;
|
|
21
20
|
customVar?: string;
|
|
@@ -35,10 +34,6 @@ export interface LismPropsBase extends TraitProps, PropValueTypes {
|
|
|
35
34
|
forwardedRef?: React.Ref<any>;
|
|
36
35
|
class?: string | null;
|
|
37
36
|
className?: string;
|
|
38
|
-
/**
|
|
39
|
-
* a--* / l--* / is--* クラスを集約する内部スロット。
|
|
40
|
-
* 通常は getLayoutProps / getAtomicProps 経由で push される。
|
|
41
|
-
*/
|
|
42
37
|
primitiveClass?: string[];
|
|
43
38
|
style?: StyleWithCustomProps;
|
|
44
39
|
_propConfig?: Record<string, PropConfig>;
|
|
@@ -52,7 +47,10 @@ export interface LismPropsBase extends TraitProps, PropValueTypes {
|
|
|
52
47
|
export declare class LismPropsData {
|
|
53
48
|
className: string;
|
|
54
49
|
primitiveClass: string[];
|
|
50
|
+
setClasses: string[];
|
|
51
|
+
traitClasses: string[];
|
|
55
52
|
uClasses: string[];
|
|
53
|
+
propClasses: string[];
|
|
56
54
|
styles: StyleWithCustomProps;
|
|
57
55
|
attrs: Record<string, unknown>;
|
|
58
56
|
_propConfig?: Record<string, PropConfig>;
|
|
@@ -61,8 +59,10 @@ export declare class LismPropsData {
|
|
|
61
59
|
analyzeTrait(traitPropData: TraitPropDataObject, propVal: unknown): void;
|
|
62
60
|
analyzeProps(): void;
|
|
63
61
|
analyzeLismProp(propName: string, propVal: unknown): void;
|
|
62
|
+
addSet(setName: string): void;
|
|
64
63
|
addUtil(util: string): void;
|
|
65
64
|
addUtils(utils: string[]): void;
|
|
65
|
+
addProp(prop: string): void;
|
|
66
66
|
addStyle(name: string, val: string | number): void;
|
|
67
67
|
addStyles(styles: Record<string, string | number | undefined>): void;
|
|
68
68
|
addAttrs(data: {
|
package/dist/lib/getLismProps.js
CHANGED
|
@@ -1,146 +1,149 @@
|
|
|
1
|
-
import { TRAITS as C, PROPS as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { TRAITS as C, PROPS as c } from "../config/index.js";
|
|
2
|
+
import V from "./getLayoutProps.js";
|
|
3
|
+
import E from "./getAtomicProps.js";
|
|
4
|
+
import g from "./isPresetValue.js";
|
|
5
5
|
import x from "./isTokenValue.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import $ from "./getUtilKey.js";
|
|
7
|
+
import d from "./getMaybeCssVar.js";
|
|
8
8
|
import w from "./getBpData.js";
|
|
9
9
|
import A from "./helper/atts.js";
|
|
10
10
|
import _ from "./helper/isEmptyObj.js";
|
|
11
|
-
import
|
|
11
|
+
import S from "./helper/filterEmptyObj.js";
|
|
12
12
|
import b from "./helper/mergeSet.js";
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
return
|
|
13
|
+
import z from "./helper/splitWithComma.js";
|
|
14
|
+
const L = (n) => {
|
|
15
|
+
const s = c[n];
|
|
16
|
+
return s && s?.token || "";
|
|
17
17
|
};
|
|
18
|
-
class
|
|
18
|
+
class T {
|
|
19
19
|
// 最終出力 className
|
|
20
20
|
className = "";
|
|
21
|
-
// 出力順のためのクラスバケット: [primitiveClass] [uClasses]
|
|
22
|
-
// - primitiveClass : a--* / l--* / is--* の primitive クラス(getAtomicProps → getLayoutProps → analyzeTrait の順で push)
|
|
23
|
-
// - uClasses : set--* → u--* → -property の順で push される utility クラス
|
|
24
21
|
primitiveClass = [];
|
|
22
|
+
setClasses = [];
|
|
23
|
+
traitClasses = [];
|
|
25
24
|
uClasses = [];
|
|
25
|
+
propClasses = [];
|
|
26
26
|
styles = {};
|
|
27
27
|
attrs = {};
|
|
28
28
|
_propConfig;
|
|
29
|
-
constructor(
|
|
30
|
-
const { forwardedRef: t, class:
|
|
31
|
-
this.styles = { ...r }, this._propConfig = { ...
|
|
29
|
+
constructor(s) {
|
|
30
|
+
const { forwardedRef: t, class: i, className: e, primitiveClass: o, style: r = {}, _propConfig: a = {}, ...u } = s;
|
|
31
|
+
this.styles = { ...r }, this._propConfig = { ...a }, o && o.length && (this.primitiveClass = [...o]), _(u) || (this.attrs = { ...u }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = this.buildClassName(e, i);
|
|
32
32
|
}
|
|
33
33
|
// 最終クラス文字列の組み立て(出力順の唯一の確定地点)
|
|
34
|
-
// 出力順: [className&class] [primitiveClass] [uClasses]
|
|
34
|
+
// 出力順: [className&class] [primitiveClass] [setClasses] [traitClasses] [uClasses] [propClasses]
|
|
35
35
|
// className と class が両方来た場合は両方マージする(atts 内で重複は除去される)。
|
|
36
|
-
buildClassName(
|
|
37
|
-
return A(
|
|
36
|
+
buildClassName(s, t) {
|
|
37
|
+
return A(s, t, this.primitiveClass, this.setClasses, this.traitClasses, this.uClasses, this.propClasses);
|
|
38
38
|
}
|
|
39
|
-
analyzeTrait(
|
|
40
|
-
const { className:
|
|
41
|
-
t === !0 ? this.
|
|
39
|
+
analyzeTrait(s, t) {
|
|
40
|
+
const { className: i, preset: e, presetClass: o, customVar: r, tokenKey: a } = s;
|
|
41
|
+
t === !0 ? this.traitClasses.push(i) : e && g(e, t) ? this.traitClasses.push(`${i} ${o}:${String(t)}`) : t && (this.traitClasses.push(i), a && r && this.addStyle(r, d(t, a)));
|
|
42
42
|
}
|
|
43
43
|
// prop解析
|
|
44
44
|
analyzeProps() {
|
|
45
|
-
const
|
|
46
|
-
b(void 0,
|
|
47
|
-
if (Object.hasOwn(C,
|
|
48
|
-
const e = this.extractProp(
|
|
49
|
-
typeof
|
|
50
|
-
} else if (Object.hasOwn(
|
|
51
|
-
const e = this.attrs[
|
|
52
|
-
delete this.attrs[
|
|
53
|
-
} else if (
|
|
54
|
-
const e = this.extractProp(
|
|
45
|
+
const s = this.extractProp("set"), t = this.extractProp("util");
|
|
46
|
+
b(void 0, s).forEach((i) => this.addSet(i)), b(void 0, t).forEach((i) => this.addUtil(`u--${i}`)), Object.keys(this.attrs).forEach((i) => {
|
|
47
|
+
if (Object.hasOwn(C, i)) {
|
|
48
|
+
const e = this.extractProp(i), o = C[i];
|
|
49
|
+
typeof o == "string" ? e && this.traitClasses.push(o) : this.analyzeTrait(o, e);
|
|
50
|
+
} else if (Object.hasOwn(c, i)) {
|
|
51
|
+
const e = this.attrs[i];
|
|
52
|
+
delete this.attrs[i], this.analyzeLismProp(i, e);
|
|
53
|
+
} else if (i === "hov") {
|
|
54
|
+
const e = this.extractProp(i);
|
|
55
55
|
this.setHovProps(e);
|
|
56
|
-
} else if (
|
|
56
|
+
} else if (i === "css") {
|
|
57
57
|
const e = this.extractProp("css");
|
|
58
58
|
this.addStyles(e);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
// Lism Prop 解析
|
|
63
|
-
analyzeLismProp(
|
|
63
|
+
analyzeLismProp(s, t) {
|
|
64
64
|
if (t == null) return;
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
67
|
-
this._propConfig?.[
|
|
68
|
-
const { base: e, ...
|
|
69
|
-
this.setAttrs(
|
|
70
|
-
|
|
65
|
+
let i = c[s] || null;
|
|
66
|
+
if (i === null) return;
|
|
67
|
+
this._propConfig?.[s] && (i = Object.assign({}, i, this._propConfig[s]));
|
|
68
|
+
const { base: e, ...o } = w(t);
|
|
69
|
+
this.setAttrs(s, e, i), Object.keys(o).forEach((r) => {
|
|
70
|
+
i && this.setAttrs(s, o[r], i, r);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
this.
|
|
73
|
+
addSet(s) {
|
|
74
|
+
this.setClasses.push(`set--${s}`);
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
this.uClasses.push(
|
|
76
|
+
addUtil(s) {
|
|
77
|
+
this.uClasses.push(s);
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.
|
|
79
|
+
addUtils(s) {
|
|
80
|
+
this.uClasses.push(...s);
|
|
81
|
+
}
|
|
82
|
+
addProp(s) {
|
|
83
|
+
this.propClasses.push(s);
|
|
84
|
+
}
|
|
85
|
+
addStyle(s, t) {
|
|
86
|
+
this.styles[s] = t;
|
|
84
87
|
}
|
|
85
|
-
addStyles(
|
|
86
|
-
this.styles = { ...this.styles, ...
|
|
88
|
+
addStyles(s) {
|
|
89
|
+
this.styles = { ...this.styles, ...s };
|
|
87
90
|
}
|
|
88
|
-
addAttrs(
|
|
89
|
-
this.addStyles(
|
|
91
|
+
addAttrs(s) {
|
|
92
|
+
this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
|
|
90
93
|
}
|
|
91
|
-
extractProp(
|
|
92
|
-
const t = this.attrs[
|
|
93
|
-
return this.attrs[
|
|
94
|
+
extractProp(s) {
|
|
95
|
+
const t = this.attrs[s];
|
|
96
|
+
return this.attrs[s] === void 0 ? null : (delete this.attrs[s], t);
|
|
94
97
|
}
|
|
95
|
-
extractProps(
|
|
98
|
+
extractProps(s) {
|
|
96
99
|
const t = {};
|
|
97
|
-
return
|
|
98
|
-
this.attrs[
|
|
100
|
+
return s.forEach((i) => {
|
|
101
|
+
this.attrs[i] !== void 0 && (t[i] = this.attrs[i], delete this.attrs[i]);
|
|
99
102
|
}), t;
|
|
100
103
|
}
|
|
101
|
-
//
|
|
104
|
+
// propertyクラスを追加するか、styleにセットするかの分岐処理 @base
|
|
102
105
|
// 値が null, undefined, '', false の時はスキップ
|
|
103
|
-
setAttrs(
|
|
106
|
+
setAttrs(s, t, i = {}, e = "") {
|
|
104
107
|
if (t == null || t === "" || t === !1) return;
|
|
105
|
-
let
|
|
106
|
-
if (e && (
|
|
107
|
-
this.
|
|
108
|
+
let o = `--${s}`, r = `-${String(i.utilKey || s)}`;
|
|
109
|
+
if (e && (o = `--${s}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
|
|
110
|
+
this.addProp(`${r}:${t.replace(":", "")}`);
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
113
|
if (!e) {
|
|
111
|
-
const { presets: m, tokenClass: j, utils:
|
|
112
|
-
if (m &&
|
|
114
|
+
const { presets: m, tokenClass: j, utils: p, shorthands: P } = i;
|
|
115
|
+
if (m && g(m, t)) {
|
|
113
116
|
const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
114
|
-
h && this.
|
|
117
|
+
h && this.addProp(`${r}:${h}`);
|
|
115
118
|
return;
|
|
116
119
|
}
|
|
117
|
-
if (j &&
|
|
120
|
+
if (j && i.token && x(i.token, t)) {
|
|
118
121
|
const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
119
|
-
h && this.
|
|
122
|
+
h && this.addProp(`${r}:${h}`);
|
|
120
123
|
return;
|
|
121
124
|
}
|
|
122
|
-
let
|
|
123
|
-
if (
|
|
124
|
-
this.
|
|
125
|
+
let f = "";
|
|
126
|
+
if (p && typeof t == "string" && (f = $(p, t)), !f && P && typeof t == "string" && (f = $(P, t, !0)), f) {
|
|
127
|
+
this.addProp(`${r}:${f}`);
|
|
125
128
|
return;
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
if (t === !0
|
|
129
|
-
this.
|
|
131
|
+
if (t === !0) {
|
|
132
|
+
this.addProp(r);
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
132
|
-
const { prop:
|
|
133
|
-
let
|
|
134
|
-
if (y && (typeof t == "string" || typeof t == "number") ?
|
|
135
|
-
if (
|
|
136
|
-
this.addStyle(`--${
|
|
135
|
+
const { prop: a, isVar: u, alwaysVar: O, token: y, bp: k } = i;
|
|
136
|
+
let l;
|
|
137
|
+
if (y && (typeof t == "string" || typeof t == "number") ? l = d(t, y) : typeof t == "string" || typeof t == "number" ? l = t : l = JSON.stringify(t), !e) {
|
|
138
|
+
if (u) {
|
|
139
|
+
this.addStyle(`--${s}`, l);
|
|
137
140
|
return;
|
|
138
141
|
} else if (!k && !O) {
|
|
139
|
-
this.addStyle(
|
|
142
|
+
this.addStyle(a, l);
|
|
140
143
|
return;
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
|
-
this.
|
|
146
|
+
this.addProp(r), this.addStyle(o, l);
|
|
144
147
|
}
|
|
145
148
|
// setPassProps(passVars) {
|
|
146
149
|
// let dataList = [];
|
|
@@ -155,21 +158,17 @@ class L {
|
|
|
155
158
|
// this.addStyle(`--pass_${propName}`, value);
|
|
156
159
|
// });
|
|
157
160
|
// }
|
|
158
|
-
setHovProps(
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
}) : typeof
|
|
162
|
-
const
|
|
163
|
-
if (!(
|
|
164
|
-
if (
|
|
165
|
-
this.
|
|
166
|
-
else if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
else if (typeof s == "string" || typeof s == "number") {
|
|
171
|
-
const e = u(s, z(t));
|
|
172
|
-
this.addUtil(`-hov:${t}`), this.addStyle(`--hov-${t}`, e);
|
|
161
|
+
setHovProps(s) {
|
|
162
|
+
s && (s === !0 ? this.addProp("-hov") : typeof s == "string" ? z(s).forEach((t) => {
|
|
163
|
+
this.addProp(`-hov:${t}`);
|
|
164
|
+
}) : typeof s == "object" && Object.keys(s).forEach((t) => {
|
|
165
|
+
const i = s[t];
|
|
166
|
+
if (!(i == null || i === "" || i === !1)) {
|
|
167
|
+
if (i === !0)
|
|
168
|
+
this.addProp(`-hov:${t}`);
|
|
169
|
+
else if (typeof i == "string" || typeof i == "number") {
|
|
170
|
+
const e = d(i, L(t));
|
|
171
|
+
this.addProp(`-hov:-${t}`), this.addStyle(`--hov-${t}`, e);
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
}));
|
|
@@ -178,17 +177,17 @@ class L {
|
|
|
178
177
|
function Y(n) {
|
|
179
178
|
if (Object.keys(n).length === 0)
|
|
180
179
|
return {};
|
|
181
|
-
const { atomic:
|
|
180
|
+
const { atomic: s, layout: t, ...i } = n, e = E(s, i), o = V(t, e), r = new T(o);
|
|
182
181
|
return {
|
|
183
|
-
...
|
|
182
|
+
...S({
|
|
184
183
|
className: r.className,
|
|
185
|
-
style:
|
|
184
|
+
style: S(r.styles)
|
|
186
185
|
}),
|
|
187
186
|
...r.attrs
|
|
188
187
|
// data-* などHTMLの標準属性はそのまま渡す
|
|
189
188
|
};
|
|
190
189
|
}
|
|
191
190
|
export {
|
|
192
|
-
|
|
191
|
+
T as LismPropsData,
|
|
193
192
|
Y as default
|
|
194
193
|
};
|
|
@@ -23,7 +23,7 @@ export type TraitProps = {
|
|
|
23
23
|
[K in keyof TraitsConfig]?: ExtractTraitValue<TraitsConfig[K]>;
|
|
24
24
|
};
|
|
25
25
|
/** set prop で使われるプリセット値(エディタ補完用) */
|
|
26
|
-
type SetPreset = '
|
|
26
|
+
type SetPreset = 'plain' | 'revert' | 'var:hov' | 'var:bxsh' | 'var:bdrsInner';
|
|
27
27
|
/**
|
|
28
28
|
* set prop の値の型。プリセット値がサジェストされつつ、任意の文字列も受け付ける。
|
|
29
29
|
*
|
|
@@ -34,7 +34,7 @@ type SetPreset = 'gutter' | 'shadow' | 'hov' | 'transition' | 'mask' | 'plain' |
|
|
|
34
34
|
*/
|
|
35
35
|
export type SetPropValue = WithArbitraryString<SetPreset> | WithArbitraryString<SetPreset>[];
|
|
36
36
|
/** util prop で使われるプリセット値(既知の `u--` クラス名・エディタ補完用) */
|
|
37
|
-
type UtilPreset = 'cbox' | 'trim' | 'trimChildren' | 'srOnly' | 'clipText' | 'collapseGrid'
|
|
37
|
+
type UtilPreset = 'cbox' | 'trim' | 'trimChildren' | 'srOnly' | 'clipText' | 'collapseGrid';
|
|
38
38
|
/**
|
|
39
39
|
* util prop の値の型。既知の `u--` クラス名がサジェストされつつ、任意の文字列も受け付ける。
|
|
40
40
|
*
|
package/package.json
CHANGED
package/packages/astro/index.ts
CHANGED
|
@@ -41,3 +41,6 @@ export * from './atomic/Decorator';
|
|
|
41
41
|
export * from './atomic/Divider';
|
|
42
42
|
export * from './atomic/Icon';
|
|
43
43
|
export * from './atomic/Spacer';
|
|
44
|
+
|
|
45
|
+
// Type exports for Astro components
|
|
46
|
+
export type { AstroLismBaseProps, AstroLismFixedLayoutProps, AstroLayoutProps } from './types';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLayoutProps } from '../../types';
|
|
4
|
+
import type { FlexProps } from 'lism-css/lib/types/LayoutProps';
|
|
4
5
|
import { Lism } from '../../Lism';
|
|
5
6
|
|
|
6
|
-
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
|
|
7
|
+
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLayoutProps<FlexProps>;
|
|
7
8
|
|
|
8
9
|
const props = Astro.props;
|
|
9
10
|
---
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLayoutProps } from '../../types';
|
|
4
4
|
import type { FlowLayoutProps } from 'lism-css/lib/types/LayoutProps';
|
|
5
5
|
import { Lism } from '../../Lism';
|
|
6
6
|
|
|
7
|
-
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
|
|
7
|
+
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLayoutProps<FlowLayoutProps>;
|
|
8
8
|
|
|
9
9
|
const props = Astro.props;
|
|
10
10
|
---
|
package/packages/astro/types.ts
CHANGED
|
@@ -17,3 +17,6 @@ export type AstroLismBaseProps = LismProps &
|
|
|
17
17
|
export type AstroLismFixedLayoutProps = Omit<LismProps, 'layout'> & {
|
|
18
18
|
exProps?: Record<string, unknown>;
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
/** レイアウトコンポーネント向けベース型(React の LayoutComponentProps<T, L> に対応) */
|
|
22
|
+
export type AstroLayoutProps<L = object> = AstroLismFixedLayoutProps & Omit<L, 'layout'>;
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
@use './query' as query;
|
|
7
7
|
@use './setting' as setting;
|
|
8
8
|
|
|
9
|
-
/*
|
|
9
|
+
/*
|
|
10
10
|
base_type:
|
|
11
11
|
0 → なし(ユーティリティクラス以外は普通のインラインスタイルのみ)
|
|
12
12
|
1 → .-d{display: var(--d)} (メリット:importantなしでbp対応できる)
|
|
13
|
-
2 → .-p, [class*='-p\:'] {padding: var(--p);} の形式で、
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
2 → alwaysVar 対象。 .-p, [class*='-p\:'] {padding: var(--p);} の形式で、
|
|
14
|
+
ユーティリティクラスは --p をセットする形になる(state 変数として扱う)。
|
|
15
|
+
BPクラスも .-p_$bp { padding: var(--p); --p: var(--p_$bp) !important; } を出力し、
|
|
16
|
+
--p が常に現在値を参照できるようになる。
|
|
17
|
+
デメリット: *= は処理負荷が高い。
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
// マップから値を取得し、nullの場合はデフォルト値を返す
|
|
@@ -218,7 +218,7 @@ $bp_outputs: (
|
|
|
218
218
|
$prop_data: map.get(setting.$props, $key);
|
|
219
219
|
$prop_name: map.get($prop_data, prop);
|
|
220
220
|
$isVar: map_get_with_default($prop_data, isVar, 0);
|
|
221
|
-
$
|
|
221
|
+
$alwaysVar: map_get_with_default($prop_data, alwaysVar, 0);
|
|
222
222
|
$important: map_get_with_default($prop_data, important, setting.$default_important);
|
|
223
223
|
|
|
224
224
|
@if $isVar == 1 {
|
|
@@ -226,11 +226,12 @@ $bp_outputs: (
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.-#{$key}_#{$bp} {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
@if $overwriteBaseVar == 1 {
|
|
229
|
+
@if $alwaysVar == 1 {
|
|
230
|
+
// state 変数扱い: --prop を単一情報源にし、--prop を上書きして property は var(--prop) を読む
|
|
231
|
+
#{$prop_name}: var(--#{$key}) #{get_important_str($important)};
|
|
233
232
|
--#{$key}: var(--#{$key}_#{$bp}) !important;
|
|
233
|
+
} @else {
|
|
234
|
+
#{$prop_name}: var(--#{$key}_#{$bp}) #{get_important_str($important)};
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
}
|
|
@@ -22,7 +22,6 @@ $props: (
|
|
|
22
22
|
'2xs': 'var(--fz--2xs)',
|
|
23
23
|
),
|
|
24
24
|
bp: 1,
|
|
25
|
-
alwaysVar: 1,
|
|
26
25
|
),
|
|
27
26
|
'fw': (
|
|
28
27
|
prop: 'font-weight',
|
|
@@ -317,7 +316,6 @@ $props: (
|
|
|
317
316
|
),
|
|
318
317
|
bp: 1,
|
|
319
318
|
alwaysVar: 1,
|
|
320
|
-
overwriteBaseVar: 1,
|
|
321
319
|
),
|
|
322
320
|
'bxsh': (
|
|
323
321
|
prop: 'box-shadow',
|
|
@@ -327,9 +325,9 @@ $props: (
|
|
|
327
325
|
'20': 'var(--bxsh--20)',
|
|
328
326
|
'30': 'var(--bxsh--30)',
|
|
329
327
|
'40': 'var(--bxsh--40)',
|
|
328
|
+
'50': 'var(--bxsh--50)',
|
|
330
329
|
),
|
|
331
330
|
bp: 1,
|
|
332
|
-
alwaysVar: 1,
|
|
333
331
|
),
|
|
334
332
|
'pos': (
|
|
335
333
|
prop: 'position',
|
|
@@ -405,7 +403,6 @@ $props: (
|
|
|
405
403
|
),
|
|
406
404
|
bp: 1,
|
|
407
405
|
alwaysVar: 1,
|
|
408
|
-
overwriteBaseVar: 1,
|
|
409
406
|
),
|
|
410
407
|
'px': (
|
|
411
408
|
prop: 'padding-inline',
|
|
@@ -423,7 +420,6 @@ $props: (
|
|
|
423
420
|
'80': 'var(--s80)',
|
|
424
421
|
),
|
|
425
422
|
bp: 1,
|
|
426
|
-
alwaysVar: 1,
|
|
427
423
|
),
|
|
428
424
|
'py': (
|
|
429
425
|
prop: 'padding-block',
|
|
@@ -441,7 +437,6 @@ $props: (
|
|
|
441
437
|
'80': 'var(--s80)',
|
|
442
438
|
),
|
|
443
439
|
bp: 1,
|
|
444
|
-
alwaysVar: 1,
|
|
445
440
|
),
|
|
446
441
|
'px-s': (
|
|
447
442
|
prop: 'padding-inline-start',
|
|
@@ -493,7 +488,6 @@ $props: (
|
|
|
493
488
|
),
|
|
494
489
|
bp: 1,
|
|
495
490
|
alwaysVar: 1,
|
|
496
|
-
overwriteBaseVar: 1,
|
|
497
491
|
),
|
|
498
492
|
'mx': (
|
|
499
493
|
prop: 'margin-inline',
|
|
@@ -512,7 +506,6 @@ $props: (
|
|
|
512
506
|
'auto': 'auto',
|
|
513
507
|
),
|
|
514
508
|
bp: 1,
|
|
515
|
-
alwaysVar: 1,
|
|
516
509
|
),
|
|
517
510
|
'my': (
|
|
518
511
|
prop: 'margin-block',
|
|
@@ -531,7 +524,6 @@ $props: (
|
|
|
531
524
|
'auto': 'auto',
|
|
532
525
|
),
|
|
533
526
|
bp: 1,
|
|
534
|
-
alwaysVar: 1,
|
|
535
527
|
),
|
|
536
528
|
'mx-s': (
|
|
537
529
|
prop: 'margin-inline-start',
|
|
@@ -609,8 +601,6 @@ $props: (
|
|
|
609
601
|
),
|
|
610
602
|
),
|
|
611
603
|
bp: 1,
|
|
612
|
-
alwaysVar: 1,
|
|
613
|
-
overwriteBaseVar: 1,
|
|
614
604
|
),
|
|
615
605
|
'cg': (
|
|
616
606
|
prop: 'column-gap',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
@use 'sass:meta';
|
|
5
5
|
|
|
6
6
|
// レイヤー順序を明示的に宣言(詳細度: 上ほど弱い)
|
|
7
|
-
@layer lism-base, lism-primitive, lism-component, lism-custom, lism-utility;
|
|
7
|
+
@layer lism-base, lism-trait, lism-primitive, lism-component, lism-custom, lism-utility;
|
|
8
8
|
|
|
9
9
|
@layer lism-base {
|
|
10
10
|
// resetは中でも layer定義済み。 lism-base.reset となる
|
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
@include meta.load-css('base');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// ユーザーが明示的に宣言する trait クラス(is--* / has--*)用レイヤー。
|
|
17
|
+
// primitive より弱い位置に配置し、is--boxLink の display: block 等の
|
|
18
|
+
// 初期化的な宣言がレイアウトプリミティブ(l--stack の display: flex 等)に負けるようにする。
|
|
19
|
+
@layer lism-trait {
|
|
20
|
+
@include meta.load-css('trait');
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
@layer lism-primitive {
|
|
17
|
-
@layer trait {
|
|
18
|
-
@include meta.load-css('primitives/trait');
|
|
19
|
-
}
|
|
20
24
|
@layer layout {
|
|
21
25
|
@include meta.load-css('primitives/layout');
|
|
22
26
|
}
|
package/src/scss/base/_html.scss
CHANGED
|
@@ -95,9 +95,9 @@ hr {
|
|
|
95
95
|
/* --------------------------------------------------
|
|
96
96
|
list
|
|
97
97
|
-------------------------------------------------- */
|
|
98
|
-
// class
|
|
99
|
-
|
|
100
|
-
:is(ul, ol):where([class
|
|
98
|
+
// classを持たないリスト要素はブラウザ標準のスタイルを復活させる。
|
|
99
|
+
// Property Class だけの ul/ol など、明示的に戻したい場合は `.set--revert` を付与する(base/set/_revert.scss)。
|
|
100
|
+
:is(ul, ol):where(:not([class])) {
|
|
101
101
|
list-style: revert;
|
|
102
102
|
padding-inline-start: var(--list-px-s, var(--s30));
|
|
103
103
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
@media (any-hover: hover) {
|
|
2
|
-
.set--hov:hover {
|
|
2
|
+
.set--var\:hov:hover {
|
|
3
3
|
--_notHov: ;
|
|
4
4
|
}
|
|
5
|
-
.set--hov:not(:is(:hover, :focus-within)) {
|
|
5
|
+
.set--var\:hov:not(:is(:hover, :focus-within)) {
|
|
6
6
|
--_isHov: ;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
@media (any-hover: none) {
|
|
10
|
-
.set--hov {
|
|
10
|
+
.set--var\:hov {
|
|
11
11
|
--_isHov: ;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
.set--hov:is(:focus-visible, :focus-within) {
|
|
14
|
+
.set--var\:hov:is(:focus-visible, :focus-within) {
|
|
15
15
|
--_notHov: ;
|
|
16
16
|
}
|