@lism-css/ui 0.1.0 → 0.1.2

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 (36) hide show
  1. package/dist/components/Accordion/setAccordion.d.ts +1 -1
  2. package/dist/components/Accordion/setAccordion.js +39 -28
  3. package/dist/components/Avatar/astro/index.d.ts +1 -0
  4. package/dist/components/Avatar/react/Avatar.d.ts +6 -0
  5. package/dist/components/Avatar/react/index.d.ts +1 -0
  6. package/dist/components/Badge/astro/index.d.ts +1 -0
  7. package/dist/components/Badge/react/Badge.d.ts +1 -0
  8. package/dist/components/Badge/react/index.d.ts +1 -0
  9. package/dist/components/Button/astro/index.d.ts +1 -0
  10. package/dist/components/Button/react/Button.d.ts +1 -0
  11. package/dist/components/Button/react/index.d.ts +1 -0
  12. package/dist/components/astro.d.ts +3 -0
  13. package/dist/components/react.d.ts +3 -0
  14. package/dist/style.css +1 -1
  15. package/package.json +2 -2
  16. package/src/components/Accordion/_style.css +5 -5
  17. package/src/components/Accordion/react/Accordion.jsx +0 -6
  18. package/src/components/Accordion/setAccordion.js +76 -63
  19. package/src/components/Avatar/_style.css +2 -0
  20. package/src/components/Avatar/astro/Avatar.astro +10 -0
  21. package/src/components/Avatar/astro/index.js +1 -0
  22. package/src/components/Avatar/react/Avatar.jsx +10 -0
  23. package/src/components/Avatar/react/index.js +1 -0
  24. package/src/components/Badge/_style.css +15 -0
  25. package/src/components/Badge/astro/Badge.astro +16 -0
  26. package/src/components/Badge/astro/index.js +1 -0
  27. package/src/components/Badge/react/Badge.jsx +14 -0
  28. package/src/components/Badge/react/index.js +1 -0
  29. package/src/components/Button/_style.css +54 -0
  30. package/src/components/Button/astro/Button.astro +16 -0
  31. package/src/components/Button/astro/index.js +1 -0
  32. package/src/components/Button/react/Button.jsx +14 -0
  33. package/src/components/Button/react/index.js +1 -0
  34. package/src/components/astro.ts +3 -0
  35. package/src/components/react.ts +3 -0
  36. package/src/style.scss +4 -1
@@ -1,3 +1,3 @@
1
- export function setEvent(currentRef: any): (() => void) | undefined;
1
+ export function setEvent(details: any): (() => void) | undefined;
2
2
  export default setAccordion;
3
3
  declare function setAccordion(): void;
@@ -1,37 +1,48 @@
1
- const s = (t) => Promise.all(t.getAnimations().map((e) => e.finished)), d = async (t, e = !1) => {
2
- if (t.dataset.animating && !e) return;
3
- t.dataset.animating = "1";
4
- const n = t.querySelector(".d--accordion_body");
5
- t.open ? t.open && (t.removeAttribute("data-opened"), await s(n), delete t.dataset.animating, t.open = !1) : (t.open = !0, setTimeout(async () => {
6
- t.setAttribute("data-opened", ""), await s(n), delete t.dataset.animating;
7
- }, 5));
8
- }, u = (t, e) => {
9
- const n = e.open, o = e.hasAttribute("data-opened");
10
- n && !o && e.setAttribute("data-opened", ""), !n && o && e.removeAttribute("data-opened");
11
- }, p = (t) => {
12
- const e = t, n = e.querySelector('[data-role="trigger"]') || e.querySelector("summary");
13
- if (!n) return;
14
- let o = !1;
15
- const r = e.parentNode;
16
- r != null && (o = r.dataset.accordionMultiple !== "disallow");
17
- const c = (a) => {
18
- if (a.preventDefault(), !o && !e.open) {
19
- const l = r.querySelector("[data-opened]");
20
- l != null && d(l, !0);
1
+ const l = (e) => {
2
+ const t = e.querySelector(".d--accordion_body"), n = t ? t.getAnimations() : [];
3
+ return Promise.allSettled(n.map((o) => o.finished));
4
+ }, s = async (e) => {
5
+ e.open && e.hasAttribute("data-opened") || (e.open = !0, requestAnimationFrame(() => {
6
+ e.setAttribute("data-opened", "");
7
+ }));
8
+ }, a = async (e) => {
9
+ !e.open && !e.hasAttribute("data-opened") || (e.removeAttribute("data-opened"), await l(e), e.open = !1);
10
+ }, i = (e) => {
11
+ let t = !1;
12
+ const n = e.parentNode;
13
+ return n != null && (t = n.dataset.multiple !== "disallow"), t;
14
+ }, p = (e, t) => {
15
+ if (e.open)
16
+ e.open && a(e);
17
+ else {
18
+ if (!t) {
19
+ const o = e.parentNode.querySelector("[data-opened]");
20
+ requestAnimationFrame(() => {
21
+ o != null && a(o);
22
+ });
21
23
  }
22
- d(e);
23
- }, i = (a) => {
24
- u(a, e);
24
+ s(e);
25
+ }
26
+ }, u = (e) => {
27
+ const t = e.open, n = e.hasAttribute("data-opened");
28
+ t && !n && e.setAttribute("data-opened", ""), !t && n && e.removeAttribute("data-opened");
29
+ }, d = (e) => {
30
+ const t = i(e), n = e.querySelector("summary");
31
+ if (!n) return;
32
+ const o = (c) => {
33
+ c.preventDefault(), p(e, t);
34
+ }, r = () => {
35
+ u(e);
25
36
  };
26
- return n.addEventListener("click", c), e.addEventListener("toggle", i), () => {
27
- n.removeEventListener("click", c), e.removeEventListener("toggle", i);
37
+ return n.addEventListener("click", o), e.addEventListener("toggle", r), () => {
38
+ n.removeEventListener("click", o), e.removeEventListener("toggle", r);
28
39
  };
29
40
  }, m = () => {
30
- document.querySelectorAll(".d--accordion").forEach((e) => {
31
- p(e);
41
+ document.querySelectorAll(".d--accordion").forEach((t) => {
42
+ d(t);
32
43
  });
33
44
  };
34
45
  export {
35
46
  m as default,
36
- p as setEvent
47
+ d as setEvent
37
48
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export default function Avatar({ size, src, alt, ...props }: {
2
+ [x: string]: any;
3
+ size?: string | undefined;
4
+ src?: string | undefined;
5
+ alt?: string | undefined;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default } from './Avatar';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export default function Badge(props: any): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default } from './Badge';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export default function Button(props: any): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default } from './Button';
@@ -1,3 +1,6 @@
1
1
  export { default as Accordion } from './Accordion/astro';
2
+ export { default as Avatar } from './Avatar/astro';
3
+ export { default as Badge } from './Badge/astro';
4
+ export { default as Button } from './Button/astro';
2
5
  export { default as Modal } from './Modal/astro';
3
6
  export { default as Tabs } from './Tabs/astro';
@@ -1,3 +1,6 @@
1
1
  export { default as Accordion } from './Accordion/react';
2
+ export { default as Avatar } from './Avatar/react';
3
+ export { default as Badge } from './Badge/react';
4
+ export { default as Button } from './Button/react';
2
5
  export { default as Modal } from './Modal/react';
3
6
  export { default as Tabs } from './Tabs/react';
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- @layer lism.modules{.d--accordion{--duration:var(--acc-duration,0.4s)}.d--accordion[data-opened]{--_notOpen: }.d--accordion:not([data-opened]){--_isOpen: }.d--accordion_header{align-items:center;display:grid;gap:.5em;grid:auto/1fr auto;outline-offset:-1px;&::-webkit-details-marker{display:none}}.d--accordion_body{display:grid;grid:1fr/auto;transition-duration:var(--duration);transition-property:margin-block,padding-block,opacity,grid-template}.d--accordion_inner{overflow:hidden}.d--accordion:not([data-opened])>.d--accordion_body{grid:0fr/auto;margin-block:0!important;padding-block:0!important}.d--accordion_icon{display:grid}.d--accordion_icon .a--icon{rotate:var(--_isOpen,-180deg);transition-duration:var(--duration)}}
1
+ @layer lism.modules{.d--accordion{--duration:var(--acc-duration,0.25s)}.d--accordion[data-opened]{--_notOpen: }.d--accordion:not([data-opened]){--_isOpen: }.d--accordion_header{align-items:center;display:grid;gap:.5em;grid:auto/1fr auto;--focus-offset:-1px;&::-webkit-details-marker{display:none}}.d--accordion_body{display:grid;grid:1fr/auto;transition-duration:var(--duration);transition-property:margin-block,padding-block,opacity,grid-template}.d--accordion_inner{overflow:hidden}.d--accordion:not([data-opened])>.d--accordion_body{grid:0fr/auto;margin-block:0!important;padding-block:0!important}.d--accordion_icon{display:grid}.d--accordion_icon>.a--icon{transform:var(--_isOpen,scaleY(-1));transition:transform var(--duration)}.c--badge{--c:var(--base);--bgc:var(--text);--bdc:transparent;background-color:var(--bgc);border:1px solid var(--bdc);color:var(--c)}.c--badge--outline{--c:var(--text);--bgc:transparent;--bdc:currentColor}.c--button{--c:var(--base);--bgc:var(--text);--bdc:var(--bgc);background-color:var(--bgc);border:1px solid var(--bdc);color:var(--c);gap:var(--s10);place-content:center;place-items:center;text-decoration:none}.c--button--outline{--c:var(--text);--bgc:transparent;--bdc:var(--c)}}@layer lism.modules{}@layer lism.modules{:where(.c--button)>.a--icon{scale:1.05}.c--button:where(.l--grid){grid-template-columns:minmax(1em,auto) 1fr minmax(1em,auto);justify-items:center}.c--button:where(.l--grid)>:not(.a--icon){grid-column:2}}.-hov\:reverse{--hov-c:var(--bgc);--hov-bgc:var(--c)}.-hov\:reverse:where(.c--button--fill){--hov-bgc:transparent}.-hov\:reverse:where(.c--button--outline){--hov-c:var(--base)}@media (any-hover:hover){.-hov\:reverse:hover{background-color:var(--hov-bgc)!important;color:var(--hov-c)!important}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lism-css/ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "UI components by lism-css.",
5
5
  "author": {
6
6
  "name": "ddryo",
@@ -39,7 +39,7 @@
39
39
  "url": "https://github.com/lism-css/lism-css/issues"
40
40
  },
41
41
  "dependencies": {
42
- "lism-css": "0.8.0"
42
+ "lism-css": "0.8.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@babel/cli": "^7.27.2",
@@ -1,6 +1,6 @@
1
1
  @layer lism.modules {
2
2
  .d--accordion {
3
- --duration: var(--acc-duration, 0.4s);
3
+ --duration: var(--acc-duration, 0.25s);
4
4
  }
5
5
  .d--accordion[data-opened] {
6
6
  --_notOpen: ;
@@ -14,7 +14,7 @@
14
14
  grid: auto / 1fr auto;
15
15
  gap: 0.5em;
16
16
  align-items: center;
17
- outline-offset: -1px; /* overflow:clip|hidden; で見えなくなってしまうのを防ぐ */
17
+ --focus-offset: -1px; /* overflow:hidden; で見えなくなってしまいがちなので内側に寄せておく */
18
18
 
19
19
  /* Safariで表示されるデフォルトの三角形アイコンを消す */
20
20
  &::-webkit-details-marker {
@@ -47,8 +47,8 @@
47
47
  }
48
48
 
49
49
  /* .d--accordion_icon 自体にborderつけたりすると回転が見えてしまうので、中にある .a--icon を回転させる。 */
50
- .d--accordion_icon .a--icon {
51
- transition-duration: var(--duration);
52
- rotate: var(--_isOpen, -180deg);
50
+ .d--accordion_icon > .a--icon {
51
+ transition: transform var(--duration);
52
+ transform: var(--_isOpen, scaleY(-1));
53
53
  }
54
54
  }
@@ -7,9 +7,6 @@ import AccIcon from './AccIcon';
7
7
 
8
8
  import '../_style.css';
9
9
 
10
- // import { AccContext } from './context';
11
-
12
- // duration: [s]
13
10
  export function Accordion({ children, ...props }) {
14
11
  const ref = React.useRef(null);
15
12
 
@@ -22,12 +19,10 @@ export function Accordion({ children, ...props }) {
22
19
 
23
20
  return (
24
21
  <details ref={ref} {...lismProps}>
25
- {/* <AccContext.Provider value={deliverState}>{children}</AccContext.Provider> */}
26
22
  {children}
27
23
  </details>
28
24
  );
29
25
  }
30
-
31
26
  export function Header({ children, ...props }) {
32
27
  return (
33
28
  <Lism tag='summary' {...defaultProps.header} {...props}>
@@ -42,7 +37,6 @@ export function Label({ children, ...props }) {
42
37
  </Lism>
43
38
  );
44
39
  }
45
-
46
40
  export function Body({ children, flow, innerProps, ...props }) {
47
41
  return (
48
42
  <Lism {...defaultProps.body} {...props}>
@@ -1,99 +1,112 @@
1
- // open 属性付与からクラスの付与まで、ほんの少しだけ遅らせた方が動作が安定する
2
- const DELAY = 5;
1
+ // アニメーションが完了するのを待つ
2
+ const waitAnimation = (details) => {
3
+ // アニメーション対象の要素を直接取得.(getAnimations({subtree: true}) は iOS Safari で動作しない場合があるので __body を直接監視)
4
+ const body = details.querySelector('.d--accordion_body');
5
+ const animations = body ? body.getAnimations() : [];
3
6
 
4
- // モーダルのアニメーションが完了するのを待つ.
5
- const waitAnimation = (element) => {
6
- return Promise.all(element.getAnimations().map((a) => a.finished));
7
+ // allSettled を使うことで、キャンセル時も reject せずに完了する
8
+ return Promise.allSettled(animations.map((a) => a.finished));
7
9
  };
8
10
 
9
11
  // animationTime: [ms]
10
- const clickedEvent = async (details, force = false) => {
11
- // アニメーション中かどうか
12
- if (details.dataset.animating && !force) return;
13
- details.dataset.animating = '1';
12
+ const open = async (details) => {
13
+ // すでに開いている場合は何もしない
14
+ if (details.open && details.hasAttribute('data-opened')) return;
14
15
 
15
- const body = details.querySelector('.d--accordion_body');
16
+ // open属性をセット
17
+ details.open = true;
16
18
 
17
- // オープン / クローズ 処理
18
- if (!details.open) {
19
- details.open = true;
20
- // 少しだけ遅らせた方が動作が安定する
21
- setTimeout(async () => {
22
- details.setAttribute('data-opened', ''); // クラスの追加
23
-
24
- // アニメーション完了後に dataset を除去。
25
- await waitAnimation(body);
26
- delete details.dataset.animating;
27
- }, DELAY);
28
- } else if (details.open) {
29
- details.removeAttribute('data-opened'); // クラスを削除
19
+ // 次フレームで data-opened 属性を付与(CSS側でフェードインアニメーション開始)
20
+ requestAnimationFrame(() => {
21
+ details.setAttribute('data-opened', ''); // 属性の追加
22
+ });
23
+ };
24
+
25
+ const close = async (details) => {
26
+ // すでに閉じている場合は何もしない
27
+ if (!details.open && !details.hasAttribute('data-opened')) return;
28
+
29
+ details.removeAttribute('data-opened'); // 属性を削除
30
30
 
31
- // アニメーション完了後に open属性 を除去。
32
- await waitAnimation(body);
31
+ // アニメーションを待つ
32
+ await waitAnimation(details);
33
33
 
34
- delete details.dataset.animating;
35
- details.open = false;
34
+ // アニメーション完了後にopen属性 を除去。
35
+ details.open = false;
36
+ };
37
+
38
+ // 複数展開を許可するかどうかを、親要素の [data-multiple] でチェック.
39
+ const getAllowMultiple = (details) => {
40
+ let allowMultiple = false;
41
+ const parent = details.parentNode;
42
+ if (null != parent) {
43
+ const dataMultiple = parent.dataset.multiple;
44
+ allowMultiple = 'disallow' !== dataMultiple;
36
45
  }
46
+ return allowMultiple;
37
47
  };
38
48
 
39
- const toggleEvent = (e, details) => {
40
- // e.preventDefault();
41
- // console.log('toggleEvent', e.target, e.currentTarget);
49
+ const onClick = (details, allowMultiple) => {
50
+ if (!details.open) {
51
+ if (!allowMultiple) {
52
+ // (複数展開が禁止されている場合)他の開いているアイテムがあるかどうかを先に探して閉じる
53
+ const parent = details.parentNode;
54
+ const openedItem = parent.querySelector(`[data-opened]`);
55
+ requestAnimationFrame(() => {
56
+ // 1フレーム待機(safariでは requestAnimationFrame() がないと動かなかった)
57
+ if (null != openedItem) close(openedItem);
58
+ });
59
+ }
60
+
61
+ // 開く処理
62
+ open(details);
63
+ } else if (details.open) {
64
+ // 閉じる処理
65
+ close(details);
66
+ }
67
+ };
42
68
 
69
+ const onToggle = (details) => {
43
70
  const hasOpen = details.open;
44
- const hasOpenedClass = details.hasAttribute('data-opened');
71
+ const hasDataOpen = details.hasAttribute('data-opened');
45
72
 
46
- // open はセットされたのに data-opened がついてない時
47
- if (hasOpen && !hasOpenedClass) {
73
+ // open はセットされたのに data-opened 属性がついてない時
74
+ if (hasOpen && !hasDataOpen) {
48
75
  details.setAttribute('data-opened', '');
49
76
  }
50
- // open は削除されたのに data-opened がまだついている時
51
- if (!hasOpen && hasOpenedClass) {
77
+ // open は削除されたのに data-opened 属性がまだついている時
78
+ if (!hasOpen && hasDataOpen) {
52
79
  details.removeAttribute('data-opened');
53
80
  }
54
81
  };
55
82
 
56
- export const setEvent = (currentRef) => {
57
- const details = currentRef;
58
- // トリガーが明示的に指定されていない場合は、<summary> 要素をトリガーとする
59
- const clickBtn = details.querySelector(`[data-role="trigger"]`) || details.querySelector('summary');
83
+ export const setEvent = (details) => {
84
+ // 複数展開を制限するかどうか
85
+ const allowMultiple = getAllowMultiple(details);
60
86
 
61
- if (!clickBtn) return;
87
+ // <summary> 要素をトリガーとする
88
+ const summary = details.querySelector('summary');
89
+ if (!summary) return;
62
90
 
63
- // 複数展開を許可するかどうかを、親要素の [data-accordion-multiple] でチェック.
64
- let allowMultiple = false;
65
- const parent = details.parentNode;
66
- if (null != parent) {
67
- const dataMultiple = parent.dataset.accordionMultiple;
68
- allowMultiple = 'disallow' !== dataMultiple;
69
- }
70
-
71
- const _clickedEvent = (e) => {
91
+ const _clickEvent = (e) => {
72
92
  // すぐに open 属性が切り替わらないようにする
73
93
  e.preventDefault();
74
-
75
- // 複数展開が禁止されている場合、(開く処理の直前で)他の開いているアイテムがあれば閉じる
76
- if (!allowMultiple && !details.open) {
77
- const openedItem = parent.querySelector(`[data-opened]`);
78
- if (null != openedItem) clickedEvent(openedItem, true);
79
- }
80
-
81
- // 自身のクリック処理
82
- clickedEvent(details);
94
+ onClick(details, allowMultiple);
83
95
  };
84
- const _toggleEvent = (e) => {
85
- toggleEvent(e, details);
96
+ const _toggleEvent = () => {
97
+ onToggle(details);
86
98
  };
87
99
 
88
100
  // <summary> 'click' イベント
89
- clickBtn.addEventListener('click', _clickedEvent);
101
+ summary.addEventListener('click', _clickEvent);
90
102
 
91
103
  // <details> の'toggle' イベントで、ページ内検索時にも開閉されるようにする
92
104
  details.addEventListener('toggle', _toggleEvent);
93
105
 
94
- // useEffectでアンマウントされた時にremoveEventListenerしないと2重でイベントが登録してしまう。
106
+ // react用
95
107
  return () => {
96
- clickBtn.removeEventListener('click', _clickedEvent);
108
+ // useEffect でアンマウントされた時にremoveEventListenerしないと2重でイベントが登録してしまう。
109
+ summary.removeEventListener('click', _clickEvent);
97
110
  details.removeEventListener('toggle', _toggleEvent);
98
111
  };
99
112
  };
@@ -0,0 +1,2 @@
1
+ /* Avatar component styles */
2
+ /* このコンポーネントは現時点でカスタムスタイルを必要としません */
@@ -0,0 +1,10 @@
1
+ ---
2
+ import { Frame } from 'lism-css/astro';
3
+ // import '../_style.css';
4
+
5
+ const { size = '1.5em', src = '', alt = '', ...props } = Astro.props;
6
+ ---
7
+
8
+ <Frame lismClass='c--avatar' ar='1/1' w={size} bdrs='99' {...props}>
9
+ <img src={src} alt={alt} width='100%' height='100%' decoding='async' />
10
+ </Frame>
@@ -0,0 +1 @@
1
+ export { default } from './Avatar.astro';
@@ -0,0 +1,10 @@
1
+ import { Frame } from 'lism-css/react';
2
+ // import '../_style.css';
3
+
4
+ export default function Avatar({ size = '1.5em', src = '', alt = '', ...props }) {
5
+ return (
6
+ <Frame lismClass='c--avatar' ar='1/1' w={size} bdrs='99' {...props}>
7
+ <img src={src} alt={alt} width='100%' height='100%' decoding='async' />
8
+ </Frame>
9
+ );
10
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Avatar';
@@ -0,0 +1,15 @@
1
+ @layer lism.modules {
2
+ .c--badge {
3
+ --c: var(--base);
4
+ --bgc: var(--text);
5
+ --bdc: transparent;
6
+ color: var(--c);
7
+ background-color: var(--bgc);
8
+ border: solid 1px var(--bdc); /* 異なる variant を並べてもサイズに差が出ないようにborderを常に指定 */
9
+ }
10
+ .c--badge--outline {
11
+ --c: var(--text);
12
+ --bgc: transparent;
13
+ --bdc: currentColor;
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { Lism } from 'lism-css/astro';
3
+ import '../_style.css';
4
+
5
+ const props = Astro.props;
6
+
7
+ // c--badge では c, bgc は 変数で受け取る
8
+ const _propConfig = {
9
+ c: { isVar: 1 },
10
+ bgc: { isVar: 1 },
11
+ };
12
+ ---
13
+
14
+ <Lism lismClass='c--badge' tag='span' d='inline-flex' fz='xs' lh='xs' py='5' px='10' bdrs='10' _propConfig={_propConfig} {...props}>
15
+ <slot />
16
+ </Lism>
@@ -0,0 +1 @@
1
+ export { default } from './Badge.astro';
@@ -0,0 +1,14 @@
1
+ import { Lism } from 'lism-css/react';
2
+ import '../_style.css';
3
+
4
+ export default function Badge(props) {
5
+ // c--badge では c, bgc は 変数で受け取る
6
+ const _propConfig = {
7
+ c: { isVar: 1 },
8
+ bgc: { isVar: 1 },
9
+ };
10
+
11
+ return (
12
+ <Lism lismClass='c--badge' tag='span' d='inline-flex' fz='xs' lh='xs' py='5' px='10' bdrs='10' _propConfig={_propConfig} {...props} />
13
+ );
14
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Badge';
@@ -0,0 +1,54 @@
1
+ @layer lism.modules {
2
+ .c--button {
3
+ --c: var(--base);
4
+ --bgc: var(--text);
5
+ --bdc: var(--bgc);
6
+
7
+ color: var(--c);
8
+ background-color: var(--bgc);
9
+ border: solid 1px var(--bdc); /* 異なる variant を並べてもサイズに差が出ないようにborderを常に指定 */
10
+
11
+ gap: var(--s10);
12
+ text-decoration: none;
13
+ place-content: center;
14
+ place-items: center;
15
+ }
16
+ .c--button--outline {
17
+ --c: var(--text);
18
+ --bgc: transparent;
19
+ --bdc: var(--c);
20
+ }
21
+
22
+ :where(.c--button) > .a--icon {
23
+ scale: 1.05;
24
+ }
25
+
26
+ /* l--gridを使用する場合の追加スタイル */
27
+ .c--button:where(.l--grid) {
28
+ grid-template-columns: minmax(1em, auto) 1fr minmax(1em, auto);
29
+ justify-items: center;
30
+ }
31
+ .c--button:where(.l--grid) > :not(.a--icon) {
32
+ grid-column: 2;
33
+ }
34
+ }
35
+
36
+ /* --------------------
37
+ reverse
38
+ -------------------- */
39
+ .-hov\:reverse {
40
+ --hov-c: var(--bgc);
41
+ --hov-bgc: var(--c);
42
+ }
43
+ .-hov\:reverse:where(.c--button--fill) {
44
+ --hov-bgc: transparent;
45
+ }
46
+ .-hov\:reverse:where(.c--button--outline) {
47
+ --hov-c: var(--base);
48
+ }
49
+ @media (any-hover: hover) {
50
+ .-hov\:reverse:hover {
51
+ background-color: var(--hov-bgc) !important;
52
+ color: var(--hov-c) !important;
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { Flex } from 'lism-css/astro';
3
+ import '../_style.css';
4
+
5
+ const props = Astro.props;
6
+
7
+ // c--button では c, bgc は 変数で受け取る
8
+ const _propConfig = {
9
+ c: { isVar: 1 },
10
+ bgc: { isVar: 1 },
11
+ };
12
+ ---
13
+
14
+ <Flex lismClass='c--button' tag='a' lh='s' py='10' px='20' hov='o' _propConfig={_propConfig} {...props}>
15
+ <slot />
16
+ </Flex>
@@ -0,0 +1 @@
1
+ export { default } from './Button.astro';
@@ -0,0 +1,14 @@
1
+ import { Flex } from 'lism-css/react';
2
+ import '../_style.css';
3
+
4
+ export default function Button(props) {
5
+ // c--button では c, bgc は 変数で受け取る
6
+ const _propConfig = {
7
+ c: { isVar: 1 },
8
+ bgc: { isVar: 1 },
9
+ };
10
+
11
+ return (
12
+ <Flex lismClass='c--button' tag='a' lh='s' py='10' px='20' hov='o' _propConfig={_propConfig} {...props} />
13
+ );
14
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Button';
@@ -1,3 +1,6 @@
1
1
  export { default as Accordion } from './Accordion/astro';
2
+ export { default as Avatar } from './Avatar/astro';
3
+ export { default as Badge } from './Badge/astro';
4
+ export { default as Button } from './Button/astro';
2
5
  export { default as Modal } from './Modal/astro';
3
6
  export { default as Tabs } from './Tabs/astro';
@@ -1,3 +1,6 @@
1
1
  export { default as Accordion } from './Accordion/react';
2
+ export { default as Avatar } from './Avatar/react';
3
+ export { default as Badge } from './Badge/react';
4
+ export { default as Button } from './Button/react';
2
5
  export { default as Modal } from './Modal/react';
3
6
  export { default as Tabs } from './Tabs/react';
package/src/style.scss CHANGED
@@ -1 +1,4 @@
1
- @use './components/Accordion/_style.css';
1
+ @use './components/Accordion/_style.css' as accordion;
2
+ @use './components/Avatar/_style.css' as avatar;
3
+ @use './components/Badge/_style.css' as badge;
4
+ @use './components/Button/_style.css' as button;