@lism-css/ui 0.9.3 → 0.11.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 (127) hide show
  1. package/README.ja.md +137 -0
  2. package/README.md +93 -5
  3. package/dist/components/Callout/getProps.d.ts +0 -1
  4. package/dist/components/Callout/getProps.js +11 -12
  5. package/dist/components/Chat/getProps.js +1 -6
  6. package/dist/components/DummyImage/astro/index.d.ts +1 -0
  7. package/dist/components/DummyImage/react/DummyImage.d.ts +2 -0
  8. package/dist/components/DummyImage/react/DummyImage.js +8 -0
  9. package/dist/components/DummyImage/react/index.d.ts +1 -0
  10. package/dist/components/DummyText/astro/index.d.ts +1 -0
  11. package/dist/components/DummyText/getContent.d.ts +11 -0
  12. package/dist/components/DummyText/getContent.js +9 -0
  13. package/dist/components/DummyText/react/DummyText.d.ts +10 -0
  14. package/dist/components/DummyText/react/DummyText.js +10 -0
  15. package/dist/components/DummyText/react/index.d.ts +1 -0
  16. package/dist/components/DummyText/texts.d.ts +22 -0
  17. package/dist/components/DummyText/texts.js +39 -0
  18. package/dist/components/NavMenu/getProps.js +2 -2
  19. package/dist/components/Tabs/react/Tab.js +1 -12
  20. package/dist/components/Tabs/react/Tabs.js +1 -3
  21. package/dist/components/astro.d.ts +2 -0
  22. package/dist/components/react.d.ts +2 -0
  23. package/dist/components/react.js +20 -16
  24. package/dist/lism-css/dist/components/atomic/Decorator/getProps.js +10 -10
  25. package/dist/lism-css/dist/components/atomic/Icon/getProps.js +28 -27
  26. package/dist/lism-css/dist/config/defaults/props.js +6 -1
  27. package/dist/lism-css/dist/config/defaults/states.js +1 -2
  28. package/dist/lism-css/dist/config/defaults/tokens.js +3 -3
  29. package/dist/lism-css/dist/lib/getMaybeCssVar.js +26 -21
  30. package/dist/style.css +1 -1
  31. package/dist/ui.css +1 -1
  32. package/package.json +5 -4
  33. package/src/components/Accordion/_style.css +69 -69
  34. package/src/components/Accordion/astro/Button.astro +2 -2
  35. package/src/components/Accordion/astro/Heading.astro +1 -1
  36. package/src/components/Accordion/astro/Item.astro +7 -7
  37. package/src/components/Accordion/astro/Panel.astro +3 -3
  38. package/src/components/Accordion/astro/Root.astro +3 -3
  39. package/src/components/Accordion/getProps.js +54 -54
  40. package/src/components/Accordion/react/AccIcon.jsx +1 -1
  41. package/src/components/Accordion/react/Accordion.jsx +34 -34
  42. package/src/components/Accordion/script.js +1 -1
  43. package/src/components/Accordion/setAccordion.js +93 -93
  44. package/src/components/Alert/astro/Alert.astro +6 -6
  45. package/src/components/Alert/getProps.ts +22 -22
  46. package/src/components/Alert/presets.ts +26 -26
  47. package/src/components/Alert/react/Alert.tsx +9 -9
  48. package/src/components/Avatar/astro/Avatar.astro +2 -2
  49. package/src/components/Avatar/react/Avatar.jsx +5 -5
  50. package/src/components/Badge/_style.css +14 -14
  51. package/src/components/Badge/astro/Badge.astro +4 -4
  52. package/src/components/Badge/react/Badge.jsx +6 -6
  53. package/src/components/Button/_style.css +29 -29
  54. package/src/components/Button/astro/Button.astro +4 -4
  55. package/src/components/Button/react/Button.jsx +6 -6
  56. package/src/components/Callout/astro/Callout.astro +13 -13
  57. package/src/components/Callout/getProps.ts +23 -24
  58. package/src/components/Callout/presets.ts +26 -26
  59. package/src/components/Callout/react/Callout.tsx +16 -16
  60. package/src/components/Chat/_style.css +49 -49
  61. package/src/components/Chat/astro/Chat.astro +27 -27
  62. package/src/components/Chat/getProps.js +40 -45
  63. package/src/components/Chat/react/Chat.jsx +17 -17
  64. package/src/components/Details/_style.css +39 -39
  65. package/src/components/Details/astro/Content.astro +3 -3
  66. package/src/components/Details/astro/Details.astro +1 -1
  67. package/src/components/Details/astro/Icon.astro +1 -1
  68. package/src/components/Details/astro/Summary.astro +2 -2
  69. package/src/components/Details/astro/Title.astro +1 -1
  70. package/src/components/Details/getProps.js +7 -7
  71. package/src/components/Details/react/Details.jsx +24 -24
  72. package/src/components/DummyImage/astro/DummyImage.astro +7 -0
  73. package/src/components/DummyImage/astro/index.ts +1 -0
  74. package/src/components/DummyImage/react/DummyImage.tsx +5 -0
  75. package/src/components/DummyImage/react/index.ts +1 -0
  76. package/src/components/DummyText/astro/DummyText.astro +9 -0
  77. package/src/components/DummyText/astro/index.ts +1 -0
  78. package/src/components/DummyText/getContent.ts +39 -0
  79. package/src/components/DummyText/react/DummyText.tsx +15 -0
  80. package/src/components/DummyText/react/index.ts +1 -0
  81. package/src/components/DummyText/texts.ts +39 -0
  82. package/src/components/Modal/_style.css +34 -34
  83. package/src/components/Modal/astro/Body.astro +1 -1
  84. package/src/components/Modal/astro/CloseBtn.astro +10 -10
  85. package/src/components/Modal/astro/Inner.astro +1 -1
  86. package/src/components/Modal/astro/Modal.astro +3 -3
  87. package/src/components/Modal/astro/OpenBtn.astro +1 -1
  88. package/src/components/Modal/getProps.js +19 -19
  89. package/src/components/Modal/react/Body.jsx +5 -5
  90. package/src/components/Modal/react/CloseBtn.jsx +13 -13
  91. package/src/components/Modal/react/Inner.jsx +1 -1
  92. package/src/components/Modal/react/Modal.jsx +10 -10
  93. package/src/components/Modal/react/OpenBtn.jsx +5 -5
  94. package/src/components/Modal/script.js +1 -1
  95. package/src/components/Modal/setModal.ts +92 -92
  96. package/src/components/NavMenu/_style.css +17 -17
  97. package/src/components/NavMenu/astro/Item.astro +1 -1
  98. package/src/components/NavMenu/astro/Link.astro +1 -1
  99. package/src/components/NavMenu/astro/Nest.astro +1 -1
  100. package/src/components/NavMenu/astro/Root.astro +1 -1
  101. package/src/components/NavMenu/getProps.js +28 -28
  102. package/src/components/NavMenu/react/NavMenu.jsx +4 -4
  103. package/src/components/ShapeDivider/_style.css +51 -51
  104. package/src/components/ShapeDivider/astro/ShapeDivider.astro +20 -20
  105. package/src/components/ShapeDivider/getProps.js +23 -23
  106. package/src/components/ShapeDivider/react/ShapeDivider.jsx +24 -24
  107. package/src/components/Tabs/_style.css +29 -29
  108. package/src/components/Tabs/astro/Tab.astro +2 -2
  109. package/src/components/Tabs/astro/TabItem.astro +1 -1
  110. package/src/components/Tabs/astro/TabList.astro +2 -2
  111. package/src/components/Tabs/astro/TabPanel.astro +2 -2
  112. package/src/components/Tabs/astro/Tabs.astro +20 -20
  113. package/src/components/Tabs/astro/transformTabitems.js +30 -30
  114. package/src/components/Tabs/getProps.js +4 -4
  115. package/src/components/Tabs/react/Tab.jsx +4 -12
  116. package/src/components/Tabs/react/TabItem.jsx +1 -1
  117. package/src/components/Tabs/react/TabList.jsx +2 -2
  118. package/src/components/Tabs/react/TabPanel.jsx +2 -2
  119. package/src/components/Tabs/react/Tabs.jsx +44 -46
  120. package/src/components/Tabs/script.js +4 -4
  121. package/src/components/Tabs/setTabs.js +70 -70
  122. package/src/components/astro.ts +2 -0
  123. package/src/components/react.ts +2 -0
  124. package/src/helper/animation.ts +10 -10
  125. package/src/helper/uuid.js +3 -3
  126. package/dist/lism-css/dist/components/getFilterProps.js +0 -23
  127. package/dist/lism-css/dist/components/setMaybeTransformStyles.js +0 -7
@@ -16,34 +16,34 @@ const AccordionContext = createContext(null);
16
16
  * 複数の AccordionItem をラップするルート要素
17
17
  */
18
18
  export function AccordionRoot({ children, ...props }) {
19
- const rootProps = getRootProps(props);
20
- return <Stack {...rootProps}>{children}</Stack>;
19
+ const rootProps = getRootProps(props);
20
+ return <Stack {...rootProps}>{children}</Stack>;
21
21
  }
22
22
 
23
23
  /**
24
24
  * 個別のアコーディオンアイテム(<div> ベース、setEvent で開閉イベントを登録)
25
25
  */
26
26
  export function AccordionItem({ children, ...props }) {
27
- const ref = useRef(null);
27
+ const ref = useRef(null);
28
28
 
29
- // コンポーネント単位でユニークIDを生成
30
- const accID = useId();
29
+ // コンポーネント単位でユニークIDを生成
30
+ const accID = useId();
31
31
 
32
- // マウント時に開閉イベントを登録(アンマウント時にクリーンアップ)
33
- useEffect(() => {
34
- if (!ref.current) return;
35
- return setEvent(ref.current);
36
- }, []);
32
+ // マウント時に開閉イベントを登録(アンマウント時にクリーンアップ)
33
+ useEffect(() => {
34
+ if (!ref.current) return;
35
+ return setEvent(ref.current);
36
+ }, []);
37
37
 
38
- const lismProps = getLismProps(getItemProps(props));
38
+ const lismProps = getLismProps(getItemProps(props));
39
39
 
40
- return (
41
- <AccordionContext.Provider value={{ accID }}>
42
- <div ref={ref} {...lismProps}>
43
- {children}
44
- </div>
45
- </AccordionContext.Provider>
46
- );
40
+ return (
41
+ <AccordionContext.Provider value={{ accID }}>
42
+ <div ref={ref} {...lismProps}>
43
+ {children}
44
+ </div>
45
+ </AccordionContext.Provider>
46
+ );
47
47
  }
48
48
 
49
49
  /**
@@ -51,7 +51,7 @@ export function AccordionItem({ children, ...props }) {
51
51
  * as に h2〜h6 を指定すると role は付与されない
52
52
  */
53
53
  export function Heading({ children, ...props }) {
54
- return <Lism {...getHeadingProps(props)}>{children}</Lism>;
54
+ return <Lism {...getHeadingProps(props)}>{children}</Lism>;
55
55
  }
56
56
 
57
57
  /**
@@ -59,27 +59,27 @@ export function Heading({ children, ...props }) {
59
59
  * accID: Context から取得できればそれを優先、なければ props / プレースホルダー
60
60
  */
61
61
  export function Button({ children, accID: _accID = '__LISM_ACC_ID__', ...props }) {
62
- const ctx = useContext(AccordionContext);
63
- const accID = ctx?.accID || _accID;
62
+ const ctx = useContext(AccordionContext);
63
+ const accID = ctx?.accID || _accID;
64
64
 
65
- return (
66
- <Lism {...defaultProps.button} {...props} aria-controls={accID} aria-expanded='false'>
67
- {children}
68
- <AccIcon />
69
- </Lism>
70
- );
65
+ return (
66
+ <Lism {...defaultProps.button} {...props} aria-controls={accID} aria-expanded="false">
67
+ {children}
68
+ <AccIcon />
69
+ </Lism>
70
+ );
71
71
  }
72
72
 
73
73
  /**
74
74
  * パネル
75
75
  */
76
76
  export function Panel({ children, ...props }) {
77
- const ctx = useContext(AccordionContext);
78
- const { panelProps, contentProps } = getPanelProps({ _contextID: ctx?.accID, ...props });
77
+ const ctx = useContext(AccordionContext);
78
+ const { panelProps, contentProps } = getPanelProps({ _contextID: ctx?.accID, ...props });
79
79
 
80
- return (
81
- <Lism {...panelProps}>
82
- <Lism {...contentProps}>{children}</Lism>
83
- </Lism>
84
- );
80
+ return (
81
+ <Lism {...panelProps}>
82
+ <Lism {...contentProps}>{children}</Lism>
83
+ </Lism>
84
+ );
85
85
  }
@@ -1,5 +1,5 @@
1
1
  import setAccordion from './setAccordion.js';
2
2
 
3
3
  document.addEventListener('DOMContentLoaded', function () {
4
- setAccordion();
4
+ setAccordion();
5
5
  });
@@ -5,142 +5,142 @@ let ACCORDION_HIDDEN_VALUE = 'until-found';
5
5
 
6
6
  // アコーディオン要素から必要な要素を取得
7
7
  const getAccordionElements = (accordionItem) => {
8
- const heading = accordionItem.querySelector('.c--accordion_heading');
9
- const panel = accordionItem.querySelector('.c--accordion_panel');
10
- return {
11
- heading,
12
- button: heading.querySelector('button'),
13
- panel,
14
- content: panel.querySelector('.c--accordion_content'),
15
- };
8
+ const heading = accordionItem.querySelector('.c--accordion_heading');
9
+ const panel = accordionItem.querySelector('.c--accordion_panel');
10
+ return {
11
+ heading,
12
+ button: heading.querySelector('button'),
13
+ panel,
14
+ content: panel.querySelector('.c--accordion_content'),
15
+ };
16
16
  };
17
17
 
18
18
  // 親に data-allow-multiple がついていなければ、展開中のアコーディオンを閉じる
19
19
  // Memo: 自身の除外処理はしていない( 開く動作の前に呼び出す & もし自分が含まれていても連打可能なため )
20
20
  const maybeCloseOpenedItems = (accordionItem) => {
21
- const parent = accordionItem.parentNode;
22
- if (!parent) return;
21
+ const parent = accordionItem.parentNode;
22
+ if (!parent) return;
23
23
 
24
- // 親の data-allow-multiple 属性の有無をチェック
25
- if (parent.hasAttribute('data-allow-multiple')) return;
24
+ // 親の data-allow-multiple 属性の有無をチェック
25
+ if (parent.hasAttribute('data-allow-multiple')) return;
26
26
 
27
- // 開いているアコーディオンを取得して閉じる
28
- parent.querySelectorAll(':scope > [data-opened]').forEach((_a) => closeAccordion(_a));
27
+ // 開いているアコーディオンを取得して閉じる
28
+ parent.querySelectorAll(':scope > [data-opened]').forEach((_a) => closeAccordion(_a));
29
29
  };
30
30
 
31
31
  async function openAccordion(accordionItem) {
32
- const { panel, content, button } = getAccordionElements(accordionItem);
32
+ const { panel, content, button } = getAccordionElements(accordionItem);
33
33
 
34
- // アニメーションがあれば一時停止
35
- maybePauseAnimation(panel);
34
+ // アニメーションがあれば一時停止
35
+ maybePauseAnimation(panel);
36
36
 
37
- // hidden を削除
38
- panel.removeAttribute('hidden');
37
+ // hidden を削除
38
+ panel.removeAttribute('hidden');
39
39
 
40
- // 1フレーム待機
41
- await waitFrame();
40
+ // 1フレーム待機
41
+ await waitFrame();
42
42
 
43
- // 次フレームで高さセット( 目標の高さ = content の高さ )
44
- accordionItem.style.setProperty('--_panel-h', `${content.offsetHeight}px`);
43
+ // 次フレームで高さセット( 目標の高さ = content の高さ )
44
+ accordionItem.style.setProperty('--_panel-h', `${content.offsetHeight}px`);
45
45
 
46
- // さらに1フレーム待機
47
- await waitFrame();
46
+ // さらに1フレーム待機
47
+ await waitFrame();
48
48
 
49
- // アニメーション開始
50
- accordionItem.setAttribute('data-opened', '');
51
- button.setAttribute('aria-expanded', 'true');
49
+ // アニメーション開始
50
+ accordionItem.setAttribute('data-opened', '');
51
+ button.setAttribute('aria-expanded', 'true');
52
52
 
53
- // アニメーションを待つ
54
- const status = await waitAnimation(panel);
53
+ // アニメーションを待つ
54
+ const status = await waitAnimation(panel);
55
55
 
56
- // アニメーションが最後まで完了した時、--_panel-h削除(高さセットしたままだとリサイズできない)
57
- if ('canceled' !== status) {
58
- accordionItem.style.removeProperty('--_panel-h');
59
- }
56
+ // アニメーションが最後まで完了した時、--_panel-h削除(高さセットしたままだとリサイズできない)
57
+ if ('canceled' !== status) {
58
+ accordionItem.style.removeProperty('--_panel-h');
59
+ }
60
60
  }
61
61
 
62
62
  async function closeAccordion(accordionItem) {
63
- const { panel, button } = getAccordionElements(accordionItem);
63
+ const { panel, button } = getAccordionElements(accordionItem);
64
64
 
65
- // アニメーションがあれば一時停止
66
- maybePauseAnimation(panel);
65
+ // アニメーションがあれば一時停止
66
+ maybePauseAnimation(panel);
67
67
 
68
- // 現在の高さを一旦セットする
69
- accordionItem.style.setProperty('--_panel-h', `${panel.offsetHeight}px`);
68
+ // 現在の高さを一旦セットする
69
+ accordionItem.style.setProperty('--_panel-h', `${panel.offsetHeight}px`);
70
70
 
71
- // 1フレーム待機
72
- await waitFrame();
71
+ // 1フレーム待機
72
+ await waitFrame();
73
73
 
74
- // 次フレームで属性を削除
75
- accordionItem.removeAttribute('data-opened');
76
- button.setAttribute('aria-expanded', 'false');
74
+ // 次フレームで属性を削除
75
+ accordionItem.removeAttribute('data-opened');
76
+ button.setAttribute('aria-expanded', 'false');
77
77
 
78
- // 変数削除して 0px へ向けてアニメーション開始
79
- accordionItem.style.removeProperty('--_panel-h');
78
+ // 変数削除して 0px へ向けてアニメーション開始
79
+ accordionItem.style.removeProperty('--_panel-h');
80
80
 
81
- // アニメーションを待つ
82
- const status = await waitAnimation(panel);
81
+ // アニメーションを待つ
82
+ const status = await waitAnimation(panel);
83
83
 
84
- // アニメーションが最後まで完了したら、hidden付与
85
- if ('canceled' !== status) {
86
- panel.setAttribute('hidden', ACCORDION_HIDDEN_VALUE);
87
- }
84
+ // アニメーションが最後まで完了したら、hidden付与
85
+ if ('canceled' !== status) {
86
+ panel.setAttribute('hidden', ACCORDION_HIDDEN_VALUE);
87
+ }
88
88
  }
89
89
 
90
90
  // アコーディオンのトグル処理
91
91
  function toggleAccordion(accordionItem) {
92
- if (accordionItem.hasAttribute('data-opened')) {
93
- // 自身を閉じる
94
- closeAccordion(accordionItem);
95
- } else {
96
- // 親に data-allow-multiple がついていなければ、他のアコーディオンを閉じる
97
- maybeCloseOpenedItems(accordionItem);
98
-
99
- // 自身を開く
100
- openAccordion(accordionItem);
101
- }
92
+ if (accordionItem.hasAttribute('data-opened')) {
93
+ // 自身を閉じる
94
+ closeAccordion(accordionItem);
95
+ } else {
96
+ // 親に data-allow-multiple がついていなければ、他のアコーディオンを閉じる
97
+ maybeCloseOpenedItems(accordionItem);
98
+
99
+ // 自身を開く
100
+ openAccordion(accordionItem);
101
+ }
102
102
  }
103
103
 
104
104
  /**
105
105
  * 個別のアコーディオンにイベントをセット(React用にクリーンアップ関数を返す)
106
106
  */
107
107
  export const setEvent = (accordionItem) => {
108
- const { button, panel } = getAccordionElements(accordionItem);
109
-
110
- // until-found のオン・オフが使い分けれるように、最初に初期値を取得
111
- if (panel.hasAttribute('hidden')) {
112
- ACCORDION_HIDDEN_VALUE = panel.getAttribute('hidden');
113
- }
114
-
115
- // clickイベント登録
116
- const _clickEvent = (e) => {
117
- e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
118
- toggleAccordion(accordionItem);
119
- };
120
-
121
- // beforematchイベント登録 (ページ検索時などはこっちが発火する)
122
- const _beforematchEvent = (e) => {
123
- e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
124
- toggleAccordion(accordionItem);
125
- };
126
-
127
- button.addEventListener('click', _clickEvent);
128
- panel.addEventListener('beforematch', _beforematchEvent);
129
-
130
- // react用: useEffect でアンマウントされた時にremoveEventListenerしないと2重でイベントが登録してしまう
131
- return () => {
132
- button.removeEventListener('click', _clickEvent);
133
- panel.removeEventListener('beforematch', _beforematchEvent);
134
- };
108
+ const { button, panel } = getAccordionElements(accordionItem);
109
+
110
+ // until-found のオン・オフが使い分けれるように、最初に初期値を取得
111
+ if (panel.hasAttribute('hidden')) {
112
+ ACCORDION_HIDDEN_VALUE = panel.getAttribute('hidden');
113
+ }
114
+
115
+ // clickイベント登録
116
+ const _clickEvent = (e) => {
117
+ e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
118
+ toggleAccordion(accordionItem);
119
+ };
120
+
121
+ // beforematchイベント登録 (ページ検索時などはこっちが発火する)
122
+ const _beforematchEvent = (e) => {
123
+ e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
124
+ toggleAccordion(accordionItem);
125
+ };
126
+
127
+ button.addEventListener('click', _clickEvent);
128
+ panel.addEventListener('beforematch', _beforematchEvent);
129
+
130
+ // react用: useEffect でアンマウントされた時にremoveEventListenerしないと2重でイベントが登録してしまう
131
+ return () => {
132
+ button.removeEventListener('click', _clickEvent);
133
+ panel.removeEventListener('beforematch', _beforematchEvent);
134
+ };
135
135
  };
136
136
 
137
137
  /**
138
138
  * ページ内の全アコーディオンにイベントをセット(Astro用)
139
139
  */
140
140
  const setAccordion = () => {
141
- const accordionAll = document.querySelectorAll('.c--accordion_item');
142
- accordionAll.forEach((accordionItem) => {
143
- setEvent(accordionItem);
144
- });
141
+ const accordionAll = document.querySelectorAll('.c--accordion_item');
142
+ accordionAll.forEach((accordionItem) => {
143
+ setEvent(accordionItem);
144
+ });
145
145
  };
146
146
  export default setAccordion;
@@ -8,10 +8,10 @@ const { icon, layout, flow, ...alertProps } = getAlertProps(Astro.props);
8
8
  ---
9
9
 
10
10
  <Lism layout={layout} {...alertProps}>
11
- <Center isSide={layout === 'sideMain'} c='keycolor' fz='xl' fxsh='0'>
12
- <Icon icon={icon} />
13
- </Center>
14
- <Flow flow={flow}>
15
- <slot />
16
- </Flow>
11
+ <Center isSide={layout === 'sideMain'} c="keycolor" fz="xl" fxsh="0">
12
+ <Icon icon={icon} />
13
+ </Center>
14
+ <Flow flow={flow}>
15
+ <slot />
16
+ </Flow>
17
17
  </Lism>
@@ -1,30 +1,30 @@
1
1
  import PRESETS from './presets';
2
2
 
3
3
  export type AlertProps = {
4
- type?: string;
5
- keycolor?: string;
6
- layout?: string;
7
- icon?: string;
8
- flow?: string;
9
- [key: string]: unknown;
4
+ type?: string;
5
+ keycolor?: string;
6
+ layout?: string;
7
+ icon?: string;
8
+ flow?: string;
9
+ [key: string]: unknown;
10
10
  };
11
11
 
12
12
  export default function getAlertProps({ type = 'alert', keycolor, layout = 'flex', icon, flow = 's', ...props }: AlertProps) {
13
- const presetData = type ? PRESETS[type] : null;
14
- const _icon = icon || presetData?.icon || 'info';
15
- const _color = keycolor || presetData?.color || 'currentColor';
13
+ const presetData = type ? PRESETS[type] : null;
14
+ const _icon = icon || presetData?.icon || 'info';
15
+ const _color = keycolor || presetData?.color || 'currentColor';
16
16
 
17
- return {
18
- icon: _icon,
19
- layout,
20
- flow,
21
- lismClass: 'c--alert u--cbox',
22
- keycolor: _color,
23
- ai: 'center',
24
- p: '15',
25
- g: '15',
26
- bd: true,
27
- bdrs: '10',
28
- ...props,
29
- };
17
+ return {
18
+ icon: _icon,
19
+ layout,
20
+ flow,
21
+ lismClass: 'c--alert u--cbox',
22
+ keycolor: _color,
23
+ ai: 'center',
24
+ p: '15',
25
+ g: '15',
26
+ bd: true,
27
+ bdrs: '10',
28
+ ...props,
29
+ };
30
30
  }
@@ -1,33 +1,33 @@
1
1
  type PresetData = {
2
- icon: string;
3
- color: string;
2
+ icon: string;
3
+ color: string;
4
4
  };
5
5
 
6
6
  const PRESETS: Record<string, PresetData> = {
7
- alert: {
8
- icon: 'alert',
9
- color: 'red',
10
- },
11
- point: {
12
- icon: 'lightbulb',
13
- color: 'orange',
14
- },
15
- warning: {
16
- icon: 'warning',
17
- color: 'yellow',
18
- },
19
- check: {
20
- icon: 'check-circle',
21
- color: 'green',
22
- },
23
- help: {
24
- icon: 'question',
25
- color: 'purple',
26
- },
27
- info: {
28
- icon: 'info',
29
- color: 'blue',
30
- },
7
+ alert: {
8
+ icon: 'alert',
9
+ color: 'red',
10
+ },
11
+ point: {
12
+ icon: 'lightbulb',
13
+ color: 'orange',
14
+ },
15
+ warning: {
16
+ icon: 'warning',
17
+ color: 'yellow',
18
+ },
19
+ check: {
20
+ icon: 'check-circle',
21
+ color: 'green',
22
+ },
23
+ help: {
24
+ icon: 'question',
25
+ color: 'purple',
26
+ },
27
+ info: {
28
+ icon: 'info',
29
+ color: 'blue',
30
+ },
31
31
  };
32
32
 
33
33
  export default PRESETS;
@@ -3,14 +3,14 @@ import { Flow, Lism, Center, Icon } from 'lism-css/react';
3
3
  import getAlertProps, { type AlertProps } from '../getProps';
4
4
 
5
5
  export default function Alert({ children, ...inputProps }: AlertProps & { children?: ReactNode }) {
6
- const { icon, layout, flow, ...alertProps } = getAlertProps(inputProps);
6
+ const { icon, layout, flow, ...alertProps } = getAlertProps(inputProps);
7
7
 
8
- return (
9
- <Lism layout={layout} {...alertProps}>
10
- <Center isSide={layout === 'sideMain'} c='keycolor' fz='xl' fxsh='0'>
11
- <Icon icon={icon} />
12
- </Center>
13
- <Flow flow={flow}>{children}</Flow>
14
- </Lism>
15
- );
8
+ return (
9
+ <Lism layout={layout} {...alertProps}>
10
+ <Center isSide={layout === 'sideMain'} c="keycolor" fz="xl" fxsh="0">
11
+ <Icon icon={icon} />
12
+ </Center>
13
+ <Flow flow={flow}>{children}</Flow>
14
+ </Lism>
15
+ );
16
16
  }
@@ -4,6 +4,6 @@ import { Frame } from 'lism-css/astro';
4
4
  const { size = '1.5em', src = '', alt = '', ...props } = Astro.props;
5
5
  ---
6
6
 
7
- <Frame lismClass='c--avatar' ar='1/1' w={size} bdrs='99' {...props}>
8
- <img src={src} alt={alt} width='100%' height='100%' decoding='async' />
7
+ <Frame lismClass="c--avatar" ar="1/1" w={size} bdrs="99" {...props}>
8
+ <img src={src} alt={alt} width="100%" height="100%" decoding="async" />
9
9
  </Frame>
@@ -1,9 +1,9 @@
1
1
  import { Frame } from 'lism-css/react';
2
2
 
3
3
  export default function Avatar({ size = '1.5em', src = '', alt = '', ...props }) {
4
- return (
5
- <Frame lismClass='c--avatar' ar='1/1' w={size} bdrs='99' {...props}>
6
- <img src={src} alt={alt} width='100%' height='100%' decoding='async' />
7
- </Frame>
8
- );
4
+ return (
5
+ <Frame lismClass="c--avatar" ar="1/1" w={size} bdrs="99" {...props}>
6
+ <img src={src} alt={alt} width="100%" height="100%" decoding="async" />
7
+ </Frame>
8
+ );
9
9
  }
@@ -1,15 +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
- }
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
15
  }
@@ -6,11 +6,11 @@ const props = Astro.props;
6
6
 
7
7
  // c--badge では c, bgc は 変数で受け取る
8
8
  const _propConfig = {
9
- c: { isVar: 1 },
10
- bgc: { isVar: 1 },
9
+ c: { isVar: 1 },
10
+ bgc: { isVar: 1 },
11
11
  };
12
12
  ---
13
13
 
14
- <Lism lismClass='c--badge' as='span' d='inline-flex' fz='xs' lh='xs' py='5' px='10' bdrs='10' _propConfig={_propConfig} {...props}>
15
- <slot />
14
+ <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" _propConfig={_propConfig} {...props}>
15
+ <slot />
16
16
  </Lism>
@@ -2,11 +2,11 @@ import { Lism } from 'lism-css/react';
2
2
  import '../_style.css';
3
3
 
4
4
  export default function Badge(props) {
5
- // c--badge では c, bgc は 変数で受け取る
6
- const _propConfig = {
7
- c: { isVar: 1 },
8
- bgc: { isVar: 1 },
9
- };
5
+ // c--badge では c, bgc は 変数で受け取る
6
+ const _propConfig = {
7
+ c: { isVar: 1 },
8
+ bgc: { isVar: 1 },
9
+ };
10
10
 
11
- return <Lism lismClass='c--badge' as='span' d='inline-flex' fz='xs' lh='xs' py='5' px='10' bdrs='10' _propConfig={_propConfig} {...props} />;
11
+ return <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" _propConfig={_propConfig} {...props} />;
12
12
  }