@dxc-technology/halstack-react 0.0.0-e081e21 → 0.0.0-e1a279c
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/accordion/Accordion.d.ts +4 -0
- package/accordion/Accordion.js +12 -43
- package/accordion/types.d.ts +68 -0
- package/accordion/types.js +5 -0
- package/accordion-group/AccordionGroup.d.ts +7 -0
- package/accordion-group/AccordionGroup.js +58 -72
- package/accordion-group/types.d.ts +72 -0
- package/accordion-group/types.js +5 -0
- package/alert/Alert.stories.tsx +170 -0
- package/box/Box.d.ts +4 -0
- package/box/Box.js +9 -32
- package/box/Box.stories.tsx +132 -0
- package/box/types.d.ts +47 -0
- package/box/types.js +5 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +7 -12
- package/button/Button.stories.tsx +244 -274
- package/button/types.d.ts +10 -10
- package/card/Card.d.ts +4 -0
- package/card/Card.js +13 -48
- package/card/types.d.ts +69 -0
- package/card/types.js +5 -0
- package/checkbox/Checkbox.stories.tsx +192 -0
- package/checkbox/types.d.ts +2 -3
- package/chip/Chip.stories.tsx +121 -0
- package/common/variables.js +30 -22
- package/date-input/DateInput.d.ts +4 -0
- package/date-input/DateInput.js +3 -38
- package/date-input/DateInput.stories.tsx +138 -0
- package/date-input/types.d.ts +100 -0
- package/date-input/types.js +5 -0
- package/dialog/Dialog.d.ts +4 -0
- package/dialog/Dialog.js +4 -23
- package/dialog/Dialog.stories.tsx +212 -0
- package/dialog/types.d.ts +43 -0
- package/dialog/types.js +5 -0
- package/dropdown/Dropdown.d.ts +4 -0
- package/dropdown/Dropdown.js +7 -40
- package/dropdown/types.d.ts +89 -0
- package/dropdown/types.js +5 -0
- package/footer/Footer.d.ts +4 -0
- package/footer/Footer.js +4 -35
- package/footer/Footer.stories.jsx +151 -0
- package/footer/types.d.ts +61 -0
- package/footer/types.js +5 -0
- package/header/Header.d.ts +7 -0
- package/header/Header.js +26 -28
- package/header/Icons.js +2 -27
- package/header/types.d.ts +45 -0
- package/header/types.js +5 -0
- package/link/Link.d.ts +3 -0
- package/link/Link.js +1 -23
- package/link/Link.stories.tsx +70 -0
- package/link/types.d.ts +74 -0
- package/link/types.js +5 -0
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +2 -44
- package/number-input/NumberInput.stories.tsx +115 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +3 -3
- package/paginator/Paginator.stories.tsx +63 -0
- package/password-input/PasswordInput.d.ts +4 -0
- package/password-input/PasswordInput.js +2 -39
- package/password-input/PasswordInput.stories.tsx +131 -0
- package/password-input/types.d.ts +100 -0
- package/password-input/types.js +5 -0
- package/progress-bar/ProgressBar.d.ts +4 -0
- package/progress-bar/ProgressBar.js +3 -21
- package/progress-bar/ProgressBar.stories.jsx +58 -0
- package/progress-bar/types.d.ts +37 -0
- package/progress-bar/types.js +5 -0
- package/radio/Radio.d.ts +4 -0
- package/radio/Radio.js +3 -24
- package/radio/Radio.stories.tsx +192 -0
- package/radio/types.d.ts +54 -0
- package/radio/types.js +5 -0
- package/select/Select.stories.tsx +572 -0
- package/select/index.d.ts +4 -4
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +4 -13
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +4 -0
- package/slider/Slider.js +59 -82
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +78 -0
- package/slider/types.js +5 -0
- package/spinner/Spinner.d.ts +4 -0
- package/spinner/Spinner.js +6 -23
- package/spinner/Spinner.stories.jsx +102 -0
- package/spinner/types.d.ts +32 -0
- package/spinner/types.js +5 -0
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +160 -0
- package/table/Table.d.ts +4 -0
- package/table/Table.stories.jsx +276 -0
- package/table/types.d.ts +21 -0
- package/table/types.js +5 -0
- package/tabs/Tabs.d.ts +4 -0
- package/tabs/Tabs.js +5 -53
- package/tabs/types.d.ts +71 -0
- package/tabs/types.js +5 -0
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +20 -35
- package/tag/Tag.stories.tsx +145 -0
- package/tag/types.d.ts +60 -0
- package/tag/types.js +5 -0
- package/text-input/index.d.ts +2 -2
- package/textarea/Textarea.stories.jsx +135 -0
- package/toggle-group/ToggleGroup.stories.tsx +178 -0
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +11 -51
- package/wizard/Wizard.stories.jsx +224 -0
- package/wizard/types.d.ts +64 -0
- package/wizard/types.js +5 -0
- package/accordion/index.d.ts +0 -28
- package/accordion-group/index.d.ts +0 -16
- package/box/index.d.ts +0 -25
- package/card/index.d.ts +0 -22
- package/date-input/index.d.ts +0 -95
- package/dialog/index.d.ts +0 -18
- package/dropdown/index.d.ts +0 -26
- package/footer/index.d.ts +0 -25
- package/header/index.d.ts +0 -25
- package/link/index.d.ts +0 -23
- package/number-input/index.d.ts +0 -113
- package/password-input/index.d.ts +0 -94
- package/progress-bar/index.d.ts +0 -18
- package/radio/index.d.ts +0 -23
- package/sidenav/index.d.ts +0 -13
- package/slider/index.d.ts +0 -29
- package/spinner/index.d.ts +0 -17
- package/table/index.d.ts +0 -13
- package/tabs/index.d.ts +0 -19
- package/tag/index.d.ts +0 -24
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import DxcTag from "./Tag";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Tag",
|
|
9
|
+
component: DxcTag,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const icon = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
16
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const largeIcon = () => {
|
|
21
|
+
return (
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
|
|
23
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
24
|
+
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Chromatic = () => (
|
|
30
|
+
<>
|
|
31
|
+
<ExampleContainer>
|
|
32
|
+
<Title title="Without label" theme="light" level={4} />
|
|
33
|
+
<DxcTag />
|
|
34
|
+
</ExampleContainer>
|
|
35
|
+
<ExampleContainer>
|
|
36
|
+
<Title title="With icon" theme="light" level={4} />
|
|
37
|
+
<DxcTag icon={icon} />
|
|
38
|
+
</ExampleContainer>
|
|
39
|
+
<ExampleContainer>
|
|
40
|
+
<Title title="With large icon" theme="light" level={4} />
|
|
41
|
+
<DxcTag icon={largeIcon} />
|
|
42
|
+
</ExampleContainer>
|
|
43
|
+
<ExampleContainer>
|
|
44
|
+
<Title title="With label" theme="light" level={4} />
|
|
45
|
+
<DxcTag label="Tag" />
|
|
46
|
+
</ExampleContainer>
|
|
47
|
+
<ExampleContainer>
|
|
48
|
+
<Title title="With label and icon" theme="light" level={4} />
|
|
49
|
+
<DxcTag label="Tag" icon={icon} />
|
|
50
|
+
</ExampleContainer>
|
|
51
|
+
<ExampleContainer>
|
|
52
|
+
<Title title="With right icon" theme="light" level={4} />
|
|
53
|
+
<DxcTag label="Tag" icon={icon} labelPosition="before" />
|
|
54
|
+
</ExampleContainer>
|
|
55
|
+
<ExampleContainer>
|
|
56
|
+
<Title title="Icon background color" theme="light" level={4} />
|
|
57
|
+
<DxcTag label="Tag" icon={icon} iconBgColor="#fabada" />
|
|
58
|
+
</ExampleContainer>
|
|
59
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
60
|
+
<Title title="With link focused" theme="light" level={4} />
|
|
61
|
+
<DxcTag icon={icon} label="Tag" linkHref="https://www.dxc.com" />
|
|
62
|
+
</ExampleContainer>
|
|
63
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
64
|
+
<Title title="With action focused" theme="light" level={4} />
|
|
65
|
+
<DxcTag
|
|
66
|
+
icon={icon}
|
|
67
|
+
label="Tag"
|
|
68
|
+
onClick={() => {
|
|
69
|
+
console.log("click");
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
</ExampleContainer>
|
|
73
|
+
<Title title="Margins" theme="light" level={2} />
|
|
74
|
+
<ExampleContainer>
|
|
75
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
76
|
+
<DxcTag label="Xxsmall" margin="xxsmall" />
|
|
77
|
+
</ExampleContainer>
|
|
78
|
+
<ExampleContainer>
|
|
79
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
80
|
+
<DxcTag label="Xsmall" margin="xsmall" />
|
|
81
|
+
</ExampleContainer>
|
|
82
|
+
<ExampleContainer>
|
|
83
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
84
|
+
<DxcTag label="Small" margin="small" />
|
|
85
|
+
</ExampleContainer>
|
|
86
|
+
<ExampleContainer>
|
|
87
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
88
|
+
<DxcTag label="Medium" margin="medium" />
|
|
89
|
+
</ExampleContainer>
|
|
90
|
+
<ExampleContainer>
|
|
91
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
92
|
+
<DxcTag label="Large" margin="large" />
|
|
93
|
+
</ExampleContainer>
|
|
94
|
+
<ExampleContainer>
|
|
95
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
96
|
+
<DxcTag label="Xlarge" margin="xlarge" />
|
|
97
|
+
</ExampleContainer>
|
|
98
|
+
<ExampleContainer>
|
|
99
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
100
|
+
<DxcTag label="Xxlarge" margin="xxlarge" />
|
|
101
|
+
</ExampleContainer>
|
|
102
|
+
<Title title="Sizes" theme="light" level={2} />
|
|
103
|
+
<ExampleContainer>
|
|
104
|
+
<Title title="Small size" theme="light" level={4} />
|
|
105
|
+
<DxcTag label="Small" size="small" />
|
|
106
|
+
</ExampleContainer>
|
|
107
|
+
<ExampleContainer>
|
|
108
|
+
<Title title="Medium size" theme="light" level={4} />
|
|
109
|
+
<DxcTag label="Medium size medium s" size="medium" />
|
|
110
|
+
</ExampleContainer>
|
|
111
|
+
<ExampleContainer>
|
|
112
|
+
<Title title="Medium size with ellipsis" theme="light" level={4} />
|
|
113
|
+
<DxcTag label="Medium size medium si medium" size="medium" />
|
|
114
|
+
</ExampleContainer>
|
|
115
|
+
<ExampleContainer>
|
|
116
|
+
<Title title="Large size" theme="light" level={4} />
|
|
117
|
+
<DxcTag label="Large size large size large size large size large size" size="large" />
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
<ExampleContainer>
|
|
120
|
+
<Title title="Large size with ellipsis" theme="light" level={4} />
|
|
121
|
+
<DxcTag label="Large size large size large size large size large size large size" size="large" />
|
|
122
|
+
</ExampleContainer>
|
|
123
|
+
<ExampleContainer>
|
|
124
|
+
<Title title="FillParent size" theme="light" level={4} />
|
|
125
|
+
<DxcTag label="FillParent" size="fillParent" />
|
|
126
|
+
</ExampleContainer>
|
|
127
|
+
<ExampleContainer>
|
|
128
|
+
<Title title="FitContent size" theme="light" level={4} />
|
|
129
|
+
<DxcTag label="FitContent" size="fitContent" />
|
|
130
|
+
</ExampleContainer>
|
|
131
|
+
</>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const LinkTag = () => (
|
|
135
|
+
<ExampleContainer>
|
|
136
|
+
<Title title="Hover link tag" theme="light" level={4} />
|
|
137
|
+
<DxcTag label="Tag" icon={icon} linkHref="https://www.dxc.com" />
|
|
138
|
+
</ExampleContainer>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const HoverLinkTag = LinkTag.bind({});
|
|
142
|
+
HoverLinkTag.play = async ({ canvasElement }) => {
|
|
143
|
+
const canvas = within(canvasElement);
|
|
144
|
+
await userEvent.hover(canvas.getByText("Tag"));
|
|
145
|
+
};
|
package/tag/types.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Element used as the icon that will be placed next to the label.
|
|
13
|
+
*/
|
|
14
|
+
icon?: SVG;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated URL of the icon.
|
|
17
|
+
*/
|
|
18
|
+
iconSrc?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Text to be placed next inside the tag.
|
|
21
|
+
*/
|
|
22
|
+
label?: string;
|
|
23
|
+
/**
|
|
24
|
+
* If defined, the tag will be displayed as an anchor, using this prop as "href".
|
|
25
|
+
* Component will show some visual feedback on hover.
|
|
26
|
+
*/
|
|
27
|
+
linkHref?: string;
|
|
28
|
+
/**
|
|
29
|
+
* If defined, the tag will be displayed as a button. This function will
|
|
30
|
+
* be called when the user clicks the tag. Component will show some
|
|
31
|
+
* visual feedback on hover.
|
|
32
|
+
*/
|
|
33
|
+
onClick?: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Background color of the icon section of the tag.
|
|
36
|
+
*/
|
|
37
|
+
iconBgColor?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the label should appear after or before the icon.
|
|
40
|
+
*/
|
|
41
|
+
labelPosition?: "before" | "after";
|
|
42
|
+
/**
|
|
43
|
+
* If true, the page is opened in a new browser tab.
|
|
44
|
+
*/
|
|
45
|
+
newWindow?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
48
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
49
|
+
*/
|
|
50
|
+
margin?: Space | Margin;
|
|
51
|
+
/**
|
|
52
|
+
* Size of the component.
|
|
53
|
+
*/
|
|
54
|
+
size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
|
|
55
|
+
/**
|
|
56
|
+
* Value of the tabindex attribute.
|
|
57
|
+
*/
|
|
58
|
+
tabIndex?: number;
|
|
59
|
+
};
|
|
60
|
+
export default Props;
|
package/tag/types.js
ADDED
package/text-input/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
type SVG =
|
|
9
|
+
type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
10
10
|
type Action = {
|
|
11
11
|
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
-
icon: SVG;
|
|
12
|
+
icon: string | SVG;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
type Props = {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DxcTextarea from "./Textarea";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
|
+
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Textarea",
|
|
10
|
+
component: DxcTextarea,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Chromatic = () => (
|
|
14
|
+
<>
|
|
15
|
+
<>
|
|
16
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
17
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
18
|
+
<DxcTextarea label="Hovered" />
|
|
19
|
+
</ExampleContainer>
|
|
20
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
21
|
+
<Title title="Focused" theme="light" level={4} />
|
|
22
|
+
<DxcTextarea label="Focused" />
|
|
23
|
+
</ExampleContainer>
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
26
|
+
<DxcTextarea
|
|
27
|
+
label="Disabled"
|
|
28
|
+
optional
|
|
29
|
+
helperText="Sample text"
|
|
30
|
+
placeholder="Enter your text here..."
|
|
31
|
+
disabled
|
|
32
|
+
/>
|
|
33
|
+
</ExampleContainer>
|
|
34
|
+
<ExampleContainer>
|
|
35
|
+
<Title title="Disabled with value" theme="light" level={4} />
|
|
36
|
+
<DxcTextarea label="Disabled" value="Example text" disabled />
|
|
37
|
+
</ExampleContainer>
|
|
38
|
+
<ExampleContainer>
|
|
39
|
+
<Title title="With error" theme="light" level={4} />
|
|
40
|
+
<DxcTextarea
|
|
41
|
+
label="Textarea with error"
|
|
42
|
+
helperText="Helper text"
|
|
43
|
+
placeholder="Enter your text here..."
|
|
44
|
+
error="Error message"
|
|
45
|
+
/>
|
|
46
|
+
</ExampleContainer>
|
|
47
|
+
<ExampleContainer>
|
|
48
|
+
<Title title="Helper text and optional with value" theme="light" level={4} />
|
|
49
|
+
<DxcTextarea label="Helper & optional" value="Some text" helperText="Sample text" optional />
|
|
50
|
+
</ExampleContainer>
|
|
51
|
+
<ExampleContainer>
|
|
52
|
+
<Title title="Resizable" theme="light" level={4} />
|
|
53
|
+
<DxcTextarea label="With resizer" helperText="Helper text" verticalGrow="manual" />
|
|
54
|
+
</ExampleContainer>
|
|
55
|
+
<ExampleContainer>
|
|
56
|
+
<Title title="Grow manual" theme="light" level={4} />
|
|
57
|
+
<DxcTextarea
|
|
58
|
+
label="Manual vertical grow"
|
|
59
|
+
verticalGrow="manual"
|
|
60
|
+
value="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
61
|
+
/>
|
|
62
|
+
</ExampleContainer>
|
|
63
|
+
</>
|
|
64
|
+
<BackgroundColorProvider color="#333333">
|
|
65
|
+
<DarkContainer>
|
|
66
|
+
<>
|
|
67
|
+
<Title title="Helper text and optional with value" theme="dark" level={4} />
|
|
68
|
+
<DxcTextarea label="Helper & optional" value="Some text" margin="medium" helperText="Sample text" optional />
|
|
69
|
+
|
|
70
|
+
<Title title="Disabled" theme="dark" level={4} />
|
|
71
|
+
<DxcTextarea
|
|
72
|
+
label="Disabled"
|
|
73
|
+
margin="medium"
|
|
74
|
+
optional
|
|
75
|
+
helperText="Sample text"
|
|
76
|
+
placeholder="Enter your text here..."
|
|
77
|
+
disabled
|
|
78
|
+
/>
|
|
79
|
+
<Title title="Disabled with value" theme="dark" level={4} />
|
|
80
|
+
<DxcTextarea label="Disabled" margin="medium" value="Example text" disabled />
|
|
81
|
+
<Title title="With error" theme="dark" level={4} />
|
|
82
|
+
<DxcTextarea
|
|
83
|
+
label="Textarea with error"
|
|
84
|
+
margin="medium"
|
|
85
|
+
helperText="Helper text"
|
|
86
|
+
placeholder="Enter your text here..."
|
|
87
|
+
error="Error message"
|
|
88
|
+
/>
|
|
89
|
+
</>
|
|
90
|
+
</DarkContainer>
|
|
91
|
+
</BackgroundColorProvider>
|
|
92
|
+
<Title title="Sizes" theme="light" level={2} />
|
|
93
|
+
<ExampleContainer>
|
|
94
|
+
<DxcTextarea label="Small" size="small" />
|
|
95
|
+
</ExampleContainer>
|
|
96
|
+
<ExampleContainer>
|
|
97
|
+
<DxcTextarea label="Medium" size="medium" />
|
|
98
|
+
</ExampleContainer>
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<DxcTextarea label="Large" size="large" />
|
|
101
|
+
</ExampleContainer>
|
|
102
|
+
<ExampleContainer>
|
|
103
|
+
<DxcTextarea label="Fill parent" size="fillParent" />
|
|
104
|
+
</ExampleContainer>
|
|
105
|
+
<Title title="Margins" theme="light" level={2} />
|
|
106
|
+
<ExampleContainer>
|
|
107
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
108
|
+
<DxcTextarea label="Xxsmmall" margin="xxsmall" />
|
|
109
|
+
</ExampleContainer>
|
|
110
|
+
<ExampleContainer>
|
|
111
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
112
|
+
<DxcTextarea label="xsmmall" margin="xsmall" />
|
|
113
|
+
</ExampleContainer>
|
|
114
|
+
<ExampleContainer>
|
|
115
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
116
|
+
<DxcTextarea label="smmall" margin="small" />
|
|
117
|
+
</ExampleContainer>
|
|
118
|
+
<ExampleContainer>
|
|
119
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
120
|
+
<DxcTextarea label="medium" margin="medium" />
|
|
121
|
+
</ExampleContainer>
|
|
122
|
+
<ExampleContainer>
|
|
123
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
124
|
+
<DxcTextarea label="Large" margin="large" />
|
|
125
|
+
</ExampleContainer>
|
|
126
|
+
<ExampleContainer>
|
|
127
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
128
|
+
<DxcTextarea label="Xlarge" margin="xlarge" />
|
|
129
|
+
</ExampleContainer>
|
|
130
|
+
<ExampleContainer>
|
|
131
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
132
|
+
<DxcTextarea label="Xxlarge" margin="xxlarge" />
|
|
133
|
+
</ExampleContainer>
|
|
134
|
+
</>
|
|
135
|
+
);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcToggleGroup from "./ToggleGroup";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "ToggleGroup",
|
|
9
|
+
component: DxcToggleGroup,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ethernetSVG = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
16
|
+
<path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const gMobileSVG = () => {
|
|
21
|
+
return (
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
23
|
+
<g>
|
|
24
|
+
<path d="M0,0h24v24H0V0z" fill="none" />
|
|
25
|
+
</g>
|
|
26
|
+
<g>
|
|
27
|
+
<g>
|
|
28
|
+
<path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z" />
|
|
29
|
+
</g>
|
|
30
|
+
</g>
|
|
31
|
+
</svg>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
const wifiSVG = () => {
|
|
35
|
+
return (
|
|
36
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
37
|
+
<path d="M0 0h24v24H0V0zm0 0h24v24H0V0z" fill="none" />
|
|
38
|
+
<path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z" />
|
|
39
|
+
</svg>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
const options = [
|
|
43
|
+
{
|
|
44
|
+
value: 1,
|
|
45
|
+
label: "Facebook",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 2,
|
|
49
|
+
label: "Twitter",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: 3,
|
|
53
|
+
label: "Linkedin",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
const optionsWithIcon = [
|
|
57
|
+
{
|
|
58
|
+
value: 1,
|
|
59
|
+
icon: wifiSVG,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 2,
|
|
63
|
+
icon: ethernetSVG,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 3,
|
|
67
|
+
icon: gMobileSVG,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const optionsWithIconAndLabel = [
|
|
71
|
+
{
|
|
72
|
+
value: 1,
|
|
73
|
+
label: "Wi-fi",
|
|
74
|
+
icon: wifiSVG,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: 2,
|
|
78
|
+
label: "Ethernet",
|
|
79
|
+
icon: ethernetSVG,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: 3,
|
|
83
|
+
label: "3G Mobile",
|
|
84
|
+
icon: gMobileSVG,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
const twoOptions = [
|
|
88
|
+
{
|
|
89
|
+
value: 1,
|
|
90
|
+
label: "Facebook",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
value: 2,
|
|
94
|
+
label: "Twitter",
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
export const Chromatic = () => (
|
|
98
|
+
<>
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<Title title="Basic toggle group" theme="light" level={4} />
|
|
101
|
+
<DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />
|
|
102
|
+
</ExampleContainer>
|
|
103
|
+
<ExampleContainer>
|
|
104
|
+
<Title title="Selected" theme="light" level={4} />
|
|
105
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" value={2} options={options} />
|
|
106
|
+
</ExampleContainer>
|
|
107
|
+
<ExampleContainer>
|
|
108
|
+
<Title title="Icons toggle group" theme="light" level={4} />
|
|
109
|
+
<DxcToggleGroup label="Icons group" options={optionsWithIcon} />
|
|
110
|
+
</ExampleContainer>
|
|
111
|
+
<ExampleContainer>
|
|
112
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
113
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
114
|
+
</ExampleContainer>
|
|
115
|
+
<ExampleContainer>
|
|
116
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
117
|
+
<DxcToggleGroup label="Disabled" value={2} options={options} disabled />
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
120
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
121
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} value={2} />
|
|
122
|
+
</ExampleContainer>
|
|
123
|
+
<ExampleContainer>
|
|
124
|
+
<Title title="Multiple toggleGroup" theme="light" level={4} />
|
|
125
|
+
<DxcToggleGroup
|
|
126
|
+
label="Toggle group"
|
|
127
|
+
helperText="Please select one or more"
|
|
128
|
+
options={options}
|
|
129
|
+
value={[1, 3]}
|
|
130
|
+
multiple
|
|
131
|
+
></DxcToggleGroup>
|
|
132
|
+
</ExampleContainer>
|
|
133
|
+
<Title title="Margins" theme="light" level={2} />
|
|
134
|
+
<ExampleContainer>
|
|
135
|
+
<Title title="xxSmall" theme="light" level={4} />
|
|
136
|
+
<DxcToggleGroup label="xxSmall margin" options={options} margin="xxsmall" />
|
|
137
|
+
</ExampleContainer>
|
|
138
|
+
<ExampleContainer>
|
|
139
|
+
<Title title="xSmall" theme="light" level={4} />
|
|
140
|
+
<DxcToggleGroup label="xSmall margin" options={options} margin="xsmall" />
|
|
141
|
+
</ExampleContainer>
|
|
142
|
+
<ExampleContainer>
|
|
143
|
+
<Title title="Small" theme="light" level={4} />
|
|
144
|
+
<DxcToggleGroup label="Small margin" options={options} margin="small" />
|
|
145
|
+
</ExampleContainer>
|
|
146
|
+
<ExampleContainer>
|
|
147
|
+
<Title title="Medium" theme="light" level={4} />
|
|
148
|
+
<DxcToggleGroup label="Medium margin" options={options} margin="medium" />
|
|
149
|
+
</ExampleContainer>
|
|
150
|
+
<ExampleContainer>
|
|
151
|
+
<Title title="Large" theme="light" level={4} />
|
|
152
|
+
<DxcToggleGroup label="Large margin" options={options} margin="large" />
|
|
153
|
+
</ExampleContainer>
|
|
154
|
+
<ExampleContainer>
|
|
155
|
+
<Title title="xLarge" theme="light" level={4} />
|
|
156
|
+
<DxcToggleGroup label="xLarge margin" options={options} margin="xlarge" />
|
|
157
|
+
</ExampleContainer>
|
|
158
|
+
<ExampleContainer>
|
|
159
|
+
<Title title="xxLarge" theme="light" level={4} />
|
|
160
|
+
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
161
|
+
</ExampleContainer>
|
|
162
|
+
</>
|
|
163
|
+
);
|
|
164
|
+
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
165
|
+
|
|
166
|
+
export const ToggleGroupSelectedActived = OptionSelected.bind({});
|
|
167
|
+
ToggleGroupSelectedActived.play = async ({ canvasElement }) => {
|
|
168
|
+
const canvas = within(canvasElement);
|
|
169
|
+
const option = canvas.getByText("Linkedin");
|
|
170
|
+
await userEvent.click(option);
|
|
171
|
+
};
|
|
172
|
+
export const ToggleGroupUnselectedActived = OptionSelected.bind({});
|
|
173
|
+
ToggleGroupUnselectedActived.play = async ({ canvasElement }) => {
|
|
174
|
+
const canvas = within(canvasElement);
|
|
175
|
+
const option = canvas.getByText("Twitter");
|
|
176
|
+
await userEvent.click(option);
|
|
177
|
+
userEvent.tab();
|
|
178
|
+
};
|