@fpkit/acss 0.5.4 → 0.5.5
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-QHIABQNQ.js +8 -0
- package/libs/chunk-QHIABQNQ.js.map +1 -0
- package/libs/chunk-ZOHIKF6I.cjs +31 -0
- package/libs/chunk-ZOHIKF6I.cjs.map +1 -0
- package/libs/components/breadcrumbs/breadcrumb.css +1 -1
- package/libs/components/breadcrumbs/breadcrumb.min.css +1 -1
- package/libs/components/buttons/button.css +1 -1
- package/libs/components/buttons/button.css.map +1 -1
- package/libs/components/buttons/button.min.css +2 -2
- package/libs/components/details/details.css +1 -1
- package/libs/components/details/details.css.map +1 -1
- package/libs/components/details/details.min.css +2 -2
- package/libs/components/dialog/dialog.css +1 -0
- package/libs/components/dialog/dialog.css.map +1 -0
- package/libs/components/dialog/dialog.min.css +3 -0
- package/libs/components/icons/icon.css +1 -1
- package/libs/components/icons/icon.css.map +1 -1
- package/libs/components/icons/icon.min.css +2 -2
- package/libs/{icons-2f29127c.d.ts → icons-1f5afc0c.d.ts} +1 -32
- 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 +39 -39
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +27 -28
- package/libs/index.d.ts +27 -28
- package/libs/index.js +6 -6
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/alert-dialog/alert-dialog.stories.tsx +35 -0
- package/src/components/alert-dialog/alert-dialog.tsx +76 -0
- 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 +40 -15
- package/src/components/buttons/button.stories.tsx +8 -1
- package/src/components/cards/card.stories.tsx +15 -15
- package/src/components/details/details.scss +6 -5
- package/src/components/details/details.stories.tsx +33 -30
- package/src/components/details/details.tsx +17 -17
- package/src/components/dialog/dialog.scss +61 -0
- package/src/components/dialog/dialog.stories.tsx +61 -0
- package/src/components/dialog/dialog.tsx +83 -0
- package/src/components/dialog/view/dialog-header.stories.tsx +43 -0
- package/src/components/dialog/view/dialog-header.tsx +32 -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/svg.tsx +0 -1
- package/src/components/icons/icon.scss +1 -3
- package/src/components/icons/icon.stories.tsx +45 -78
- package/src/components/icons/icon.tsx +0 -11
- 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/index.scss +22 -22
- package/src/index.ts +31 -30
- package/src/patterns/page/page-header.stories.tsx +17 -21
- package/src/sass/_globals.scss +7 -31
- package/src/sass/_styles.scss +2 -1
- package/src/sass/styles/_colors.scss +13 -0
- 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 +5 -3
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/dialog/dialog.css +61 -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 +107 -47
- 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/src/components/readme.stories.mdx +0 -7
|
@@ -5,7 +5,7 @@ nav[data-breadcrumb] {
|
|
|
5
5
|
--breadcrumb-gap: 0.5rem;
|
|
6
6
|
--breadcrumb-color: currentColor;
|
|
7
7
|
--breadcrumb-current-color: rgb(46, 46, 46);
|
|
8
|
-
--breadcrumb-fs: var(--fs-
|
|
8
|
+
--breadcrumb-fs: var(--fs-3);
|
|
9
9
|
margin-inline: unset;
|
|
10
10
|
padding-inline: unset;
|
|
11
11
|
ol {
|
|
@@ -20,7 +20,7 @@ nav[data-breadcrumb] {
|
|
|
20
20
|
color: var(--breadcrumb-color);
|
|
21
21
|
gap: 0.5rem;
|
|
22
22
|
font-size: var(--breadcrumb-fs);
|
|
23
|
-
span[aria-hidden=
|
|
23
|
+
span[aria-hidden="true"] {
|
|
24
24
|
opacity: 0.6;
|
|
25
25
|
}
|
|
26
26
|
a[href] {
|
|
@@ -1,108 +1,103 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from
|
|
2
|
-
import { within,
|
|
1
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, fn, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
+
import Breadcrumb from "./breadcrumb";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const linkClicked = fn()
|
|
6
|
+
const linkClicked = fn();
|
|
8
7
|
|
|
9
8
|
const meta: Meta<typeof Breadcrumb> = {
|
|
10
|
-
title:
|
|
9
|
+
title: "FP.REACT Components/Breadcrumb",
|
|
11
10
|
component: Breadcrumb,
|
|
11
|
+
tags: ["beta"],
|
|
12
12
|
parameters: {
|
|
13
|
-
actions: { argTypesRegex:
|
|
13
|
+
actions: { argTypesRegex: "^on.*" },
|
|
14
14
|
docs: {
|
|
15
15
|
description: {
|
|
16
|
-
component:
|
|
16
|
+
component: "Breadcrumb description here...",
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
args: {
|
|
21
|
-
children:
|
|
21
|
+
children: "Link",
|
|
22
22
|
},
|
|
23
|
-
} as Meta
|
|
23
|
+
} as Meta;
|
|
24
24
|
|
|
25
|
-
export default meta
|
|
26
|
-
type Story = StoryObj<typeof Breadcrumb
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof Breadcrumb>;
|
|
27
27
|
|
|
28
28
|
export const BreadcrumbComponent: Story = {
|
|
29
29
|
args: {},
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
31
|
|
|
32
32
|
export const CustomURL: Story = {
|
|
33
33
|
args: {
|
|
34
34
|
routes: [
|
|
35
35
|
{
|
|
36
|
-
name:
|
|
37
|
-
url:
|
|
38
|
-
path:
|
|
36
|
+
name: "Products",
|
|
37
|
+
url: "/products",
|
|
38
|
+
path: "product",
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name:
|
|
42
|
-
url:
|
|
43
|
-
path:
|
|
41
|
+
name: "Shirts",
|
|
42
|
+
url: "/products/shirts",
|
|
43
|
+
path: "shirts",
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
name:
|
|
47
|
-
url:
|
|
48
|
-
path:
|
|
46
|
+
name: "Pants",
|
|
47
|
+
url: "/products/pants",
|
|
48
|
+
path: "pants",
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
|
-
currentRoute:
|
|
51
|
+
currentRoute: "/product/men/shirts/size-22",
|
|
52
52
|
},
|
|
53
|
-
} as Story
|
|
53
|
+
} as Story;
|
|
54
54
|
|
|
55
55
|
export const AstroBreadcrumbs: Story = {
|
|
56
56
|
args: {
|
|
57
57
|
...CustomURL.args,
|
|
58
|
-
currentRoute:
|
|
58
|
+
currentRoute: "/about",
|
|
59
59
|
},
|
|
60
|
-
} as Story
|
|
60
|
+
} as Story;
|
|
61
61
|
|
|
62
62
|
export const EncodedBreadcrumbs: Story = {
|
|
63
63
|
args: {
|
|
64
64
|
routes: [
|
|
65
65
|
{
|
|
66
|
-
name:
|
|
67
|
-
path:
|
|
66
|
+
name: "Home",
|
|
67
|
+
path: "#",
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
name:
|
|
71
|
-
path:
|
|
70
|
+
name: "Products",
|
|
71
|
+
path: "/products",
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
name:
|
|
75
|
-
path:
|
|
74
|
+
name: "Shirts",
|
|
75
|
+
path: "/products/shirts",
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
|
-
currentRoute:
|
|
79
|
-
|
|
78
|
+
currentRoute: "/products/learning%20in%20public",
|
|
80
79
|
},
|
|
81
|
-
|
|
82
|
-
} as Story
|
|
80
|
+
} as Story;
|
|
83
81
|
|
|
84
82
|
export const TruncateName: Story = {
|
|
85
83
|
args: {
|
|
86
84
|
...CustomURL.args,
|
|
87
|
-
currentRoute:
|
|
85
|
+
currentRoute: "/products/AveryLongNameTruncate",
|
|
88
86
|
},
|
|
89
|
-
} as Story
|
|
87
|
+
} as Story;
|
|
90
88
|
|
|
91
|
-
export const
|
|
89
|
+
export const BreadCrumbInteractions: Story = {
|
|
92
90
|
args: {
|
|
93
91
|
...CustomURL.args,
|
|
94
|
-
currentRoute:
|
|
92
|
+
currentRoute: "/products/shirts",
|
|
95
93
|
startRouteUrl: "#",
|
|
96
94
|
linkProps: {
|
|
97
95
|
onClick: linkClicked,
|
|
98
96
|
},
|
|
99
97
|
},
|
|
100
|
-
|
|
101
98
|
play: async ({ canvasElement }) => {
|
|
102
|
-
const canvas = within(canvasElement)
|
|
103
|
-
const homeLink = canvas.getByRole(
|
|
104
|
-
expect(homeLink).toHaveAttribute(
|
|
105
|
-
// await userEvent.click(homeLink)
|
|
106
|
-
// expect(linkClicked).toHaveBeenCalled()
|
|
99
|
+
const canvas = within(canvasElement);
|
|
100
|
+
const homeLink = canvas.getByRole("link", { name: "Home" });
|
|
101
|
+
expect(homeLink).toHaveAttribute("href", "#");
|
|
107
102
|
},
|
|
108
|
-
} as Story
|
|
103
|
+
} as Story;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
button {
|
|
2
|
-
--btn-
|
|
3
|
-
--btn-
|
|
2
|
+
--btn-xs: 0.6rem;
|
|
3
|
+
--btn-sm: 0.7rem;
|
|
4
|
+
--btn-md: 0.85rem;
|
|
4
5
|
--btn-lg: calc(21rem / 16);
|
|
5
6
|
--btn-pill: 100rem;
|
|
6
7
|
--btn-height: 2.5rem;
|
|
@@ -28,20 +29,23 @@ button {
|
|
|
28
29
|
background-color: var(--btn-bg, var(--btn));
|
|
29
30
|
outline: none;
|
|
30
31
|
width: var(--btn-width);
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
line-height: 0cap;
|
|
31
35
|
|
|
32
36
|
&[type] {
|
|
33
37
|
background-color: var(--btn-bg, var(--neutral-300));
|
|
34
38
|
--btn-bdr: solid var(--btn-sg);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
&[type=
|
|
38
|
-
&[style*=
|
|
41
|
+
&[type="submit"],
|
|
42
|
+
&[style*="submit"] {
|
|
39
43
|
--btn-bg: var(--primary-500, royal-blue);
|
|
40
44
|
--btn-color: white;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
&[disabled],
|
|
44
|
-
&[aria-disabled=
|
|
48
|
+
&[aria-disabled="true"] {
|
|
45
49
|
cursor: var(--btn-cursor, not-allowed);
|
|
46
50
|
// opacity: var(--btn-opacity, 0.5);
|
|
47
51
|
|
|
@@ -60,44 +64,65 @@ button {
|
|
|
60
64
|
transform: scale(0.95) var(--line-style, solid);
|
|
61
65
|
outline-offset: var(--line-offset, 1px);
|
|
62
66
|
|
|
63
|
-
&[aria-disabled=
|
|
67
|
+
&[aria-disabled="true"] {
|
|
64
68
|
transform: none;
|
|
65
69
|
opacity: var(--btn-opacity, 0.5);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
&[type=
|
|
73
|
+
&[type="reset"] {
|
|
70
74
|
--btn-bg: transparent;
|
|
71
75
|
--btn-color: gray;
|
|
72
76
|
--btn-bdr: gray thin solid;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
|
-
&[type=
|
|
79
|
+
&[type="submit"] {
|
|
76
80
|
--btn-bg: var(--primary-700, blue);
|
|
77
81
|
--btn-cl: #fff;
|
|
78
82
|
--btn-color: rgb(231, 231, 231);
|
|
79
83
|
--btn-border: none;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
&[data-fp-btn~=
|
|
83
|
-
&[data-btn~=
|
|
84
|
-
&[data-style~=
|
|
86
|
+
&[data-fp-btn~="pill"],
|
|
87
|
+
&[data-btn~="pill"],
|
|
88
|
+
&[data-style~="pill"] {
|
|
85
89
|
border-radius: var(--btn-pill, 100rem);
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
&[data-btn~=
|
|
92
|
+
&[data-btn~="xs"] {
|
|
93
|
+
padding-inline: var(--btn-xs);
|
|
94
|
+
--btn-fs: var(--btn-xs);
|
|
95
|
+
--btn-height: 1.5rem;
|
|
96
|
+
text-transform: uppercase;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&[data-btn~="sm"] {
|
|
89
100
|
--btn-fs: var(--btn-sm);
|
|
101
|
+
--btn-height: 1.75rem;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
|
-
&[data-btn~=
|
|
104
|
+
&[data-btn~="md"] {
|
|
93
105
|
--btn-fs: var(--btn-md);
|
|
106
|
+
--btn-height: 2rem;
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
&[data-btn~=
|
|
109
|
+
&[data-btn~="lg"] {
|
|
97
110
|
--btn-fs: var(--btn-lg);
|
|
111
|
+
--btn-height: 2.5rem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&[data-btn~="icon"] {
|
|
115
|
+
padding: unset;
|
|
116
|
+
height: unset;
|
|
117
|
+
min-width: 1.5rem;
|
|
118
|
+
min-height: 1.5rem;
|
|
119
|
+
text-align: center;
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
98
123
|
}
|
|
99
124
|
|
|
100
|
-
&[data-btn~=
|
|
125
|
+
&[data-btn~="text"] {
|
|
101
126
|
--btn-bg: transparent;
|
|
102
127
|
--btn-cl: currentColor;
|
|
103
128
|
--btn-bdr: none;
|
|
@@ -9,12 +9,13 @@ const buttonClicked = fn();
|
|
|
9
9
|
const meta = {
|
|
10
10
|
title: "FP.React Components/Buttons",
|
|
11
11
|
component: Button,
|
|
12
|
+
tags: ["rc"],
|
|
12
13
|
args: {
|
|
13
14
|
children: "Click me",
|
|
14
15
|
onClick: buttonClicked,
|
|
15
16
|
},
|
|
16
17
|
parameters: {
|
|
17
|
-
actions: { argTypesRegex:
|
|
18
|
+
actions: { argTypesRegex: "^on.*" },
|
|
18
19
|
},
|
|
19
20
|
} as Meta;
|
|
20
21
|
|
|
@@ -52,6 +53,12 @@ export const ButtonComponent: Story = {
|
|
|
52
53
|
},
|
|
53
54
|
} as Story;
|
|
54
55
|
|
|
56
|
+
export const Xsmall: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
"data-btn": "xs",
|
|
59
|
+
},
|
|
60
|
+
} as Story;
|
|
61
|
+
|
|
55
62
|
export const Small: Story = {
|
|
56
63
|
args: {
|
|
57
64
|
"data-btn": "sm",
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, userEvent, screen } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
// import { within, userEvent, screen } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import Card from './card'
|
|
4
|
+
import Card from "./card";
|
|
6
5
|
// import './card.scss'
|
|
7
6
|
|
|
8
7
|
const content =
|
|
9
|
-
|
|
8
|
+
"Enim aliquip excepteur veniam esse culpa. Et exercitation incididunt occaecat incididunt proident consectetur. Voluptate elit reprehenderit nulla reprehenderit excepteur tempor adipisicing officia eiusmod est id aute. Nisi do et nulla fugiat enim id pariatur ex. Culpa aliquip excepteur velit fugiat qui magna deserunt adipisicing dolore quis. Esse proident qui consectetur Lorem id fugiat elit amet proident enim deserunt dolore sit.";
|
|
10
9
|
|
|
11
10
|
const meta: Meta<typeof Card> = {
|
|
12
|
-
title:
|
|
11
|
+
title: "FP.REACT Components/Card",
|
|
12
|
+
tags: ["rc"],
|
|
13
13
|
component: Card,
|
|
14
14
|
args: {
|
|
15
15
|
children: <p>{content}</p>,
|
|
16
16
|
},
|
|
17
|
-
} as Story
|
|
17
|
+
} as Story;
|
|
18
18
|
|
|
19
|
-
export default meta
|
|
20
|
-
type Story = StoryObj<typeof Card
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof Card>;
|
|
21
21
|
|
|
22
22
|
export const CardComponent: Story = {
|
|
23
23
|
args: {},
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
export const Multiple: Story = {
|
|
27
27
|
args: {
|
|
28
28
|
styles: {
|
|
29
|
-
|
|
29
|
+
"--theme": "warm",
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
render: (args) => (
|
|
33
|
-
<div style={{ display:
|
|
33
|
+
<div style={{ display: "flex", gap: "1rem", flexDirection: "column" }}>
|
|
34
34
|
<Card {...args}>
|
|
35
35
|
<p>
|
|
36
36
|
Proident et amet aliqua excepteur sunt qui deserunt commodo tempor
|
|
@@ -57,7 +57,7 @@ export const Multiple: Story = {
|
|
|
57
57
|
</Card>
|
|
58
58
|
</div>
|
|
59
59
|
),
|
|
60
|
-
} as Story
|
|
60
|
+
} as Story;
|
|
61
61
|
|
|
62
62
|
export const CardWithTitle: Story = {
|
|
63
63
|
args: {},
|
|
@@ -73,7 +73,7 @@ export const CardWithTitle: Story = {
|
|
|
73
73
|
</Card.Content>
|
|
74
74
|
</Card>
|
|
75
75
|
),
|
|
76
|
-
} as Story
|
|
76
|
+
} as Story;
|
|
77
77
|
|
|
78
78
|
export const FlexibleContent: Story = {
|
|
79
79
|
args: {
|
|
@@ -144,4 +144,4 @@ export const FlexibleContent: Story = {
|
|
|
144
144
|
</Card>
|
|
145
145
|
</div>
|
|
146
146
|
),
|
|
147
|
-
} as Story
|
|
147
|
+
} as Story;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
details {
|
|
2
2
|
--details-w: 100%;
|
|
3
|
-
--details-h:
|
|
3
|
+
--details-h: max-content;
|
|
4
4
|
--details-border: 1px solid #dfdfdf;
|
|
5
5
|
--details-display: flex;
|
|
6
6
|
--details-justify: flex-start;
|
|
@@ -10,7 +10,7 @@ details {
|
|
|
10
10
|
--details-py: 1rem;
|
|
11
11
|
--details-radius: 0.5rem;
|
|
12
12
|
--summary-cursor: pointer;
|
|
13
|
-
--summary-transitions: all 0.75s
|
|
13
|
+
--summary-transitions: all 0.75s ease-in-out;
|
|
14
14
|
--summary-display: flex;
|
|
15
15
|
--summary-justify: flex-start;
|
|
16
16
|
--summary-align: center;
|
|
@@ -18,6 +18,7 @@ details {
|
|
|
18
18
|
--max-h-closed: 6.25rem;
|
|
19
19
|
--max-h-open: 50rem;
|
|
20
20
|
|
|
21
|
+
interpolate-size: allow-keywords;
|
|
21
22
|
display: var(--details-display);
|
|
22
23
|
flex-direction: var(--details-direction);
|
|
23
24
|
justify-content: var(--details-justify);
|
|
@@ -43,19 +44,19 @@ details {
|
|
|
43
44
|
list-style: none;
|
|
44
45
|
border-top-left-radius: var(--details-radius);
|
|
45
46
|
border-top-right-radius: var(--details-radius);
|
|
47
|
+
transition: var(--summary-transitions);
|
|
46
48
|
|
|
47
49
|
&::-webkit-details-marker {
|
|
48
50
|
display: none;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
&:focus-within
|
|
53
|
+
&:focus-within {
|
|
52
54
|
outline: none;
|
|
53
55
|
border-bottom: solid 2px var(--details-border);
|
|
54
56
|
background-color: whitesmoke;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/* This ensures no bullet points are shown */
|
|
58
|
-
|
|
59
60
|
&:hover {
|
|
60
61
|
cursor: var(--summary-cursor);
|
|
61
62
|
}
|
|
@@ -72,7 +73,7 @@ details {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
&[open] {
|
|
75
|
-
max-height:
|
|
76
|
+
max-height: max-content;
|
|
76
77
|
transition: var(--summary-transitions);
|
|
77
78
|
> summary {
|
|
78
79
|
border-bottom: var(--details-border);
|
|
@@ -1,9 +1,8 @@
|
|
|
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
|
|
6
|
-
import Icons from '../icons/icon'
|
|
4
|
+
import Details from "./details";
|
|
5
|
+
import Icons from "../icons/icon";
|
|
7
6
|
|
|
8
7
|
const content = (
|
|
9
8
|
<>
|
|
@@ -25,49 +24,51 @@ const content = (
|
|
|
25
24
|
hic est placeat!
|
|
26
25
|
</p>
|
|
27
26
|
</>
|
|
28
|
-
)
|
|
27
|
+
);
|
|
29
28
|
|
|
30
|
-
const icon = <Icons.Add
|
|
29
|
+
const icon = <Icons.Add />;
|
|
31
30
|
|
|
32
31
|
const meta: Meta<typeof Details> = {
|
|
33
|
-
title:
|
|
32
|
+
title: "FP.REACT Components/Details",
|
|
34
33
|
component: Details,
|
|
34
|
+
tags: ["rc"],
|
|
35
35
|
args: {
|
|
36
|
-
// @ts-ignore
|
|
37
36
|
children: content,
|
|
38
37
|
icon: icon,
|
|
39
38
|
summary: <>Summary Section</>,
|
|
40
39
|
},
|
|
41
|
-
actions: { argTypesRegex:
|
|
40
|
+
actions: { argTypesRegex: "^on.*" },
|
|
42
41
|
decorators: [
|
|
43
42
|
(Story) => (
|
|
44
|
-
<div className="container" style={{ minWidth:
|
|
43
|
+
<div className="container" style={{ minWidth: "50vw" }}>
|
|
45
44
|
<Story />
|
|
46
45
|
</div>
|
|
47
46
|
),
|
|
48
47
|
],
|
|
49
|
-
} as Story
|
|
48
|
+
} as Story;
|
|
50
49
|
|
|
51
|
-
export default meta
|
|
52
|
-
type Story = StoryObj<typeof Details
|
|
50
|
+
export default meta;
|
|
51
|
+
type Story = StoryObj<typeof Details>;
|
|
53
52
|
|
|
54
53
|
export const DetailsDropdown: Story = {
|
|
55
54
|
args: {},
|
|
56
55
|
play: async ({ canvasElement }) => {
|
|
57
|
-
const canvas = within(canvasElement)
|
|
58
|
-
expect(
|
|
56
|
+
const canvas = within(canvasElement);
|
|
57
|
+
expect(
|
|
58
|
+
canvas.getByRole("group", { name: /details dropdown/i })
|
|
59
|
+
).toBeInTheDocument();
|
|
59
60
|
},
|
|
60
|
-
} as Story
|
|
61
|
+
} as Story;
|
|
61
62
|
|
|
62
63
|
export const DetailsOpen: Story = {
|
|
63
64
|
args: {
|
|
64
65
|
open: true,
|
|
65
66
|
},
|
|
66
67
|
play: async ({ canvasElement }) => {
|
|
67
|
-
const canvas = within(canvasElement)
|
|
68
|
-
expect(canvas.getByRole(
|
|
68
|
+
const canvas = within(canvasElement);
|
|
69
|
+
expect(canvas.getByRole("group")).toBeInTheDocument();
|
|
69
70
|
},
|
|
70
|
-
} as Story
|
|
71
|
+
} as Story;
|
|
71
72
|
|
|
72
73
|
export const CustomDropdown: Story = {
|
|
73
74
|
render: () => (
|
|
@@ -87,12 +88,12 @@ export const CustomDropdown: Story = {
|
|
|
87
88
|
</p>
|
|
88
89
|
</>
|
|
89
90
|
),
|
|
90
|
-
} as Story
|
|
91
|
+
} as Story;
|
|
91
92
|
|
|
92
93
|
export const DetailsAccordion: Story = {
|
|
93
94
|
render: () => (
|
|
94
95
|
<>
|
|
95
|
-
|
|
96
|
+
<Details
|
|
96
97
|
summary="Summary Section"
|
|
97
98
|
icon={icon}
|
|
98
99
|
ariaLabel="Details Section"
|
|
@@ -100,7 +101,7 @@ export const DetailsAccordion: Story = {
|
|
|
100
101
|
>
|
|
101
102
|
{content}
|
|
102
103
|
</Details>
|
|
103
|
-
|
|
104
|
+
<Details
|
|
104
105
|
summary="Summary Section"
|
|
105
106
|
icon={icon}
|
|
106
107
|
ariaLabel="Details Section"
|
|
@@ -108,7 +109,7 @@ export const DetailsAccordion: Story = {
|
|
|
108
109
|
>
|
|
109
110
|
{content}
|
|
110
111
|
</Details>
|
|
111
|
-
|
|
112
|
+
<Details
|
|
112
113
|
summary="Summary Section"
|
|
113
114
|
icon={icon}
|
|
114
115
|
ariaLabel="Details Section"
|
|
@@ -117,8 +118,8 @@ export const DetailsAccordion: Story = {
|
|
|
117
118
|
{content}
|
|
118
119
|
</Details>
|
|
119
120
|
</>
|
|
120
|
-
)
|
|
121
|
-
} as Story
|
|
121
|
+
),
|
|
122
|
+
} as Story;
|
|
122
123
|
|
|
123
124
|
export const DetailsInteractionTest: Story = {
|
|
124
125
|
args: {},
|
|
@@ -126,13 +127,15 @@ export const DetailsInteractionTest: Story = {
|
|
|
126
127
|
const canvas = within(canvasElement);
|
|
127
128
|
|
|
128
129
|
// Find the summary element
|
|
129
|
-
const summaryElement = canvas.getByText(
|
|
130
|
+
const summaryElement = canvas.getByText("Summary Section");
|
|
130
131
|
|
|
131
132
|
// Simulate a click on the summary element
|
|
132
133
|
await userEvent.click(summaryElement);
|
|
133
134
|
|
|
134
135
|
// Assert that the details element is open
|
|
135
|
-
const detailsElement = canvas.getByRole(
|
|
136
|
-
|
|
136
|
+
const detailsElement = canvas.getByRole("group", {
|
|
137
|
+
name: /details dropdown/i,
|
|
138
|
+
});
|
|
139
|
+
expect(detailsElement).toHaveAttribute("open");
|
|
137
140
|
},
|
|
138
|
-
}
|
|
141
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import UI from
|
|
2
|
-
import React from
|
|
1
|
+
import UI from "#components/ui";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
4
|
type DetailsProps = {
|
|
5
5
|
/**
|
|
6
6
|
* The summary text shown for the details.
|
|
7
7
|
* Required.
|
|
8
8
|
*/
|
|
9
|
-
summary: React.ReactNode
|
|
9
|
+
summary: React.ReactNode;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The aria-label element for accessibility.
|
|
13
13
|
*/
|
|
14
|
-
ariaLabel: string
|
|
15
|
-
} & React.ComponentProps<
|
|
16
|
-
Partial<React.ComponentProps<typeof UI
|
|
14
|
+
ariaLabel: string;
|
|
15
|
+
} & React.ComponentProps<"details"> &
|
|
16
|
+
Partial<React.ComponentProps<typeof UI>>;
|
|
17
17
|
|
|
18
18
|
/**3
|
|
19
19
|
* Details component props interface.
|
|
@@ -42,16 +42,16 @@ export const Details = ({
|
|
|
42
42
|
ref,
|
|
43
43
|
...props
|
|
44
44
|
}: DetailsProps) => {
|
|
45
|
-
const defaultStyles: React.CSSProperties = { ...styles }
|
|
45
|
+
const defaultStyles: React.CSSProperties = { ...styles };
|
|
46
46
|
|
|
47
47
|
const onPointerDownCallback = (e: React.PointerEvent<HTMLDetailsElement>) => {
|
|
48
|
-
if (onPointerDown) onPointerDown?.(e)
|
|
49
|
-
if (onPointerDown) onPointerDown?.(e)
|
|
50
|
-
}
|
|
48
|
+
if (onPointerDown) onPointerDown?.(e);
|
|
49
|
+
if (onPointerDown) onPointerDown?.(e);
|
|
50
|
+
};
|
|
51
51
|
|
|
52
52
|
const onToggleCallback = (e: React.PointerEvent<HTMLDetailsElement>) => {
|
|
53
|
-
if (onToggle) onPointerDown?.(e)
|
|
54
|
-
}
|
|
53
|
+
if (onToggle) onPointerDown?.(e);
|
|
54
|
+
};
|
|
55
55
|
return (
|
|
56
56
|
<UI
|
|
57
57
|
as="details"
|
|
@@ -60,7 +60,7 @@ export const Details = ({
|
|
|
60
60
|
onToggle={onToggleCallback}
|
|
61
61
|
ref={ref}
|
|
62
62
|
open={open}
|
|
63
|
-
aria-label={ariaLabel ||
|
|
63
|
+
aria-label={ariaLabel || "Details dropdown"}
|
|
64
64
|
// aria-roledescription="detail accordion"
|
|
65
65
|
name={name}
|
|
66
66
|
{...props}
|
|
@@ -71,8 +71,8 @@ export const Details = ({
|
|
|
71
71
|
</UI>
|
|
72
72
|
<UI as="section">{children}</UI>
|
|
73
73
|
</UI>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
76
|
|
|
77
|
-
export default Details
|
|
78
|
-
Details.displayName =
|
|
77
|
+
export default Details;
|
|
78
|
+
Details.displayName = "Details";
|