@lism-css/ui 0.11.0 → 0.13.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 +1 -1
- package/dist/components/Accordion/Accordion.stories.d.ts +7 -0
- package/dist/components/Accordion/getProps.d.ts +55 -42
- package/dist/components/Accordion/getProps.js +36 -32
- package/dist/components/Accordion/react/AccIcon.d.ts +2 -1
- package/dist/components/Accordion/react/Accordion.d.ts +12 -21
- package/dist/components/Accordion/react/Accordion.js +30 -29
- package/dist/components/Accordion/react/index.d.ts +10 -11
- package/dist/components/Accordion/setAccordion.d.ts +6 -3
- package/dist/components/Accordion/setAccordion.js +12 -10
- package/dist/components/Alert/Alert.stories.d.ts +13 -0
- package/dist/components/Alert/getProps.d.ts +6 -4
- package/dist/components/Alert/react/Alert.d.ts +3 -4
- package/dist/components/Alert/react/Alert.js +2 -2
- package/dist/components/Avatar/Avatar.stories.d.ts +8 -0
- package/dist/components/Avatar/react/Avatar.d.ts +10 -6
- package/dist/components/Avatar/react/Avatar.js +1 -1
- package/dist/components/Badge/Badge.stories.d.ts +8 -0
- package/dist/components/Badge/react/Badge.d.ts +3 -1
- package/dist/components/Badge/react/Badge.js +5 -8
- package/dist/components/Button/Button.stories.d.ts +8 -0
- package/dist/components/Button/react/Button.d.ts +3 -1
- package/dist/components/Button/react/Button.js +3 -6
- package/dist/components/Callout/Callout.stories.d.ts +12 -0
- package/dist/components/Callout/getProps.d.ts +3 -2
- package/dist/components/Callout/react/Callout.d.ts +3 -4
- package/dist/components/Callout/react/Callout.js +4 -4
- package/dist/components/Chat/Chat.stories.d.ts +9 -0
- package/dist/components/Chat/getProps.d.ts +43 -44
- package/dist/components/Chat/getProps.js +2 -2
- package/dist/components/Chat/react/Chat.d.ts +11 -7
- package/dist/components/Chat/react/Chat.js +10 -10
- package/dist/components/Details/Details.stories.d.ts +6 -0
- package/dist/components/Details/getProps.d.ts +34 -35
- package/dist/components/Details/getProps.js +17 -7
- package/dist/components/Details/react/Details.d.ts +11 -20
- package/dist/components/Details/react/Details.js +15 -15
- package/dist/components/Details/react/index.d.ts +7 -7
- package/dist/components/DummyImage/DummyImage.stories.d.ts +7 -0
- package/dist/components/DummyText/DummyText.stories.d.ts +9 -0
- package/dist/components/Modal/Modal.stories.d.ts +6 -0
- package/dist/components/Modal/getProps.d.ts +35 -36
- package/dist/components/Modal/getProps.js +34 -15
- package/dist/components/Modal/react/Body.d.ts +2 -4
- package/dist/components/Modal/react/CloseBtn.d.ts +9 -7
- package/dist/components/Modal/react/CloseBtn.js +5 -5
- package/dist/components/Modal/react/Inner.d.ts +3 -4
- package/dist/components/Modal/react/Modal.d.ts +4 -4
- package/dist/components/Modal/react/Modal.js +11 -9
- package/dist/components/Modal/react/OpenBtn.d.ts +7 -5
- package/dist/components/Modal/react/OpenBtn.js +4 -4
- package/dist/components/Modal/react/index.d.ts +7 -8
- package/dist/components/NavMenu/NavMenu.stories.d.ts +7 -0
- package/dist/components/NavMenu/getProps.d.ts +31 -29
- package/dist/components/NavMenu/react/NavMenu.d.ts +6 -16
- package/dist/components/NavMenu/react/NavMenu.js +21 -17
- package/dist/components/NavMenu/react/index.d.ts +6 -6
- package/dist/components/ShapeDivider/ShapeDivider.stories.d.ts +10 -0
- package/dist/components/ShapeDivider/getProps.d.ts +16 -11
- package/dist/components/ShapeDivider/getProps.js +10 -12
- package/dist/components/ShapeDivider/react/ShapeDivider.d.ts +3 -4
- package/dist/components/ShapeDivider/react/ShapeDivider.js +3 -3
- package/dist/components/Tabs/Tabs.stories.d.ts +6 -0
- package/dist/components/Tabs/getProps.d.ts +11 -4
- package/dist/components/Tabs/getProps.js +15 -5
- package/dist/components/Tabs/react/Tab.d.ts +8 -6
- package/dist/components/Tabs/react/Tab.js +15 -6
- package/dist/components/Tabs/react/TabItem.d.ts +7 -4
- package/dist/components/Tabs/react/TabList.d.ts +2 -1
- package/dist/components/Tabs/react/TabPanel.d.ts +8 -6
- package/dist/components/Tabs/react/Tabs.d.ts +9 -7
- package/dist/components/Tabs/react/Tabs.js +50 -36
- package/dist/components/Tabs/react/index.d.ts +8 -8
- package/dist/components/Tabs/setTabs.d.ts +1 -1
- package/dist/components/Tabs/setTabs.js +25 -15
- package/dist/lism-css/dist/components/{Center → layout/Center}/index.js +1 -1
- package/dist/lism-css/dist/components/{Flex → layout/Flex}/index.js +1 -1
- package/dist/lism-css/dist/components/{Flow → layout/Flow}/index.js +1 -1
- package/dist/lism-css/dist/components/{Frame → layout/Frame}/index.js +1 -1
- package/dist/lism-css/dist/components/{Grid → layout/Grid}/index.js +1 -1
- package/dist/lism-css/dist/components/{Stack → layout/Stack}/index.js +1 -1
- package/dist/lism-css/dist/config/default-config.js +6 -6
- package/dist/lism-css/dist/config/defaults/props.js +16 -26
- package/dist/lism-css/dist/config/defaults/traits.js +19 -0
- package/dist/lism-css/dist/config/index.js +9 -9
- package/dist/lism-css/dist/lib/getLayoutProps.js +6 -9
- package/dist/lism-css/dist/lib/getLismProps.js +116 -104
- package/dist/lism-css/dist/lib/helper/mergeSet.js +14 -0
- package/dist/style.css +1 -1
- package/dist/ui.css +1 -1
- package/package.json +14 -7
- package/src/components/Accordion/Accordion.stories.tsx +105 -0
- package/src/components/Accordion/_style.css +1 -1
- package/src/components/Accordion/astro/Button.astro +2 -2
- package/src/components/Accordion/getProps.ts +91 -0
- package/src/components/Accordion/react/{AccIcon.jsx → AccIcon.tsx} +2 -2
- package/src/components/Accordion/react/{Accordion.jsx → Accordion.tsx} +33 -11
- package/src/components/Accordion/setAccordion.ts +120 -0
- package/src/components/Alert/Alert.stories.tsx +64 -0
- package/src/components/Alert/getProps.ts +5 -3
- package/src/components/Alert/react/Alert.tsx +3 -3
- package/src/components/Avatar/Avatar.stories.tsx +42 -0
- package/src/components/Avatar/react/Avatar.tsx +17 -0
- package/src/components/Badge/Badge.stories.tsx +40 -0
- package/src/components/Badge/_style.css +1 -1
- package/src/components/Badge/astro/Badge.astro +1 -7
- package/src/components/Badge/react/Badge.tsx +7 -0
- package/src/components/Button/Button.stories.tsx +44 -0
- package/src/components/Button/_style.css +1 -1
- package/src/components/Button/astro/Button.astro +1 -7
- package/src/components/Button/react/Button.tsx +7 -0
- package/src/components/Callout/Callout.stories.tsx +55 -0
- package/src/components/Callout/getProps.ts +3 -2
- package/src/components/Callout/react/Callout.tsx +3 -3
- package/src/components/Chat/Chat.stories.tsx +58 -0
- package/src/components/Chat/_style.css +6 -6
- package/src/components/Chat/{getProps.js → getProps.ts} +10 -4
- package/src/components/Chat/react/{Chat.jsx → Chat.tsx} +13 -3
- package/src/components/Details/Details.stories.tsx +61 -0
- package/src/components/Details/_style.css +1 -1
- package/src/components/Details/astro/Title.astro +2 -2
- package/src/components/Details/{getProps.js → getProps.ts} +19 -6
- package/src/components/Details/react/Details.tsx +69 -0
- package/src/components/DummyImage/DummyImage.stories.tsx +23 -0
- package/src/components/DummyText/DummyText.stories.tsx +48 -0
- package/src/components/Modal/Modal.stories.tsx +67 -0
- package/src/components/Modal/_style.css +1 -1
- package/src/components/Modal/astro/CloseBtn.astro +2 -2
- package/src/components/Modal/astro/OpenBtn.astro +2 -3
- package/src/components/Modal/getProps.ts +64 -0
- package/src/components/Modal/react/Body.tsx +10 -0
- package/src/components/Modal/react/CloseBtn.tsx +24 -0
- package/src/components/Modal/react/Inner.tsx +6 -0
- package/src/components/Modal/react/Modal.tsx +24 -0
- package/src/components/Modal/react/OpenBtn.tsx +15 -0
- package/src/components/Modal/{script.js → script.ts} +1 -1
- package/src/components/NavMenu/NavMenu.stories.tsx +68 -0
- package/src/components/NavMenu/_style.css +1 -1
- package/src/components/NavMenu/getProps.ts +60 -0
- package/src/components/NavMenu/react/NavMenu.tsx +40 -0
- package/src/components/ShapeDivider/ShapeDivider.stories.tsx +87 -0
- package/src/components/ShapeDivider/_style.css +1 -1
- package/src/components/ShapeDivider/getProps.ts +36 -0
- package/src/components/ShapeDivider/react/{ShapeDivider.jsx → ShapeDivider.tsx} +4 -4
- package/src/components/Tabs/Tabs.stories.tsx +79 -0
- package/src/components/Tabs/_style.css +1 -1
- package/src/components/Tabs/astro/Tab.astro +2 -1
- package/src/components/Tabs/astro/{transformTabitems.js → transformTabitems.ts} +9 -9
- package/src/components/Tabs/getProps.ts +23 -0
- package/src/components/Tabs/react/Tab.tsx +21 -0
- package/src/components/Tabs/react/TabItem.tsx +13 -0
- package/src/components/Tabs/react/TabList.tsx +5 -0
- package/src/components/Tabs/react/{TabPanel.jsx → TabPanel.tsx} +8 -3
- package/src/components/Tabs/react/{Tabs.jsx → Tabs.tsx} +27 -12
- package/src/components/Tabs/{script.js → script.ts} +2 -2
- package/src/components/Tabs/setTabs.ts +65 -0
- package/src/helper/{uuid.js → uuid.ts} +2 -2
- package/src/vite-env.d.ts +1 -0
- package/dist/components/Accordion/astro/__setEvent.d.ts +0 -1
- package/dist/components/Accordion/astro/index.d.ts +0 -15
- package/dist/components/Alert/astro/index.d.ts +0 -1
- package/dist/components/Callout/astro/index.d.ts +0 -1
- package/dist/components/Details/astro/index.d.ts +0 -13
- package/dist/components/DummyImage/astro/index.d.ts +0 -1
- package/dist/components/DummyText/astro/index.d.ts +0 -1
- package/dist/components/Modal/astro/index.d.ts +0 -13
- package/dist/components/NavMenu/astro/index.d.ts +0 -11
- package/dist/components/Tabs/astro/index.d.ts +0 -13
- package/dist/components/Tabs/astro/transformTabitems.d.ts +0 -4
- package/dist/components/astro.d.ts +0 -14
- package/dist/lism-css/dist/config/defaults/states.js +0 -38
- package/dist/lism-css/dist/config/helper/getSvgUrl.js +0 -4
- package/src/components/Accordion/getProps.js +0 -77
- package/src/components/Accordion/setAccordion.js +0 -146
- package/src/components/Avatar/astro/index.js +0 -1
- package/src/components/Avatar/react/Avatar.jsx +0 -9
- package/src/components/Badge/astro/index.js +0 -1
- package/src/components/Badge/react/Badge.jsx +0 -12
- package/src/components/Button/astro/index.js +0 -1
- package/src/components/Button/react/Button.jsx +0 -12
- package/src/components/Chat/astro/index.js +0 -1
- package/src/components/Details/react/Details.jsx +0 -66
- package/src/components/Modal/getProps.js +0 -30
- package/src/components/Modal/react/Body.jsx +0 -10
- package/src/components/Modal/react/CloseBtn.jsx +0 -20
- package/src/components/Modal/react/Inner.jsx +0 -6
- package/src/components/Modal/react/Modal.jsx +0 -23
- package/src/components/Modal/react/OpenBtn.jsx +0 -11
- package/src/components/NavMenu/getProps.js +0 -65
- package/src/components/NavMenu/react/NavMenu.jsx +0 -19
- package/src/components/ShapeDivider/astro/index.js +0 -1
- package/src/components/ShapeDivider/getProps.js +0 -40
- package/src/components/Tabs/getProps.js +0 -8
- package/src/components/Tabs/react/Tab.jsx +0 -10
- package/src/components/Tabs/react/TabItem.jsx +0 -5
- package/src/components/Tabs/react/TabList.jsx +0 -6
- package/src/components/Tabs/setTabs.js +0 -87
- /package/src/components/Accordion/astro/{index.js → index.ts} +0 -0
- /package/src/components/Accordion/react/{index.js → index.ts} +0 -0
- /package/src/components/Accordion/{script.js → script.ts} +0 -0
- /package/{dist/components/Avatar/astro/index.d.ts → src/components/Avatar/astro/index.ts} +0 -0
- /package/src/components/Avatar/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Badge/astro/index.d.ts → src/components/Badge/astro/index.ts} +0 -0
- /package/src/components/Badge/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Button/astro/index.d.ts → src/components/Button/astro/index.ts} +0 -0
- /package/src/components/Button/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Chat/astro/index.d.ts → src/components/Chat/astro/index.ts} +0 -0
- /package/src/components/Chat/react/{index.js → index.ts} +0 -0
- /package/src/components/Details/astro/{index.js → index.ts} +0 -0
- /package/src/components/Details/react/{index.js → index.ts} +0 -0
- /package/src/components/Modal/astro/{index.js → index.ts} +0 -0
- /package/src/components/Modal/react/{index.js → index.ts} +0 -0
- /package/src/components/NavMenu/astro/{index.js → index.ts} +0 -0
- /package/src/components/NavMenu/react/{index.js → index.ts} +0 -0
- /package/{dist/components/ShapeDivider/astro/index.d.ts → src/components/ShapeDivider/astro/index.ts} +0 -0
- /package/src/components/ShapeDivider/react/{index.js → index.ts} +0 -0
- /package/src/components/Tabs/astro/{index.js → index.ts} +0 -0
- /package/src/components/Tabs/react/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import DummyImage from './react/DummyImage';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof DummyImage> = {
|
|
5
|
+
title: 'UI/DummyImage',
|
|
6
|
+
component: DummyImage,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof DummyImage>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
args: {},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const WithSize: Story = {
|
|
18
|
+
name: 'サイズ指定',
|
|
19
|
+
args: {
|
|
20
|
+
w: '300px',
|
|
21
|
+
h: '200px',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import DummyText from './react/DummyText';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof DummyText> = {
|
|
5
|
+
title: 'UI/DummyText',
|
|
6
|
+
component: DummyText,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
lang: { control: 'select', options: ['en', 'ja', 'ar'] },
|
|
10
|
+
length: { control: 'select', options: ['s', 'm', 'l'] },
|
|
11
|
+
offset: { control: 'number' },
|
|
12
|
+
pre: { control: 'text' },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof DummyText>;
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
lang: 'en',
|
|
22
|
+
length: 'm',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Japanese: Story = {
|
|
27
|
+
name: '日本語',
|
|
28
|
+
args: {
|
|
29
|
+
lang: 'ja',
|
|
30
|
+
length: 'm',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Short: Story = {
|
|
35
|
+
name: '短い(length: s)',
|
|
36
|
+
args: {
|
|
37
|
+
lang: 'en',
|
|
38
|
+
length: 's',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Long: Story = {
|
|
43
|
+
name: '長い(length: l)',
|
|
44
|
+
args: {
|
|
45
|
+
lang: 'en',
|
|
46
|
+
length: 'l',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { expect, userEvent, within, waitFor } from 'storybook/test';
|
|
3
|
+
import Modal from './react';
|
|
4
|
+
|
|
5
|
+
const meta: Meta = {
|
|
6
|
+
title: 'UI/Modal',
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<>
|
|
16
|
+
<Modal.OpenBtn modalId="story-modal-1">モーダルを開く</Modal.OpenBtn>
|
|
17
|
+
<Modal.Root id="story-modal-1">
|
|
18
|
+
<Modal.Inner>
|
|
19
|
+
<Modal.Body>
|
|
20
|
+
<p>モーダルのコンテンツです。</p>
|
|
21
|
+
</Modal.Body>
|
|
22
|
+
<Modal.CloseBtn modalId="story-modal-1">閉じる</Modal.CloseBtn>
|
|
23
|
+
</Modal.Inner>
|
|
24
|
+
</Modal.Root>
|
|
25
|
+
</>
|
|
26
|
+
),
|
|
27
|
+
play: async ({ canvasElement }) => {
|
|
28
|
+
const canvas = within(canvasElement);
|
|
29
|
+
|
|
30
|
+
const dialog = canvas.getByRole('dialog', { hidden: true });
|
|
31
|
+
const openBtn = canvas.getByRole('button', { name: 'モーダルを開く' });
|
|
32
|
+
|
|
33
|
+
// 初期状態: モーダルは閉じている
|
|
34
|
+
await expect(dialog).not.toHaveAttribute('open');
|
|
35
|
+
|
|
36
|
+
// 開くボタンをクリック
|
|
37
|
+
await userEvent.click(openBtn);
|
|
38
|
+
|
|
39
|
+
// モーダルが開いている
|
|
40
|
+
await waitFor(() => expect(dialog).toHaveAttribute('open'));
|
|
41
|
+
|
|
42
|
+
// 閉じるボタンをクリック
|
|
43
|
+
const closeBtn = within(dialog).getByRole('button', { name: '閉じる' });
|
|
44
|
+
await userEvent.click(closeBtn);
|
|
45
|
+
|
|
46
|
+
// モーダルが閉じている(アニメーション完了待ち)
|
|
47
|
+
await waitFor(() => expect(dialog).not.toHaveAttribute('open'), { timeout: 2000 });
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const WithTitle: Story = {
|
|
52
|
+
name: 'タイトル付き',
|
|
53
|
+
render: () => (
|
|
54
|
+
<>
|
|
55
|
+
<Modal.OpenBtn modalId="story-modal-2">モーダルを開く</Modal.OpenBtn>
|
|
56
|
+
<Modal.Root id="story-modal-2">
|
|
57
|
+
<Modal.Inner>
|
|
58
|
+
<Modal.Body>
|
|
59
|
+
<h2>モーダルタイトル</h2>
|
|
60
|
+
<p>モーダルのコンテンツです。</p>
|
|
61
|
+
</Modal.Body>
|
|
62
|
+
<Modal.CloseBtn modalId="story-modal-2">閉じる</Modal.CloseBtn>
|
|
63
|
+
</Modal.Inner>
|
|
64
|
+
</Modal.Root>
|
|
65
|
+
</>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
// import type { LismProps } from 'lism-css/types';
|
|
3
3
|
import { Lism, Icon } from 'lism-css/astro';
|
|
4
|
-
import {
|
|
4
|
+
import { getCloseBtnProps } from '../getProps';
|
|
5
5
|
|
|
6
6
|
// Propsの定義
|
|
7
7
|
// interface Props extends LismProps {}
|
|
8
8
|
const { modalId = '', icon, srText = 'Close', ...props } = Astro.props || {};
|
|
9
|
-
const btnProps =
|
|
9
|
+
const btnProps = getCloseBtnProps(props);
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
{
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
// import type { LismProps } from 'lism-css/types';
|
|
3
3
|
import { Lism } from 'lism-css/astro';
|
|
4
|
-
import {
|
|
4
|
+
import { getOpenBtnProps } from '../getProps';
|
|
5
5
|
|
|
6
6
|
// Propsの定義
|
|
7
7
|
// interface Props extends LismProps {}
|
|
8
8
|
const { modalId = '', ...props } = Astro.props || {};
|
|
9
|
-
const btnProps = { ...defaultProps.openBtn, ...props };
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
<Lism data-modal-open={modalId} {...
|
|
11
|
+
<Lism data-modal-open={modalId} {...getOpenBtnProps(props)}>
|
|
13
12
|
<slot />
|
|
14
13
|
</Lism>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import atts from 'lism-css/lib/helper/atts';
|
|
2
|
+
import mergeSet from 'lism-css/lib/helper/mergeSet';
|
|
3
|
+
|
|
4
|
+
export type ModalRootProps = {
|
|
5
|
+
lismClass?: string;
|
|
6
|
+
set?: string;
|
|
7
|
+
duration?: string;
|
|
8
|
+
style?: Record<string, string>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ModalInnerProps = {
|
|
13
|
+
lismClass?: string;
|
|
14
|
+
offset?: string;
|
|
15
|
+
style?: Record<string, string>;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function getProps({ lismClass = '', set, duration, style = {}, ...props }: ModalRootProps) {
|
|
20
|
+
const theProps = {
|
|
21
|
+
lismClass: atts(lismClass, 'c--modal'),
|
|
22
|
+
set: mergeSet('plain', set),
|
|
23
|
+
};
|
|
24
|
+
if (duration) {
|
|
25
|
+
style['--duration'] = duration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { as: 'dialog', ...theProps, style, ...props };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getInnerProps({ lismClass = '', offset, style = {}, ...props }: ModalInnerProps) {
|
|
32
|
+
if (offset) {
|
|
33
|
+
style['--offset'] = offset;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
lismClass: atts(lismClass, 'c--modal_inner'),
|
|
37
|
+
style,
|
|
38
|
+
...props,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getOpenBtnProps({ set, ...props }: Record<string, unknown>) {
|
|
43
|
+
return {
|
|
44
|
+
as: 'button',
|
|
45
|
+
set: mergeSet('plain', set),
|
|
46
|
+
hov: 'o',
|
|
47
|
+
d: 'inline-flex',
|
|
48
|
+
...props,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getCloseBtnProps({ set, ...props }: Record<string, unknown>) {
|
|
53
|
+
return {
|
|
54
|
+
as: 'button',
|
|
55
|
+
set: mergeSet('plain', set),
|
|
56
|
+
hov: 'o',
|
|
57
|
+
d: 'inline-flex',
|
|
58
|
+
...props,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const defaultProps = {
|
|
63
|
+
body: { lismClass: 'c--modal_body' },
|
|
64
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
2
|
+
import { defaultProps } from '../getProps';
|
|
3
|
+
|
|
4
|
+
export default function ModalBody({ children, ...props }: LismComponentProps) {
|
|
5
|
+
return (
|
|
6
|
+
<Lism {...defaultProps.body} {...props}>
|
|
7
|
+
{children}
|
|
8
|
+
</Lism>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import { Lism, Icon, type LismComponentProps, type IconProps } from 'lism-css/react';
|
|
3
|
+
import { getCloseBtnProps } from '../getProps';
|
|
4
|
+
|
|
5
|
+
type CloseBtnProps<T extends ElementType = 'button'> = LismComponentProps<T> & {
|
|
6
|
+
modalId?: string;
|
|
7
|
+
icon?: IconProps['icon'];
|
|
8
|
+
srText?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function CloseBtn<T extends ElementType = 'button'>({ children, modalId = '', icon, srText = 'Close', ...props }: CloseBtnProps<T>) {
|
|
12
|
+
return (
|
|
13
|
+
<Lism data-modal-close={modalId} {...(getCloseBtnProps(props as Record<string, unknown>) as object)}>
|
|
14
|
+
{children ? (
|
|
15
|
+
children
|
|
16
|
+
) : (
|
|
17
|
+
<>
|
|
18
|
+
<Icon icon={icon || 'x'} />
|
|
19
|
+
<span className="u--srOnly">{srText || 'Close'}</span>
|
|
20
|
+
</>
|
|
21
|
+
)}
|
|
22
|
+
</Lism>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
2
|
+
import { getInnerProps, type ModalInnerProps } from '../getProps';
|
|
3
|
+
|
|
4
|
+
export default function ModalInner({ children, ...props }: ModalInnerProps & LismComponentProps) {
|
|
5
|
+
return <Lism {...getInnerProps(props)}>{children}</Lism>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import type { ElementType } from 'react';
|
|
4
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
5
|
+
import { setEvent } from '../setModal';
|
|
6
|
+
import { getProps, type ModalRootProps } from '../getProps';
|
|
7
|
+
|
|
8
|
+
import '../_style.css';
|
|
9
|
+
|
|
10
|
+
const Modal = <T extends ElementType = 'dialog'>({ children, ...props }: ModalRootProps & LismComponentProps<T>) => {
|
|
11
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!ref?.current) return;
|
|
14
|
+
return setEvent(ref?.current);
|
|
15
|
+
}, [ref]);
|
|
16
|
+
|
|
17
|
+
const { as: modalAs, ...modalProps } = getProps(props);
|
|
18
|
+
return (
|
|
19
|
+
<Lism as={modalAs as ElementType} forwardedRef={ref} {...modalProps}>
|
|
20
|
+
{children}
|
|
21
|
+
</Lism>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export default Modal;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
3
|
+
import { getOpenBtnProps } from '../getProps';
|
|
4
|
+
|
|
5
|
+
type OpenBtnProps<T extends ElementType = 'button'> = LismComponentProps<T> & {
|
|
6
|
+
modalId?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function OpenBtn<T extends ElementType = 'button'>({ children, modalId = '', ...props }: OpenBtnProps<T>) {
|
|
10
|
+
return (
|
|
11
|
+
<Lism data-modal-open={modalId} {...(getOpenBtnProps(props as Record<string, unknown>) as object)}>
|
|
12
|
+
{children}
|
|
13
|
+
</Lism>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import NavMenu from './react';
|
|
3
|
+
|
|
4
|
+
const meta: Meta = {
|
|
5
|
+
title: 'UI/NavMenu',
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
render: () => (
|
|
14
|
+
<NavMenu.Root>
|
|
15
|
+
<NavMenu.Item>
|
|
16
|
+
<NavMenu.Link href="#">ホーム</NavMenu.Link>
|
|
17
|
+
</NavMenu.Item>
|
|
18
|
+
<NavMenu.Item>
|
|
19
|
+
<NavMenu.Link href="#">ブログ</NavMenu.Link>
|
|
20
|
+
</NavMenu.Item>
|
|
21
|
+
<NavMenu.Item>
|
|
22
|
+
<NavMenu.Link href="#">お問い合わせ</NavMenu.Link>
|
|
23
|
+
</NavMenu.Item>
|
|
24
|
+
</NavMenu.Root>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const WithNest: Story = {
|
|
29
|
+
name: 'ネスト(サブメニュー)付き',
|
|
30
|
+
render: () => (
|
|
31
|
+
<NavMenu.Root>
|
|
32
|
+
<NavMenu.Item>
|
|
33
|
+
<NavMenu.Link href="#">ホーム</NavMenu.Link>
|
|
34
|
+
</NavMenu.Item>
|
|
35
|
+
<NavMenu.Item>
|
|
36
|
+
<NavMenu.Link>サービス</NavMenu.Link>
|
|
37
|
+
<NavMenu.Nest>
|
|
38
|
+
<NavMenu.Item>
|
|
39
|
+
<NavMenu.Link href="#">サービス A</NavMenu.Link>
|
|
40
|
+
</NavMenu.Item>
|
|
41
|
+
<NavMenu.Item>
|
|
42
|
+
<NavMenu.Link href="#">サービス B</NavMenu.Link>
|
|
43
|
+
</NavMenu.Item>
|
|
44
|
+
</NavMenu.Nest>
|
|
45
|
+
</NavMenu.Item>
|
|
46
|
+
<NavMenu.Item>
|
|
47
|
+
<NavMenu.Link href="#">お問い合わせ</NavMenu.Link>
|
|
48
|
+
</NavMenu.Item>
|
|
49
|
+
</NavMenu.Root>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const WithHoverColor: Story = {
|
|
54
|
+
name: 'ホバーカラー指定',
|
|
55
|
+
render: () => (
|
|
56
|
+
<NavMenu.Root hovBgc="base-2" itemP="10">
|
|
57
|
+
<NavMenu.Item>
|
|
58
|
+
<NavMenu.Link href="#">ホーム</NavMenu.Link>
|
|
59
|
+
</NavMenu.Item>
|
|
60
|
+
<NavMenu.Item>
|
|
61
|
+
<NavMenu.Link href="#">ブログ</NavMenu.Link>
|
|
62
|
+
</NavMenu.Item>
|
|
63
|
+
<NavMenu.Item>
|
|
64
|
+
<NavMenu.Link href="#">お問い合わせ</NavMenu.Link>
|
|
65
|
+
</NavMenu.Item>
|
|
66
|
+
</NavMenu.Root>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NavMenu コンポーネントの共通プロパティ処理
|
|
3
|
+
*/
|
|
4
|
+
import getMaybeCssVar from 'lism-css/lib/getMaybeCssVar';
|
|
5
|
+
|
|
6
|
+
export type NavMenuRootProps = {
|
|
7
|
+
hovC?: string;
|
|
8
|
+
hovBgc?: string;
|
|
9
|
+
itemP?: string;
|
|
10
|
+
style?: Record<string, string>;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type NavMenuLinkProps = {
|
|
15
|
+
href?: string;
|
|
16
|
+
as?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function getRootProps({ hovC, hovBgc, itemP, style = {}, ...props }: NavMenuRootProps) {
|
|
21
|
+
const computedStyle = { ...style };
|
|
22
|
+
|
|
23
|
+
if (hovBgc) computedStyle['--hov-bgc'] = getMaybeCssVar(hovBgc, 'color');
|
|
24
|
+
if (hovC) computedStyle['--hov-c'] = getMaybeCssVar(hovC, 'color');
|
|
25
|
+
if (itemP) computedStyle['--_item-p'] = getMaybeCssVar(itemP, 'space');
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
lismClass: 'c--navMenu',
|
|
29
|
+
as: 'ul',
|
|
30
|
+
style: computedStyle,
|
|
31
|
+
...props,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getNestProps(props: Record<string, unknown>) {
|
|
36
|
+
return {
|
|
37
|
+
lismClass: 'c--navMenu_nest',
|
|
38
|
+
as: 'ul',
|
|
39
|
+
'px-s': '20',
|
|
40
|
+
...props,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getItemProps(props: Record<string, unknown>) {
|
|
45
|
+
return {
|
|
46
|
+
lismClass: 'c--navMenu_item',
|
|
47
|
+
as: 'li',
|
|
48
|
+
...props,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getLinkProps({ href, as = 'span', ...props }: NavMenuLinkProps) {
|
|
53
|
+
return {
|
|
54
|
+
lismClass: 'c--navMenu_link',
|
|
55
|
+
as: href ? 'a' : as,
|
|
56
|
+
href,
|
|
57
|
+
c: 'inherit',
|
|
58
|
+
...props,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import { Lism, Stack, Flex, type LismComponentProps } from 'lism-css/react';
|
|
3
|
+
import { getRootProps, getNestProps, getItemProps, getLinkProps, type NavMenuRootProps, type NavMenuLinkProps } from '../getProps';
|
|
4
|
+
import '../_style.css';
|
|
5
|
+
|
|
6
|
+
export function Root({ children, ...props }: NavMenuRootProps & LismComponentProps) {
|
|
7
|
+
const { as: rootAs, ...rootProps } = getRootProps(props);
|
|
8
|
+
return (
|
|
9
|
+
<Stack as={rootAs as ElementType} {...rootProps}>
|
|
10
|
+
{children}
|
|
11
|
+
</Stack>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Nest({ children, ...props }: LismComponentProps) {
|
|
16
|
+
const { as: nestAs, ...nestProps } = getNestProps(props);
|
|
17
|
+
return (
|
|
18
|
+
<Stack as={nestAs as ElementType} {...nestProps}>
|
|
19
|
+
{children}
|
|
20
|
+
</Stack>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Item({ children, ...props }: LismComponentProps) {
|
|
25
|
+
const { as: itemAs, ...itemProps } = getItemProps(props);
|
|
26
|
+
return (
|
|
27
|
+
<Lism as={itemAs as ElementType} {...itemProps}>
|
|
28
|
+
{children}
|
|
29
|
+
</Lism>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function Link({ children, ...props }: NavMenuLinkProps & LismComponentProps) {
|
|
34
|
+
const { as: linkAs, ...linkProps } = getLinkProps(props);
|
|
35
|
+
return (
|
|
36
|
+
<Flex as={linkAs as ElementType} {...linkProps}>
|
|
37
|
+
{children}
|
|
38
|
+
</Flex>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import ShapeDivider from './react/ShapeDivider';
|
|
3
|
+
|
|
4
|
+
const WAVE_PATH =
|
|
5
|
+
'M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ShapeDivider> = {
|
|
8
|
+
title: 'UI/ShapeDivider',
|
|
9
|
+
component: ShapeDivider,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
children: { control: false },
|
|
13
|
+
level: { control: 'number' },
|
|
14
|
+
flip: { control: 'select', options: [undefined, 'X', 'Y', 'XY'] },
|
|
15
|
+
isAnimation: { control: 'boolean' },
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof ShapeDivider>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
viewBox: '0 0 1200 120',
|
|
25
|
+
level: 5,
|
|
26
|
+
},
|
|
27
|
+
render: (args) => (
|
|
28
|
+
<ShapeDivider {...args}>
|
|
29
|
+
<path d={WAVE_PATH} />
|
|
30
|
+
</ShapeDivider>
|
|
31
|
+
),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const FlipX: Story = {
|
|
35
|
+
name: 'flip: X(左右反転)',
|
|
36
|
+
args: {
|
|
37
|
+
viewBox: '0 0 1200 120',
|
|
38
|
+
level: 5,
|
|
39
|
+
flip: 'X',
|
|
40
|
+
},
|
|
41
|
+
render: (args) => (
|
|
42
|
+
<ShapeDivider {...args}>
|
|
43
|
+
<path d={WAVE_PATH} />
|
|
44
|
+
</ShapeDivider>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const FlipY: Story = {
|
|
49
|
+
name: 'flip: Y(上下反転)',
|
|
50
|
+
args: {
|
|
51
|
+
viewBox: '0 0 1200 120',
|
|
52
|
+
level: 5,
|
|
53
|
+
flip: 'Y',
|
|
54
|
+
},
|
|
55
|
+
render: (args) => (
|
|
56
|
+
<ShapeDivider {...args}>
|
|
57
|
+
<path d={WAVE_PATH} />
|
|
58
|
+
</ShapeDivider>
|
|
59
|
+
),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const HighLevel: Story = {
|
|
63
|
+
name: 'level: 10',
|
|
64
|
+
args: {
|
|
65
|
+
viewBox: '0 0 1200 120',
|
|
66
|
+
level: 10,
|
|
67
|
+
},
|
|
68
|
+
render: (args) => (
|
|
69
|
+
<ShapeDivider {...args}>
|
|
70
|
+
<path d={WAVE_PATH} />
|
|
71
|
+
</ShapeDivider>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Animation: Story = {
|
|
76
|
+
name: 'animation',
|
|
77
|
+
args: {
|
|
78
|
+
viewBox: '0 0 1200 120',
|
|
79
|
+
level: 10,
|
|
80
|
+
isAnimation: true,
|
|
81
|
+
},
|
|
82
|
+
render: (args) => (
|
|
83
|
+
<ShapeDivider {...args}>
|
|
84
|
+
<path d={WAVE_PATH} />
|
|
85
|
+
</ShapeDivider>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ShapeDividerProps = {
|
|
2
|
+
viewBox?: string;
|
|
3
|
+
isAnimation?: boolean;
|
|
4
|
+
isEmpty?: boolean;
|
|
5
|
+
level?: number;
|
|
6
|
+
stretch?: string;
|
|
7
|
+
offset?: string;
|
|
8
|
+
flip?: string;
|
|
9
|
+
style?: Record<string, string>;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default function getProps({ viewBox, isAnimation, isEmpty, level = 5, stretch, offset, flip, style = {}, ...restProps }: ShapeDividerProps) {
|
|
14
|
+
if (level === 0) return null;
|
|
15
|
+
|
|
16
|
+
const computedStyle: Record<string, string | undefined> = { ...style };
|
|
17
|
+
computedStyle['--level'] = level != null ? String(level) : undefined;
|
|
18
|
+
computedStyle['--_inner-offset'] = offset ?? undefined;
|
|
19
|
+
computedStyle['--_inner-stretch'] = stretch ?? undefined;
|
|
20
|
+
|
|
21
|
+
const _props: Record<string, unknown> = {
|
|
22
|
+
lismClass: 'c--shapeDivider',
|
|
23
|
+
'max-sz': 'full',
|
|
24
|
+
'aria-hidden': 'true',
|
|
25
|
+
};
|
|
26
|
+
if (flip) _props['data-flip'] = flip;
|
|
27
|
+
if (isAnimation) _props['data-has-animation'] = 'true';
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
..._props,
|
|
31
|
+
style: computedStyle,
|
|
32
|
+
viewBox,
|
|
33
|
+
isEmpty,
|
|
34
|
+
...restProps,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Lism } from 'lism-css/react';
|
|
2
|
-
import getProps from '../getProps';
|
|
1
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
2
|
+
import getProps, { type ShapeDividerProps } from '../getProps';
|
|
3
3
|
import '../_style.css';
|
|
4
4
|
|
|
5
|
-
export default function ShapeDivider({ children, ...props }) {
|
|
5
|
+
export default function ShapeDivider({ children, ...props }: ShapeDividerProps & LismComponentProps) {
|
|
6
6
|
const componentProps = getProps(props);
|
|
7
7
|
|
|
8
8
|
// level が 0 の場合は非表示
|
|
9
9
|
if (!componentProps) return null;
|
|
10
10
|
|
|
11
|
-
const { viewBox,
|
|
11
|
+
const { viewBox, isEmpty, ...lismProps } = componentProps;
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<Lism {...lismProps}>
|