@fpkit/acss 0.5.4 → 0.5.6
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/libs/chunk-PWVRDQ3R.js +8 -0
- package/libs/chunk-PWVRDQ3R.js.map +1 -0
- package/libs/chunk-SVS4MX3U.cjs +31 -0
- package/libs/chunk-SVS4MX3U.cjs.map +1 -0
- package/libs/{icons-2f29127c.d.ts → icons-31ace3de.d.ts} +87 -81
- package/libs/icons.cjs +2 -2
- package/libs/icons.d.cts +1 -1
- package/libs/icons.d.ts +1 -1
- package/libs/icons.js +1 -1
- package/libs/index.cjs +42 -42
- package/libs/index.cjs.map +1 -1
- package/libs/index.d.cts +59 -29
- package/libs/index.d.ts +59 -29
- package/libs/index.js +7 -7
- package/libs/index.js.map +1 -1
- package/package.json +4 -3
- package/src/components/README.mdx +84 -0
- package/src/components/alert/README.mdx +86 -0
- package/src/components/alert/alert.mdx +74 -0
- package/src/components/alert/alert.scss +80 -0
- package/src/components/alert/alert.stories.tsx +132 -0
- package/src/components/alert/alert.tsx +154 -0
- package/src/components/alert/elements/README.mdx +77 -0
- package/src/components/alert/elements/dismiss-button.stories.tsx +31 -0
- package/src/components/alert/elements/dismiss-button.tsx +28 -0
- package/src/components/badge/badge.mdx +124 -0
- package/src/components/badge/badge.scss +4 -4
- package/src/components/badge/badge.stories.tsx +21 -23
- package/src/components/breadcrumbs/breadcrumb.scss +2 -2
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +42 -47
- package/src/components/buttons/button.scss +41 -15
- package/src/components/buttons/button.stories.tsx +8 -1
- package/src/components/buttons/button.test.tsx +72 -72
- package/src/components/cards/card.stories.tsx +15 -15
- package/src/components/details/details.scss +26 -6
- package/src/components/details/details.stories.tsx +33 -30
- package/src/components/details/details.tsx +17 -17
- package/src/components/dialog/README.mdx +187 -0
- package/src/components/dialog/dialog-modal.stories.tsx +113 -0
- package/src/components/dialog/dialog-modal.tsx +111 -0
- package/src/components/dialog/dialog.scss +76 -0
- package/src/components/dialog/dialog.stories.tsx +116 -0
- package/src/components/dialog/dialog.tsx +128 -0
- package/src/components/dialog/hooks/useClickOutside.ts +33 -0
- package/src/components/dialog/views/README.mdx +182 -0
- package/src/components/dialog/views/dialog-footer.tsx +45 -0
- package/src/components/dialog/views/dialog-header.stories.tsx +42 -0
- package/src/components/dialog/views/dialog-header.tsx +61 -0
- package/src/components/form/form.stories.tsx +16 -16
- package/src/components/form/input.stories.tsx +62 -62
- package/src/components/form/select.stories.tsx +22 -15
- package/src/components/heading/heading.stories.tsx +32 -33
- package/src/components/heading/heading.tsx +1 -1
- package/src/components/icons/components/add.tsx +14 -14
- package/src/components/icons/components/alert-solid.tsx +36 -0
- package/src/components/icons/components/alert-square-solid.tsx +36 -0
- package/src/components/icons/components/info-solid.tsx +40 -0
- package/src/components/icons/components/info.tsx +36 -0
- package/src/components/icons/components/question-solid.tsx +36 -0
- package/src/components/icons/components/success-solid.tsx +36 -0
- package/src/components/icons/components/svg.tsx +0 -1
- package/src/components/icons/components/warn-solid.tsx +36 -0
- package/src/components/icons/icon.scss +1 -3
- package/src/components/icons/icon.stories.tsx +87 -78
- package/src/components/icons/icon.tsx +57 -52
- package/src/components/icons/index.ts +36 -29
- package/src/components/icons/types.ts +1 -1
- package/src/components/images/figure.stories.tsx +13 -13
- package/src/components/images/img.stories.tsx +12 -12
- package/src/components/link/link.stories.tsx +32 -35
- package/src/components/link/link.tsx +27 -14
- package/src/components/list/list.stories.tsx +16 -16
- package/src/components/modal/dialog.tsx +13 -12
- package/src/components/modal/modal.tsx +28 -30
- package/src/components/nav/nav.stories.tsx +25 -24
- package/src/components/popover/popover.stories.tsx +17 -18
- package/src/components/progress/progress.stories.tsx +14 -20
- package/src/components/tag/tag.stories.tsx +17 -18
- package/src/components/text/text.stories.tsx +28 -29
- package/src/components/text-to-speech/TextToSpeech.stories.tsx +100 -101
- package/src/components/ui.tsx +28 -25
- package/src/decorators/instructions.tsx +44 -0
- package/src/hooks/useDialogClickHandler.ts +26 -0
- package/src/index.scss +23 -22
- package/src/index.ts +31 -30
- package/src/patterns/page/page-header.stories.tsx +17 -21
- package/src/sass/_globals.scss +14 -32
- package/src/sass/_styles.scss +2 -1
- package/src/sass/styles/_colors.scss +13 -0
- package/src/styles/alert/alert.css +68 -0
- package/src/styles/alert/alert.css.map +1 -0
- package/src/styles/badge/badge.css +3 -3
- package/src/styles/breadcrumbs/breadcrumb.css +1 -1
- package/src/styles/buttons/button.css +25 -2
- package/src/styles/buttons/button.css.map +1 -1
- package/src/styles/details/details.css +19 -4
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/dialog/dialog.css +76 -0
- package/src/styles/dialog/dialog.css.map +1 -0
- package/src/styles/icons/icon.css +1 -3
- package/src/styles/icons/icon.css.map +1 -1
- package/src/styles/index.css +213 -60
- package/src/styles/index.css.map +1 -1
- package/libs/chunk-TBM2QIVT.js +0 -8
- package/libs/chunk-TBM2QIVT.js.map +0 -1
- package/libs/chunk-VAH6X2DZ.cjs +0 -31
- package/libs/chunk-VAH6X2DZ.cjs.map +0 -1
- package/libs/components/badge/badge.css +0 -1
- package/libs/components/badge/badge.css.map +0 -1
- package/libs/components/badge/badge.min.css +0 -3
- package/libs/components/breadcrumbs/breadcrumb.css +0 -1
- package/libs/components/breadcrumbs/breadcrumb.css.map +0 -1
- package/libs/components/breadcrumbs/breadcrumb.min.css +0 -3
- package/libs/components/buttons/button.css +0 -1
- package/libs/components/buttons/button.css.map +0 -1
- package/libs/components/buttons/button.min.css +0 -3
- package/libs/components/cards/card-style.css +0 -1
- package/libs/components/cards/card-style.css.map +0 -1
- package/libs/components/cards/card-style.min.css +0 -3
- package/libs/components/cards/card.css +0 -1
- package/libs/components/cards/card.css.map +0 -1
- package/libs/components/cards/card.min.css +0 -3
- package/libs/components/details/details.css +0 -1
- package/libs/components/details/details.css.map +0 -1
- package/libs/components/details/details.min.css +0 -3
- package/libs/components/form/form.css +0 -1
- package/libs/components/form/form.css.map +0 -1
- package/libs/components/form/form.min.css +0 -3
- package/libs/components/icons/icon.css +0 -1
- package/libs/components/icons/icon.css.map +0 -1
- package/libs/components/icons/icon.min.css +0 -3
- package/libs/components/images/img.css +0 -1
- package/libs/components/images/img.css.map +0 -1
- package/libs/components/images/img.min.css +0 -3
- package/libs/components/layout/landmarks.css +0 -1
- package/libs/components/layout/landmarks.css.map +0 -1
- package/libs/components/layout/landmarks.min.css +0 -3
- package/libs/components/link/link.css +0 -1
- package/libs/components/link/link.css.map +0 -1
- package/libs/components/link/link.min.css +0 -3
- package/libs/components/nav/nav.css +0 -1
- package/libs/components/nav/nav.css.map +0 -1
- package/libs/components/nav/nav.min.css +0 -3
- package/libs/components/progress/progress.css +0 -1
- package/libs/components/progress/progress.css.map +0 -1
- package/libs/components/progress/progress.min.css +0 -3
- package/libs/components/styles/index.css +0 -1
- package/libs/components/styles/index.css.map +0 -1
- package/libs/components/styles/index.min.css +0 -3
- package/libs/components/tag/tag.css +0 -1
- package/libs/components/tag/tag.css.map +0 -1
- package/libs/components/tag/tag.min.css +0 -3
- package/libs/components/text-to-speech/text-to-speech.css +0 -1
- package/libs/components/text-to-speech/text-to-speech.css.map +0 -1
- package/libs/components/text-to-speech/text-to-speech.min.css +0 -3
- package/libs/index.css +0 -1
- package/libs/index.css.map +0 -1
- package/src/components/readme.stories.mdx +0 -7
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, expect, userEvent } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect, userEvent } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import Popover from './popover'
|
|
6
|
-
import { getByText } from '@testing-library/react'
|
|
4
|
+
import Popover from "./popover";
|
|
7
5
|
|
|
8
6
|
const meta: Meta<typeof Popover> = {
|
|
9
|
-
title:
|
|
7
|
+
title: "FP.React Components/Basic Popover",
|
|
10
8
|
component: Popover,
|
|
9
|
+
tags: ["experimental"],
|
|
11
10
|
args: {
|
|
12
|
-
children:
|
|
13
|
-
popoverTrigger:
|
|
11
|
+
children: "Hi, I am a popover.",
|
|
12
|
+
popoverTrigger: "Hover here",
|
|
14
13
|
styles: Popover.styles,
|
|
15
14
|
},
|
|
16
|
-
} as Meta
|
|
15
|
+
} as Meta;
|
|
17
16
|
|
|
18
|
-
export default meta
|
|
19
|
-
type Story = StoryObj<typeof Popover
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof Popover>;
|
|
20
19
|
|
|
21
20
|
export const PopoverComponent: Story = {
|
|
22
21
|
args: {},
|
|
23
22
|
play: async ({ canvasElement }) => {
|
|
24
|
-
const canvas = within(canvasElement)
|
|
25
|
-
expect(await canvas.queryByText(
|
|
26
|
-
userEvent.hover(canvas.getByText(
|
|
27
|
-
expect(await canvas.findByText(
|
|
28
|
-
await userEvent.unhover(canvas.getByText(
|
|
29
|
-
expect(canvas.queryByText(
|
|
23
|
+
const canvas = within(canvasElement);
|
|
24
|
+
expect(await canvas.queryByText("Hover here")).toBeInTheDocument();
|
|
25
|
+
userEvent.hover(canvas.getByText("Hover here"));
|
|
26
|
+
expect(await canvas.findByText("Hi, I am a popover.")).toBeInTheDocument();
|
|
27
|
+
await userEvent.unhover(canvas.getByText("Hover here"));
|
|
28
|
+
expect(canvas.queryByText("Hi, I am a popover.")).not.toBeInTheDocument();
|
|
30
29
|
},
|
|
31
|
-
}
|
|
30
|
+
};
|
|
@@ -1,51 +1,45 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, userEvent, screen } from '@storybook/test'
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
3
2
|
|
|
3
|
+
import "../../styles/progress/progress.css";
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import Progress from './progress'
|
|
5
|
+
import Progress from "./progress";
|
|
8
6
|
|
|
9
7
|
const meta: Meta<typeof Progress> = {
|
|
10
|
-
title:
|
|
8
|
+
title: "FP.React Components/Progress",
|
|
11
9
|
component: Progress,
|
|
12
|
-
|
|
10
|
+
tags: ["experimental"],
|
|
13
11
|
decorators: [
|
|
14
12
|
(Story) => (
|
|
15
|
-
<div style={{ minWidth:
|
|
13
|
+
<div style={{ minWidth: "500px", height: "100%" }}>
|
|
16
14
|
<Story />
|
|
17
15
|
</div>
|
|
18
16
|
),
|
|
19
17
|
],
|
|
20
|
-
} as Meta
|
|
18
|
+
} as Meta;
|
|
21
19
|
|
|
22
|
-
export default meta
|
|
23
|
-
type Story = StoryObj<typeof Progress
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof Progress>;
|
|
24
22
|
|
|
25
23
|
export const ProgressComponent: Story = {
|
|
26
|
-
name:
|
|
24
|
+
name: "Progress Bar",
|
|
27
25
|
args: {
|
|
28
26
|
isBusy: true,
|
|
29
27
|
},
|
|
30
|
-
|
|
31
|
-
const canvas = within(canvasElement)
|
|
32
|
-
//expect(canvas).toBeInTheDocument()
|
|
33
|
-
},
|
|
34
|
-
} as Story
|
|
28
|
+
} as Story;
|
|
35
29
|
|
|
36
30
|
export const ProgressIndicator: Story = {
|
|
37
31
|
args: {
|
|
38
32
|
value: 3,
|
|
39
33
|
max: 10,
|
|
40
34
|
},
|
|
41
|
-
} as Story
|
|
35
|
+
} as Story;
|
|
42
36
|
|
|
43
37
|
export const RedProgress: Story = {
|
|
44
38
|
args: {
|
|
45
39
|
...ProgressIndicator.args,
|
|
46
40
|
styles: {
|
|
47
|
-
|
|
41
|
+
"--progress-color": "red",
|
|
48
42
|
},
|
|
49
43
|
value: 7,
|
|
50
44
|
},
|
|
51
|
-
} as Story
|
|
45
|
+
} as Story;
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, expect } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import './tag.scss'
|
|
4
|
+
import Tag from "./tag";
|
|
5
|
+
import "./tag.scss";
|
|
7
6
|
|
|
8
7
|
const meta: Meta<typeof Tag> = {
|
|
9
|
-
title:
|
|
8
|
+
title: "FP.React Components/Tag",
|
|
10
9
|
component: Tag,
|
|
10
|
+
tags: ["beta"],
|
|
11
11
|
args: {
|
|
12
|
-
|
|
13
|
-
children: 'Basic Tag',
|
|
12
|
+
children: "Basic Tag",
|
|
14
13
|
// styles: Tag.styles,
|
|
15
14
|
},
|
|
16
|
-
} as Meta
|
|
15
|
+
} as Meta;
|
|
17
16
|
|
|
18
|
-
export default meta
|
|
19
|
-
type Story = StoryObj<typeof Tag
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof Tag>;
|
|
20
19
|
|
|
21
20
|
export const TagComponent: Story = {
|
|
22
21
|
args: {},
|
|
23
22
|
play: async ({ canvasElement }) => {
|
|
24
|
-
const canvas = within(canvasElement)
|
|
25
|
-
expect(canvas.queryByText(/basic tag/i)).toBeInTheDocument()
|
|
23
|
+
const canvas = within(canvasElement);
|
|
24
|
+
expect(canvas.queryByText(/basic tag/i)).toBeInTheDocument();
|
|
26
25
|
},
|
|
27
|
-
}
|
|
26
|
+
};
|
|
28
27
|
|
|
29
28
|
export const Beta: Story = {
|
|
30
29
|
args: {
|
|
31
|
-
|
|
30
|
+
"data-tag": "beta",
|
|
32
31
|
},
|
|
33
|
-
} as Story
|
|
32
|
+
} as Story;
|
|
34
33
|
|
|
35
34
|
export const Production: Story = {
|
|
36
35
|
args: {
|
|
37
|
-
|
|
36
|
+
"data-tag": "production",
|
|
38
37
|
},
|
|
39
|
-
} as Story
|
|
38
|
+
} as Story;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, expect} from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import Text from './text'
|
|
4
|
+
import Text from "./text";
|
|
6
5
|
|
|
7
6
|
const meta: Meta<typeof Text> = {
|
|
8
|
-
title:
|
|
7
|
+
title: "FP.REACT Components/Text",
|
|
9
8
|
component: Text,
|
|
9
|
+
tags: ["version:1.0.0"],
|
|
10
10
|
args: {
|
|
11
|
-
// @ts-ignore
|
|
12
11
|
children:
|
|
13
|
-
|
|
12
|
+
"Exercitation non voluptate fugiat amet dolor tempor consectetur. Eu esse adipisicing laboris duis et velit in quis et sunt pariatur tempor laborum nisi. Et id amet ullamco culpa irure nulla esse dolore velit esse.",
|
|
14
13
|
},
|
|
15
|
-
} as Story
|
|
14
|
+
} as Story;
|
|
16
15
|
|
|
17
|
-
export default meta
|
|
18
|
-
type Story = StoryObj<typeof Text
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof Text>;
|
|
19
18
|
|
|
20
19
|
export const ParagraphText: Story = {
|
|
21
20
|
args: {},
|
|
@@ -23,45 +22,45 @@ export const ParagraphText: Story = {
|
|
|
23
22
|
// const canvas = within(canvasElement)
|
|
24
23
|
// expect(canvas.getByText(/link/i)).toBeInTheDocument()
|
|
25
24
|
// },
|
|
26
|
-
}
|
|
25
|
+
};
|
|
27
26
|
|
|
28
27
|
export const span: Story = {
|
|
29
28
|
args: {
|
|
30
|
-
as:
|
|
31
|
-
children:
|
|
29
|
+
as: "span",
|
|
30
|
+
children: "Heading Text",
|
|
32
31
|
},
|
|
33
32
|
play: async ({ canvasElement }) => {
|
|
34
|
-
const canvas = within(canvasElement)
|
|
35
|
-
expect(canvas.getByText(/heading/i)).toBeInTheDocument()
|
|
33
|
+
const canvas = within(canvasElement);
|
|
34
|
+
expect(canvas.getByText(/heading/i)).toBeInTheDocument();
|
|
36
35
|
},
|
|
37
|
-
} as Story
|
|
36
|
+
} as Story;
|
|
38
37
|
|
|
39
38
|
export const Blockquote: Story = {
|
|
40
39
|
args: {
|
|
41
|
-
as:
|
|
40
|
+
as: "blockquote",
|
|
42
41
|
children:
|
|
43
|
-
|
|
42
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.",
|
|
44
43
|
},
|
|
45
|
-
} as Story
|
|
44
|
+
} as Story;
|
|
46
45
|
|
|
47
46
|
export const Strong: Story = {
|
|
48
47
|
args: {
|
|
49
|
-
as:
|
|
50
|
-
children:
|
|
48
|
+
as: "strong",
|
|
49
|
+
children: "Emphasis Text",
|
|
51
50
|
},
|
|
52
51
|
play: async ({ canvasElement }) => {
|
|
53
|
-
const canvas = within(canvasElement)
|
|
54
|
-
expect(canvas.getByText(/emphasis/i)).toBeInTheDocument()
|
|
52
|
+
const canvas = within(canvasElement);
|
|
53
|
+
expect(canvas.getByText(/emphasis/i)).toBeInTheDocument();
|
|
55
54
|
},
|
|
56
|
-
} as Story
|
|
55
|
+
} as Story;
|
|
57
56
|
|
|
58
57
|
export const Code: Story = {
|
|
59
58
|
args: {
|
|
60
|
-
as:
|
|
61
|
-
children:
|
|
59
|
+
as: "code",
|
|
60
|
+
children: "Code Text",
|
|
62
61
|
},
|
|
63
62
|
play: async ({ canvasElement }) => {
|
|
64
|
-
const canvas = within(canvasElement)
|
|
65
|
-
expect(canvas.getByText(/code/i)).toBeInTheDocument()
|
|
63
|
+
const canvas = within(canvasElement);
|
|
64
|
+
expect(canvas.getByText(/code/i)).toBeInTheDocument();
|
|
66
65
|
},
|
|
67
|
-
} as Story
|
|
66
|
+
} as Story;
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import './text-to-speech.scss'
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import TextToSpeech from "./TextToSpeech";
|
|
3
|
+
import "./text-to-speech.scss";
|
|
5
4
|
|
|
6
5
|
const meta: Meta<typeof TextToSpeech> = {
|
|
7
|
-
title:
|
|
6
|
+
title: "FP.REACT Components/TextToSpeech",
|
|
8
7
|
component: TextToSpeech,
|
|
9
|
-
tags: [
|
|
8
|
+
tags: ["experimental"],
|
|
10
9
|
argTypes: {
|
|
11
10
|
voice: {
|
|
12
11
|
control: {
|
|
13
|
-
type:
|
|
12
|
+
type: "select",
|
|
14
13
|
options: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
"Google US English",
|
|
15
|
+
"Google UK English Female",
|
|
16
|
+
"Google UK English Male",
|
|
18
17
|
],
|
|
19
18
|
},
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
|
-
} as Story
|
|
21
|
+
} as Story;
|
|
23
22
|
|
|
24
|
-
export default meta
|
|
23
|
+
export default meta;
|
|
25
24
|
|
|
26
|
-
type Story = StoryObj<typeof TextToSpeech
|
|
25
|
+
type Story = StoryObj<typeof TextToSpeech>;
|
|
27
26
|
|
|
28
27
|
export const Default: Story = {
|
|
29
28
|
args: {
|
|
30
|
-
label:
|
|
29
|
+
label: "Read post",
|
|
31
30
|
initialText:
|
|
32
|
-
|
|
31
|
+
"Hello, how are you? I am a Text to Speech (TTS) assistant! Update this text and click the [speak] button to hear the change.",
|
|
33
32
|
},
|
|
34
33
|
parameters: {
|
|
35
34
|
docs: {
|
|
@@ -39,13 +38,13 @@ export const Default: Story = {
|
|
|
39
38
|
},
|
|
40
39
|
},
|
|
41
40
|
},
|
|
42
|
-
} as Story
|
|
41
|
+
} as Story;
|
|
43
42
|
|
|
44
43
|
export const WithText: Story = {
|
|
45
44
|
args: {
|
|
46
45
|
// Add props to simulate text input
|
|
47
46
|
initialText:
|
|
48
|
-
|
|
47
|
+
"This is a test of the text to speech component. Here the test is passed as a prop and the text input is hidden.",
|
|
49
48
|
showTextInput: false,
|
|
50
49
|
},
|
|
51
50
|
parameters: {
|
|
@@ -56,90 +55,90 @@ export const WithText: Story = {
|
|
|
56
55
|
},
|
|
57
56
|
},
|
|
58
57
|
},
|
|
59
|
-
} as Story
|
|
58
|
+
} as Story;
|
|
60
59
|
|
|
61
|
-
export const FullFeature: Story = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
// export const FullFeature: Story = {
|
|
61
|
+
// args: {
|
|
62
|
+
// initialText:
|
|
63
|
+
// "Welcome to the full-featured Text-to-Speech component. You can modify this text, choose a voice, adjust pitch and rate, and then click the speak button to hear it.",
|
|
64
|
+
// showTextInput: true,
|
|
65
|
+
// pitch: 1,
|
|
66
|
+
// rate: 1,
|
|
67
|
+
// },
|
|
68
|
+
// parameters: {
|
|
69
|
+
// docs: {
|
|
70
|
+
// description: {
|
|
71
|
+
// story:
|
|
72
|
+
// "This story showcases all features of the TextToSpeechComponent, including text input, voice selection, pitch and rate adjustment. It provides a comprehensive demonstration of the component's capabilities.",
|
|
73
|
+
// },
|
|
74
|
+
// },
|
|
75
|
+
// },
|
|
76
|
+
// render: (args) => {
|
|
77
|
+
// const [selectedVoice, setSelectedVoice] = React.useState<
|
|
78
|
+
// SpeechSynthesisVoice | undefined
|
|
79
|
+
// >(undefined);
|
|
80
|
+
// const [pitch, setPitch] = React.useState(1);
|
|
81
|
+
// const [rate, setRate] = React.useState(1);
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
// React.useEffect(() => {
|
|
84
|
+
// const voices = window.speechSynthesis.getVoices();
|
|
85
|
+
// setSelectedVoice(
|
|
86
|
+
// voices.find((voice) => voice.name === "Google US English") || voices[0]
|
|
87
|
+
// );
|
|
88
|
+
// }, []);
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
} as Story
|
|
90
|
+
// return (
|
|
91
|
+
// <div>
|
|
92
|
+
// <TextToSpeech
|
|
93
|
+
// {...args}
|
|
94
|
+
// voice={selectedVoice}
|
|
95
|
+
// pitch={pitch}
|
|
96
|
+
// rate={rate}
|
|
97
|
+
// />
|
|
98
|
+
// <div style={{ marginTop: "20px" }}>
|
|
99
|
+
// <label htmlFor="voice-select">Select Voice: </label>
|
|
100
|
+
// <select
|
|
101
|
+
// id="voice-select"
|
|
102
|
+
// onChange={(e) =>
|
|
103
|
+
// setSelectedVoice(
|
|
104
|
+
// window.speechSynthesis
|
|
105
|
+
// .getVoices()
|
|
106
|
+
// .find((v) => v.name === e.target.value)
|
|
107
|
+
// )
|
|
108
|
+
// }
|
|
109
|
+
// >
|
|
110
|
+
// {window.speechSynthesis.getVoices().map((voice) => (
|
|
111
|
+
// <option key={voice.name} value={voice.name}>
|
|
112
|
+
// {voice.name} ({voice.lang})
|
|
113
|
+
// </option>
|
|
114
|
+
// ))}
|
|
115
|
+
// </select>
|
|
116
|
+
// </div>
|
|
117
|
+
// <div style={{ marginTop: "10px" }}>
|
|
118
|
+
// <label htmlFor="pitch-range">Pitch: {pitch}</label>
|
|
119
|
+
// <input
|
|
120
|
+
// id="pitch-range"
|
|
121
|
+
// type="range"
|
|
122
|
+
// min="0.5"
|
|
123
|
+
// max="2"
|
|
124
|
+
// step="0.1"
|
|
125
|
+
// value={pitch}
|
|
126
|
+
// onChange={(e) => setPitch(parseFloat(e.target.value))}
|
|
127
|
+
// />
|
|
128
|
+
// </div>
|
|
129
|
+
// <div style={{ marginTop: "10px" }}>
|
|
130
|
+
// <label htmlFor="rate-range">Rate: {rate}</label>
|
|
131
|
+
// <input
|
|
132
|
+
// id="rate-range"
|
|
133
|
+
// type="range"
|
|
134
|
+
// min="0.5"
|
|
135
|
+
// max="2"
|
|
136
|
+
// step="0.1"
|
|
137
|
+
// value={rate}
|
|
138
|
+
// onChange={(e) => setRate(parseFloat(e.target.value))}
|
|
139
|
+
// />
|
|
140
|
+
// </div>
|
|
141
|
+
// </div>
|
|
142
|
+
// );
|
|
143
|
+
// },
|
|
144
|
+
// } as Story;
|
package/src/components/ui.tsx
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import React from "react";
|
|
3
4
|
|
|
4
5
|
type PolymorphicRef<C extends React.ElementType> =
|
|
5
|
-
React.ComponentPropsWithRef<C>[
|
|
6
|
+
React.ComponentPropsWithRef<C>["ref"];
|
|
6
7
|
|
|
7
8
|
type AsProp<C extends React.ElementType> = {
|
|
8
|
-
as?: C
|
|
9
|
-
}
|
|
9
|
+
as?: C;
|
|
10
|
+
};
|
|
10
11
|
|
|
11
|
-
type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P)
|
|
12
|
+
type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);
|
|
12
13
|
|
|
13
14
|
type PolymorphicComponentProp<
|
|
14
15
|
C extends React.ElementType,
|
|
15
16
|
Props = {},
|
|
16
17
|
> = React.PropsWithChildren<Props & AsProp<C>> &
|
|
17
|
-
Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props
|
|
18
|
+
Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
|
|
18
19
|
|
|
19
20
|
type PolymorphicComponentPropWithRef<
|
|
20
21
|
C extends React.ElementType,
|
|
21
22
|
Props = {},
|
|
22
23
|
> = PolymorphicComponentProp<C, Props> & {
|
|
23
|
-
ref?: PolymorphicRef<C
|
|
24
|
-
}
|
|
24
|
+
ref?: PolymorphicRef<C>;
|
|
25
|
+
};
|
|
25
26
|
|
|
26
27
|
type FPProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<
|
|
27
28
|
C,
|
|
28
29
|
{
|
|
29
|
-
renderStyles?: boolean
|
|
30
|
-
styles?: React.CSSProperties
|
|
31
|
-
classes?: string
|
|
32
|
-
id?: string
|
|
33
|
-
children?: React.ReactNode
|
|
30
|
+
renderStyles?: boolean;
|
|
31
|
+
styles?: React.CSSProperties;
|
|
32
|
+
classes?: string;
|
|
33
|
+
id?: string;
|
|
34
|
+
children?: React.ReactNode;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
>;
|
|
36
37
|
|
|
37
38
|
/*
|
|
38
39
|
* FPComponent type definition
|
|
@@ -43,25 +44,27 @@ type FPProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<
|
|
|
43
44
|
* @param props - The component props
|
|
44
45
|
* @returns React component
|
|
45
46
|
*/
|
|
46
|
-
type FPComponent = <C extends React.ElementType =
|
|
47
|
-
props: FPProps<C
|
|
48
|
-
) => React.ReactElement | any
|
|
47
|
+
type FPComponent = <C extends React.ElementType = "span">(
|
|
48
|
+
props: FPProps<C>
|
|
49
|
+
) => React.ReactElement | (any & { displayName?: String });
|
|
49
50
|
|
|
50
51
|
const FP: FPComponent = React.forwardRef(
|
|
51
52
|
<C extends React.ElementType>(
|
|
52
53
|
{ as, styles, classes, children, defaultStyles, ...props }: FPProps<C>,
|
|
53
|
-
ref?: PolymorphicRef<C
|
|
54
|
+
ref?: PolymorphicRef<C>
|
|
54
55
|
) => {
|
|
55
|
-
const Component = as
|
|
56
|
+
const Component = as ?? "div";
|
|
56
57
|
|
|
57
|
-
const styleObj: React.CSSProperties = { ...defaultStyles, ...styles }
|
|
58
|
+
const styleObj: React.CSSProperties = { ...defaultStyles, ...styles };
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
61
|
<Component ref={ref} style={styleObj} className={classes} {...props}>
|
|
61
62
|
{children}
|
|
62
63
|
</Component>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
66
67
|
|
|
67
|
-
export default FP
|
|
68
|
+
export default FP;
|
|
69
|
+
// @ts-expect-error -- React component displayName
|
|
70
|
+
FP.displayName = "FP";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { StoryFn } from "@storybook/react";
|
|
2
|
+
import UI from "#components/ui";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A decorator that wraps a Storybook story with instructions and an optional title.
|
|
6
|
+
* This decorator creates a container that displays instructions above the story component.
|
|
7
|
+
*
|
|
8
|
+
* @param {React.ReactNode} [instructions] - Optional instructions to display above the story
|
|
9
|
+
* @param {string} [title] - Optional title for the instructions section. Defaults to "Story Instructions"
|
|
10
|
+
* @returns {Function} A decorator function that wraps the story component
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* export const MyStory = Template.bind({});
|
|
15
|
+
* MyStory.decorators = [
|
|
16
|
+
* WithInstructions(
|
|
17
|
+
* <p>Follow these steps to interact with the component...</p>,
|
|
18
|
+
* "Usage Instructions"
|
|
19
|
+
* )
|
|
20
|
+
* ];
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const WithInstructions =
|
|
24
|
+
(instructions?: React.ReactNode, title?: string) => (Story: StoryFn) => {
|
|
25
|
+
return (
|
|
26
|
+
<UI
|
|
27
|
+
style={{
|
|
28
|
+
paddingBlock: "2rem",
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
gap: "3rem",
|
|
32
|
+
width: "max(320px, 90%)",
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<Story />
|
|
36
|
+
<div style={{ paddingInline: "1rem" }}>
|
|
37
|
+
<h3>{title || "Story Instructions"}</h3>
|
|
38
|
+
{instructions}
|
|
39
|
+
</div>
|
|
40
|
+
</UI>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default WithInstructions;
|