-
Notifications
You must be signed in to change notification settings - Fork 14
/
Breadcrumbs.stories.tsx
194 lines (190 loc) · 5.26 KB
/
Breadcrumbs.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import React from "react";
import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import DxcBreadcrumbs from "./Breadcrumbs";
import DxcContainer from "../container/Container";
import { HalstackProvider } from "../HalstackContext";
import { userEvent, within } from "@storybook/testing-library";
import { disabledRules } from "../../test/accessibility/rules/specific/breadcrumbs/disabledRules";
import preview from "../../.storybook/preview";
export default {
title: "Breadcrumbs",
component: DxcBreadcrumbs,
parameters: {
a11y: {
config: {
rules: [
...disabledRules.map((ruleId) => ({ id: ruleId, enabled: false })),
...preview?.parameters?.a11y?.config?.rules,
],
},
},
},
};
const items = [
{
label: "Home",
href: "/",
},
{
label: "User Menu",
href: "",
},
{
label: "Preferences",
href: "",
},
{
label: "Customization",
href: "",
},
{
label: "Dark Mode",
href: "",
},
];
const Breadcrumbs = () => (
<>
<Title title="Default" theme="light" level={3} />
<ExampleContainer>
<DxcBreadcrumbs
items={[
{
label: "Home",
href: "/",
},
{
label: "User Menu",
href: "",
},
{
label: "Preferences",
href: "",
},
{
label: "Dark Mode",
href: "",
},
]}
/>
</ExampleContainer>
<Title title="Collapsed variant" theme="light" level={3} />
<ExampleContainer>
<DxcBreadcrumbs items={items} />
</ExampleContainer>
<Title title="Collapsed variant without root" theme="light" level={3} />
<ExampleContainer>
<DxcBreadcrumbs items={items} showRoot={false} />
</ExampleContainer>
<Title title="Collapsed variant with dropdown menu opened" theme="light" level={3} />
<ExampleContainer>
<DxcContainer height="150px">
<DxcBreadcrumbs items={items} />
</DxcContainer>
</ExampleContainer>
<Title title="Focus state" theme="light" level={3} />
<ExampleContainer pseudoState="pseudo-focus">
<DxcBreadcrumbs items={items} />
</ExampleContainer>
<Title title="Hover state" theme="light" level={3} />
<ExampleContainer pseudoState="pseudo-hover">
<DxcBreadcrumbs items={items} />
</ExampleContainer>
<Title title="Active state" theme="light" level={3} />
<ExampleContainer pseudoState="pseudo-active">
<DxcBreadcrumbs items={items} />
</ExampleContainer>
<Title title="Truncation and text ellipsis with tooltip (only when collapsed)" theme="light" level={3} />
<ExampleContainer>
<DxcContainer width="200px">
<DxcBreadcrumbs
items={[
{
label: "Root",
href: "/",
},
{
label: "Main folder",
href: "",
},
{
label: "User",
href: "",
},
{
label: "Very long label for the link",
href: "",
},
]}
itemsBeforeCollapse={3}
/>
</DxcContainer>
</ExampleContainer>
<Title title="Truncation, text ellipsis with tooltip and without root" theme="light" level={3} />
<ExampleContainer>
<DxcContainer width="200px">
<DxcBreadcrumbs
items={[
{
label: "Root",
href: "/",
},
{
label: "Main folder",
href: "",
},
{
label: "User",
href: "",
},
{
label: "Very long label for the link",
href: "",
},
]}
itemsBeforeCollapse={3}
showRoot={false}
/>
</DxcContainer>
</ExampleContainer>
<Title title="Dropdown theming doesn't affect the collapsed trigger" theme="light" level={3} />
<ExampleContainer>
<Title title="Opinionated theming" theme="light" level={4} />
<ExampleContainer>
<HalstackProvider
theme={{
dropdown: {
baseColor: "#fabada",
fontColor: "#999",
optionFontColor: "#4d4d4d",
},
}}
>
<DxcBreadcrumbs items={items} itemsBeforeCollapse={3} />
</HalstackProvider>
</ExampleContainer>
<Title title="Advanced theming" theme="light" level={4} />
<ExampleContainer>
<HalstackProvider
advancedTheme={{
dropdown: {
buttonBackgroundColor: "#fabada",
buttonHeight: "100px",
buttonBorderThickness: "2px",
buttonBorderStyle: "solid",
buttonBorderColor: "#000",
},
}}
>
<DxcBreadcrumbs items={items} itemsBeforeCollapse={3} />
</HalstackProvider>
</ExampleContainer>
</ExampleContainer>
</>
);
export const Chromatic = Breadcrumbs.bind({});
Chromatic.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
const dropdowns = canvas.getAllByRole("button");
await userEvent.click(dropdowns[2]);
};