@dxc-technology/halstack-react 0.0.0-d3ac293 → 0.0.0-d3df47e
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/BackgroundColorContext.d.ts +1 -10
- package/BackgroundColorContext.js +4 -21
- package/HalstackContext.d.ts +24 -139
- package/HalstackContext.js +11 -36
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +26 -83
- package/accordion/Accordion.stories.tsx +2 -114
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -17
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +27 -75
- package/accordion-group/AccordionGroup.stories.tsx +78 -77
- package/accordion-group/AccordionGroup.test.js +43 -71
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +6 -18
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/alert/Alert.js +17 -56
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +142 -42
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +16 -55
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +19 -53
- package/bulleted-list/BulletedList.stories.tsx +8 -93
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +66 -100
- package/button/Button.stories.tsx +9 -90
- package/button/Button.test.js +19 -16
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +47 -88
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +6 -12
- package/checkbox/Checkbox.js +85 -120
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +34 -68
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.js +2 -8
- package/common/variables.d.ts +24 -282
- package/common/variables.js +860 -1125
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/date-input/Calendar.js +15 -59
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +15 -60
- package/dialog/Dialog.stories.tsx +215 -169
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -26
- package/dropdown/Dropdown.js +39 -93
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +13 -20
- package/dropdown/DropdownMenuItem.js +5 -19
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +180 -249
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +356 -354
- package/file-input/FileItem.js +14 -41
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +27 -39
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +74 -9
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +69 -116
- package/footer/Footer.stories.tsx +38 -95
- package/footer/Footer.test.js +21 -33
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -27
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/grid/types.js +5 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +33 -116
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -20
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.js +13 -21
- package/inset/Inset.stories.tsx +2 -1
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +28 -65
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +5 -6
- package/link/Link.js +23 -44
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +7 -4
- package/main.js +32 -58
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +22 -54
- package/nav-tabs/NavTabs.stories.tsx +21 -5
- package/nav-tabs/NavTabs.test.js +38 -44
- package/nav-tabs/Tab.js +40 -72
- package/nav-tabs/types.d.ts +14 -15
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +26 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +700 -412
- package/number-input/types.d.ts +11 -5
- package/package.json +30 -28
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +17 -47
- package/paginator/Paginator.test.js +229 -199
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +2 -3
- package/paragraph/Paragraph.js +3 -19
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +157 -140
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +21 -53
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +31 -63
- package/radio-group/RadioGroup.js +45 -93
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +1 -1
- package/{resultsetTable → resultset-table}/ResultsetTable.js +33 -63
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +19 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
- package/{resultsetTable → resultset-table}/types.d.ts +13 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +17 -27
- package/select/Select.js +92 -166
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1946 -1804
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +80 -150
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +31 -28
- package/slider/Slider.js +68 -126
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +28 -72
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +28 -28
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.js +49 -97
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/Table.d.ts +1 -1
- package/table/Table.js +23 -30
- package/table/{Table.stories.jsx → Table.stories.tsx} +98 -0
- package/table/Table.test.js +1 -6
- package/table/types.d.ts +12 -6
- package/tabs/Tab.js +19 -36
- package/tabs/Tabs.js +61 -144
- package/tabs/Tabs.stories.tsx +1 -1
- package/tabs/Tabs.test.js +65 -121
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +26 -58
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +11 -28
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +15 -65
- package/text-input/TextInput.js +217 -318
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1210 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +68 -111
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +151 -182
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +91 -105
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +68 -87
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +21 -136
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +28 -43
- package/wizard/Wizard.js +15 -50
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +8 -9
- package/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/Icons.d.ts +0 -7
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
5
|
import DxcBulletedList from "./BulletedList";
|
|
7
6
|
|
|
8
7
|
export default {
|
|
9
|
-
title: "
|
|
8
|
+
title: "Bulleted List",
|
|
10
9
|
component: DxcBulletedList,
|
|
11
10
|
};
|
|
12
11
|
|
|
@@ -20,12 +19,18 @@ const icon = (
|
|
|
20
19
|
export const Chromatic = () => (
|
|
21
20
|
<>
|
|
22
21
|
<ExampleContainer>
|
|
23
|
-
<Title title="Icon list" level={4} />
|
|
22
|
+
<Title title="Icon list (SVG)" level={4} />
|
|
24
23
|
<DxcBulletedList type="icon" icon={icon}>
|
|
25
24
|
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
26
25
|
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
27
26
|
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
28
27
|
</DxcBulletedList>
|
|
28
|
+
<Title title="Icon list (path)" level={4} />
|
|
29
|
+
<DxcBulletedList type="icon" icon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg">
|
|
30
|
+
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
31
|
+
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
32
|
+
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
33
|
+
</DxcBulletedList>
|
|
29
34
|
<Title title="Number list" level={4} />
|
|
30
35
|
<DxcBulletedList type="number">
|
|
31
36
|
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
@@ -102,99 +107,9 @@ export const Chromatic = () => (
|
|
|
102
107
|
</DxcBulletedList>
|
|
103
108
|
</Container>
|
|
104
109
|
</ExampleContainer>
|
|
105
|
-
<BackgroundColorProvider color="#333333">
|
|
106
|
-
<DarkContainerForBulletedList>
|
|
107
|
-
<Title title="Icon list" theme="dark" level={4} />
|
|
108
|
-
<DxcBulletedList type="icon" icon={icon}>
|
|
109
|
-
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
110
|
-
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
111
|
-
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
112
|
-
</DxcBulletedList>
|
|
113
|
-
<Title title="Number list" theme="dark" level={4} />
|
|
114
|
-
<DxcBulletedList type="number">
|
|
115
|
-
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
116
|
-
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
117
|
-
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
118
|
-
</DxcBulletedList>
|
|
119
|
-
<Title title="Square" theme="dark" level={4} />
|
|
120
|
-
<DxcBulletedList type="square">
|
|
121
|
-
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
122
|
-
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
123
|
-
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
124
|
-
</DxcBulletedList>
|
|
125
|
-
<Title title="Circle" theme="dark" level={4} />
|
|
126
|
-
<DxcBulletedList type="circle">
|
|
127
|
-
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
128
|
-
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
129
|
-
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
130
|
-
</DxcBulletedList>
|
|
131
|
-
<Title title="Disc" theme="dark" level={4} />
|
|
132
|
-
<DxcBulletedList>
|
|
133
|
-
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
134
|
-
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
135
|
-
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
136
|
-
</DxcBulletedList>
|
|
137
|
-
<Title title="Multiple lines" theme="dark" level={4} />
|
|
138
|
-
<Container>
|
|
139
|
-
<Title title="Number" theme="dark" level={4} />
|
|
140
|
-
<DxcBulletedList type="number">
|
|
141
|
-
<DxcBulletedList.Item>
|
|
142
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
143
|
-
dolore magna aliqua.
|
|
144
|
-
</DxcBulletedList.Item>
|
|
145
|
-
<DxcBulletedList.Item>Text 2.</DxcBulletedList.Item>
|
|
146
|
-
</DxcBulletedList>
|
|
147
|
-
</Container>
|
|
148
|
-
<Container>
|
|
149
|
-
<Title title="Square" theme="dark" level={4} />
|
|
150
|
-
<DxcBulletedList type="square">
|
|
151
|
-
<DxcBulletedList.Item>
|
|
152
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
153
|
-
dolore magna aliqua.
|
|
154
|
-
</DxcBulletedList.Item>
|
|
155
|
-
<DxcBulletedList.Item>Text 2.</DxcBulletedList.Item>
|
|
156
|
-
</DxcBulletedList>
|
|
157
|
-
</Container>
|
|
158
|
-
<Container>
|
|
159
|
-
<Title title="Circle" theme="dark" level={4} />
|
|
160
|
-
<DxcBulletedList type="circle">
|
|
161
|
-
<DxcBulletedList.Item>
|
|
162
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
163
|
-
dolore magna aliqua.
|
|
164
|
-
</DxcBulletedList.Item>
|
|
165
|
-
<DxcBulletedList.Item>Text 2.</DxcBulletedList.Item>
|
|
166
|
-
</DxcBulletedList>
|
|
167
|
-
</Container>
|
|
168
|
-
<Title title="Disc" theme="dark" level={4} />
|
|
169
|
-
<Container>
|
|
170
|
-
<DxcBulletedList>
|
|
171
|
-
<DxcBulletedList.Item>
|
|
172
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
173
|
-
dolore magna aliqua.
|
|
174
|
-
</DxcBulletedList.Item>
|
|
175
|
-
<DxcBulletedList.Item>Text 2.</DxcBulletedList.Item>
|
|
176
|
-
</DxcBulletedList>
|
|
177
|
-
</Container>
|
|
178
|
-
<Container>
|
|
179
|
-
<Title title="Icon" theme="dark" level={4} />
|
|
180
|
-
<DxcBulletedList type="icon" icon={icon}>
|
|
181
|
-
<DxcBulletedList.Item>
|
|
182
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
183
|
-
dolore magna aliqua.
|
|
184
|
-
</DxcBulletedList.Item>
|
|
185
|
-
<DxcBulletedList.Item>Text 2.</DxcBulletedList.Item>
|
|
186
|
-
</DxcBulletedList>
|
|
187
|
-
</Container>
|
|
188
|
-
</DarkContainerForBulletedList>
|
|
189
|
-
</BackgroundColorProvider>
|
|
190
110
|
</>
|
|
191
111
|
);
|
|
192
112
|
|
|
193
113
|
const Container = styled.div`
|
|
194
114
|
width: 400px;
|
|
195
115
|
`;
|
|
196
|
-
|
|
197
|
-
const DarkContainerForBulletedList = styled.div`
|
|
198
|
-
background-color: #333333;
|
|
199
|
-
padding: 5px;
|
|
200
|
-
`;
|
package/bulleted-list/types.d.ts
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
3
|
+
type IconProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the style of the bullet point in the list.
|
|
6
|
+
*/
|
|
7
|
+
type: "icon";
|
|
8
|
+
/**
|
|
9
|
+
* Icon to display as bullet.
|
|
10
|
+
*/
|
|
11
|
+
icon: string | SVG;
|
|
12
|
+
/**
|
|
13
|
+
* Text to be shown in the list.
|
|
14
|
+
*/
|
|
4
15
|
children: React.ReactNode;
|
|
5
|
-
type?: "disc" | "circle" | "square" | "number" | "icon";
|
|
6
|
-
icon?: string | SVG;
|
|
7
16
|
};
|
|
17
|
+
type OtherProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Defines the style of the bullet point in the list.
|
|
20
|
+
*/
|
|
21
|
+
type?: "disc" | "circle" | "square" | "number";
|
|
22
|
+
/**
|
|
23
|
+
* Icon to display as bullet.
|
|
24
|
+
*/
|
|
25
|
+
icon?: never;
|
|
26
|
+
/**
|
|
27
|
+
* Text to be shown in the list.
|
|
28
|
+
*/
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
type Props = IconProps | OtherProps;
|
|
8
32
|
export default Props;
|
|
9
|
-
export
|
|
33
|
+
export type BulletedListItemPropsType = {
|
|
34
|
+
/**
|
|
35
|
+
* Text to be shown in the list.
|
|
36
|
+
*/
|
|
10
37
|
children?: React.ReactNode;
|
|
11
38
|
};
|
package/button/Button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import ButtonPropsType from "./types";
|
|
3
|
-
declare const DxcButton: ({ label, mode, disabled, iconPosition, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
|
|
3
|
+
declare const DxcButton: ({ label, mode, disabled, iconPosition, title, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
|
|
4
4
|
export default DxcButton;
|
package/button/Button.js
CHANGED
|
@@ -1,103 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
18
12
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
-
|
|
20
13
|
var _variables = require("../common/variables");
|
|
21
|
-
|
|
22
14
|
var _utils = require("../common/utils");
|
|
23
|
-
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
27
|
-
|
|
28
16
|
var _templateObject, _templateObject2, _templateObject3;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
|
-
var sizes = {
|
|
35
|
-
small: "42px",
|
|
36
|
-
medium: "120px",
|
|
37
|
-
large: "240px",
|
|
38
|
-
fillParent: "100%",
|
|
39
|
-
fitContent: "fit-content"
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
43
|
-
if (size === "fillParent") {
|
|
44
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return sizes[size];
|
|
48
|
-
};
|
|
49
|
-
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
50
19
|
var DxcButton = function DxcButton(_ref) {
|
|
51
20
|
var _ref$label = _ref.label,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
21
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
22
|
+
_ref$mode = _ref.mode,
|
|
23
|
+
mode = _ref$mode === void 0 ? "primary" : _ref$mode,
|
|
24
|
+
_ref$disabled = _ref.disabled,
|
|
25
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
26
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
27
|
+
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
28
|
+
title = _ref.title,
|
|
29
|
+
_ref$type = _ref.type,
|
|
30
|
+
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
31
|
+
icon = _ref.icon,
|
|
32
|
+
_ref$onClick = _ref.onClick,
|
|
33
|
+
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
34
|
+
margin = _ref.margin,
|
|
35
|
+
_ref$size = _ref.size,
|
|
36
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
37
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
38
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
70
39
|
var colorsTheme = (0, _useTheme["default"])();
|
|
71
|
-
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
72
40
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
73
41
|
theme: colorsTheme.button
|
|
74
42
|
}, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
75
|
-
|
|
76
|
-
mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
43
|
+
"aria-label": title,
|
|
77
44
|
disabled: disabled,
|
|
78
|
-
"aria-disabled": disabled,
|
|
79
|
-
tabIndex: disabled ? -1 : tabIndex,
|
|
80
|
-
backgroundType: backgroundType,
|
|
81
|
-
size: size,
|
|
82
|
-
margin: margin,
|
|
83
45
|
onClick: function onClick() {
|
|
84
46
|
_onClick();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
label:
|
|
91
|
-
|
|
92
|
-
|
|
47
|
+
},
|
|
48
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
49
|
+
title: title,
|
|
50
|
+
type: type,
|
|
51
|
+
$mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
52
|
+
hasLabel: label ? true : false,
|
|
53
|
+
hasIcon: icon ? true : false,
|
|
54
|
+
iconPosition: iconPosition,
|
|
55
|
+
size: size,
|
|
56
|
+
margin: margin
|
|
57
|
+
}, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
93
58
|
src: icon
|
|
94
|
-
}) : icon)
|
|
95
|
-
icon: icon,
|
|
96
|
-
iconPosition: iconPosition
|
|
97
|
-
}, label)));
|
|
59
|
+
}) : icon)));
|
|
98
60
|
};
|
|
99
|
-
|
|
100
|
-
|
|
61
|
+
var sizes = {
|
|
62
|
+
small: "42px",
|
|
63
|
+
medium: "120px",
|
|
64
|
+
large: "240px",
|
|
65
|
+
fillParent: "100%",
|
|
66
|
+
fitContent: "fit-content"
|
|
67
|
+
};
|
|
68
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
69
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
70
|
+
};
|
|
71
|
+
var getButtonStyles = function getButtonStyles($mode, theme) {
|
|
72
|
+
return "\n border-color: ".concat($mode === "secondary" ? theme.secondaryBorderColor : "", ";\n border-radius: ").concat($mode === "primary" ? theme.primaryBorderRadius : $mode === "secondary" ? theme.secondaryBorderRadius : theme.textBorderRadius, ";\n border-width: ").concat($mode === "primary" ? theme.primaryBorderThickness : $mode === "secondary" ? theme.secondaryBorderThickness : theme.textBorderThickness, ";\n border-style: ").concat($mode === "primary" ? theme.primaryBorderStyle : $mode === "secondary" ? theme.secondaryBorderStyle : theme.textBorderStyle, ";\n font-family: ").concat($mode === "primary" ? theme.primaryFontFamily : $mode === "secondary" ? theme.secondaryFontFamily : theme.textFontFamily, ";\n font-size: ").concat($mode === "primary" ? theme.primaryFontSize : $mode === "secondary" ? theme.secondaryFontSize : theme.textFontSize, ";\n font-weight: ").concat($mode === "primary" ? theme.primaryFontWeight : $mode === "secondary" ? theme.secondaryFontWeight : theme.textFontWeight, ";\n background-color: ").concat($mode === "primary" ? theme.primaryBackgroundColor : $mode === "secondary" ? theme.secondaryBackgroundColor : theme.textBackgroundColor, ";\n color: ").concat($mode === "primary" ? theme.primaryFontColor : $mode === "secondary" ? theme.secondaryFontColor : theme.textFontColor, ";\n ");
|
|
73
|
+
};
|
|
74
|
+
var getButtonStates = function getButtonStates(disabled, $mode, theme) {
|
|
75
|
+
return "\n &:hover {\n background-color: ".concat($mode === "primary" ? theme.primaryHoverBackgroundColor : $mode === "secondary" ? theme.secondaryHoverBackgroundColor : theme.textHoverBackgroundColor, ";\n color: ").concat($mode === "secondary" ? theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat($mode === "primary" ? theme.primaryActiveBackgroundColor : $mode === "secondary" ? theme.secondaryActiveBackgroundColor : theme.textActiveBackgroundColor, ";\n color: ").concat($mode === "secondary" ? theme.secondaryHoverFontColor : "", ";\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat($mode === "primary" ? theme.primaryDisabledBackgroundColor : $mode === "secondary" ? theme.secondaryDisabledBackgroundColor : theme.textDisabledBackgroundColor, ";\n color: ").concat($mode === "primary" ? theme.primaryDisabledFontColor : $mode === "secondary" ? theme.secondaryDisabledFontColor : theme.textDisabledFontColor, ";\n border-color: ").concat($mode === "secondary" ? theme.secondaryDisabledBorderColor : "", ";\n }\n");
|
|
76
|
+
};
|
|
77
|
+
var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n gap: 0.5rem;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: 40px;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n\n ", "\n ", "\n"])), function (props) {
|
|
78
|
+
return props.iconPosition === "after" ? "row" : "row-reverse";
|
|
79
|
+
}, function (props) {
|
|
80
|
+
return calculateWidth(props.margin, props.size);
|
|
81
|
+
}, function (props) {
|
|
101
82
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
102
83
|
}, function (props) {
|
|
103
84
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -107,16 +88,14 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
107
88
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
108
89
|
}, function (props) {
|
|
109
90
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
110
|
-
}, function (props) {
|
|
111
|
-
return calculateWidth(props.margin, props.size);
|
|
112
|
-
}, function (props) {
|
|
113
|
-
return props.theme.paddingLeft;
|
|
114
|
-
}, function (props) {
|
|
115
|
-
return props.theme.paddingRight;
|
|
116
91
|
}, function (props) {
|
|
117
92
|
return props.theme.paddingTop;
|
|
118
93
|
}, function (props) {
|
|
119
94
|
return props.theme.paddingBottom;
|
|
95
|
+
}, function (props) {
|
|
96
|
+
return props.hasIcon && !props.hasLabel ? props.theme.paddingLeft : "calc(".concat(props.theme.paddingLeft, " + 8px)");
|
|
97
|
+
}, function (props) {
|
|
98
|
+
return props.hasIcon && !props.hasLabel ? props.theme.paddingRight : "calc(".concat(props.theme.paddingRight, " + 8px)");
|
|
120
99
|
}, function (props) {
|
|
121
100
|
return props.theme.fontFamily;
|
|
122
101
|
}, function (props) {
|
|
@@ -126,29 +105,16 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
126
105
|
}, function (props) {
|
|
127
106
|
return props.theme.labelLetterSpacing;
|
|
128
107
|
}, function (props) {
|
|
129
|
-
return props.
|
|
108
|
+
return props.theme.focusBorderColor;
|
|
109
|
+
}, function (props) {
|
|
110
|
+
return getButtonStyles(props.$mode, props.theme);
|
|
130
111
|
}, function (props) {
|
|
131
|
-
|
|
132
|
-
backgroundType = props.backgroundType,
|
|
133
|
-
disabled = props.disabled;
|
|
134
|
-
return "\n border-radius: ".concat(props.mode === "primary" ? props.theme.primaryBorderRadius : props.mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat(props.mode === "primary" ? props.theme.primaryBorderThickness : props.mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat(mode === "primary" ? props.theme.primaryBorderStyle : mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat(mode === "primary" ? props.theme.primaryFontFamily : mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat(mode === "primary" ? props.theme.primaryFontSize : mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat(mode === "primary" ? props.theme.primaryFontWeight : mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
|
|
112
|
+
return getButtonStates(props.disabled, props.$mode, props.theme);
|
|
135
113
|
});
|
|
136
|
-
|
|
137
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
114
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n"])), function (props) {
|
|
138
115
|
return props.theme.labelFontLineHeight;
|
|
139
116
|
}, function (props) {
|
|
140
117
|
return props.theme.fontSize;
|
|
141
|
-
}, function (props) {
|
|
142
|
-
return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
|
|
143
|
-
}, function (props) {
|
|
144
|
-
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
145
118
|
});
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
149
|
-
}, function (props) {
|
|
150
|
-
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
var _default = DxcButton;
|
|
154
|
-
exports["default"] = _default;
|
|
119
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])));
|
|
120
|
+
var _default = exports["default"] = DxcButton;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
3
2
|
import DxcButton from "./Button";
|
|
4
3
|
import DxcFlex from "./../flex/Flex";
|
|
5
4
|
import Title from "../../.storybook/components/Title";
|
|
6
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
|
-
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
8
6
|
import { HalstackProvider } from "../HalstackContext";
|
|
9
7
|
|
|
10
8
|
export default {
|
|
@@ -98,7 +96,7 @@ export const Chromatic = () => (
|
|
|
98
96
|
</ExampleContainer>
|
|
99
97
|
<ExampleContainer>
|
|
100
98
|
<Title title="Big icon (image)" theme="light" level={4} />
|
|
101
|
-
<DxcButton icon="https://
|
|
99
|
+
<DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
|
|
102
100
|
</ExampleContainer>
|
|
103
101
|
<ExampleContainer>
|
|
104
102
|
<Title title="Small icon" theme="light" level={4} />
|
|
@@ -133,7 +131,7 @@ export const Chromatic = () => (
|
|
|
133
131
|
<Title title="Only icon (image)" theme="light" level={4} />
|
|
134
132
|
<DxcButton
|
|
135
133
|
mode="secondary"
|
|
136
|
-
icon="https://
|
|
134
|
+
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
137
135
|
/>
|
|
138
136
|
</ExampleContainer>
|
|
139
137
|
<Title title="Text" theme="light" level={2} />
|
|
@@ -165,88 +163,9 @@ export const Chromatic = () => (
|
|
|
165
163
|
<Title title="Only icon (image)" theme="light" level={4} />
|
|
166
164
|
<DxcButton
|
|
167
165
|
mode="text"
|
|
168
|
-
icon="https://
|
|
166
|
+
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
169
167
|
/>
|
|
170
168
|
</ExampleContainer>
|
|
171
|
-
<BackgroundColorProvider color="#333333">
|
|
172
|
-
<DarkContainer>
|
|
173
|
-
<Title title="Primary" theme="dark" level={2} />
|
|
174
|
-
<ExampleContainer>
|
|
175
|
-
<Title title="Enabled" theme="dark" level={4} />
|
|
176
|
-
<DxcButton label="Primary enabled" />
|
|
177
|
-
</ExampleContainer>
|
|
178
|
-
<ExampleContainer pseudoState="pseudo-hover">
|
|
179
|
-
<Title title="Hovered" theme="dark" level={4} />
|
|
180
|
-
<DxcButton label="Primary hovered" />
|
|
181
|
-
</ExampleContainer>
|
|
182
|
-
<ExampleContainer pseudoState="pseudo-focus">
|
|
183
|
-
<Title title="Focused" theme="dark" level={4} />
|
|
184
|
-
<DxcButton label="Primary focused" />
|
|
185
|
-
</ExampleContainer>
|
|
186
|
-
<ExampleContainer pseudoState="pseudo-active">
|
|
187
|
-
<Title title="Actived" theme="dark" level={4} />
|
|
188
|
-
<DxcButton label="Primary actived" />
|
|
189
|
-
</ExampleContainer>
|
|
190
|
-
<ExampleContainer>
|
|
191
|
-
<Title title="Disabled" theme="dark" level={4} />
|
|
192
|
-
<DxcButton label="Primary disabled" disabled icon={iconSVG} />
|
|
193
|
-
</ExampleContainer>
|
|
194
|
-
<ExampleContainer>
|
|
195
|
-
<Title title="With icon" theme="dark" level={4} />
|
|
196
|
-
<DxcButton label="Primary" icon={iconSVG} />
|
|
197
|
-
</ExampleContainer>
|
|
198
|
-
<Title title="Secondary" theme="dark" level={2} />
|
|
199
|
-
<ExampleContainer>
|
|
200
|
-
<Title title="Enabled" theme="dark" level={4} />
|
|
201
|
-
<DxcButton mode="secondary" label="Secondary enabled" />
|
|
202
|
-
</ExampleContainer>
|
|
203
|
-
<ExampleContainer pseudoState="pseudo-hover">
|
|
204
|
-
<Title title="Hovered" theme="dark" level={4} />
|
|
205
|
-
<DxcButton mode="secondary" label="Secondary hovered" />
|
|
206
|
-
</ExampleContainer>
|
|
207
|
-
<ExampleContainer pseudoState="pseudo-focus">
|
|
208
|
-
<Title title="Focused" theme="dark" level={4} />
|
|
209
|
-
<DxcButton mode="secondary" label="Secondary focused" />
|
|
210
|
-
</ExampleContainer>
|
|
211
|
-
<ExampleContainer pseudoState="pseudo-active">
|
|
212
|
-
<Title title="Actived" theme="dark" level={4} />
|
|
213
|
-
<DxcButton mode="secondary" label="Secondary actived" />
|
|
214
|
-
</ExampleContainer>
|
|
215
|
-
<ExampleContainer>
|
|
216
|
-
<Title title="Disabled" theme="dark" level={4} />
|
|
217
|
-
<DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
|
|
218
|
-
</ExampleContainer>
|
|
219
|
-
<ExampleContainer>
|
|
220
|
-
<Title title="With icon" theme="dark" level={4} />
|
|
221
|
-
<DxcButton mode="secondary" label="Primary" icon={iconSVG} />
|
|
222
|
-
</ExampleContainer>
|
|
223
|
-
<Title title="Text" theme="dark" level={2} />
|
|
224
|
-
<ExampleContainer>
|
|
225
|
-
<Title title="Enabled" theme="dark" level={4} />
|
|
226
|
-
<DxcButton mode="text" label="Text enabled" />
|
|
227
|
-
</ExampleContainer>
|
|
228
|
-
<ExampleContainer pseudoState="pseudo-hover">
|
|
229
|
-
<Title title="Hovered" theme="dark" level={4} />
|
|
230
|
-
<DxcButton mode="text" label="Text hovered" />
|
|
231
|
-
</ExampleContainer>
|
|
232
|
-
<ExampleContainer pseudoState="pseudo-focus">
|
|
233
|
-
<Title title="Focused" theme="dark" level={4} />
|
|
234
|
-
<DxcButton mode="text" label="Text focused" />
|
|
235
|
-
</ExampleContainer>
|
|
236
|
-
<ExampleContainer pseudoState="pseudo-active">
|
|
237
|
-
<Title title="Actived" theme="dark" level={4} />
|
|
238
|
-
<DxcButton mode="text" label="Text actived" />
|
|
239
|
-
</ExampleContainer>
|
|
240
|
-
<ExampleContainer>
|
|
241
|
-
<Title title="Disabled" theme="dark" level={4} />
|
|
242
|
-
<DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
|
|
243
|
-
</ExampleContainer>
|
|
244
|
-
<ExampleContainer>
|
|
245
|
-
<Title title="With icon" theme="dark" level={4} />
|
|
246
|
-
<DxcButton mode="text" label="Primary" icon={iconSVG} />
|
|
247
|
-
</ExampleContainer>
|
|
248
|
-
</DarkContainer>
|
|
249
|
-
</BackgroundColorProvider>
|
|
250
169
|
<Title title="Sizes" theme="light" level={2} />
|
|
251
170
|
<ExampleContainer>
|
|
252
171
|
<Title title="Small size" theme="light" level={4} />
|
|
@@ -254,7 +173,7 @@ export const Chromatic = () => (
|
|
|
254
173
|
</ExampleContainer>
|
|
255
174
|
<ExampleContainer>
|
|
256
175
|
<Title title="Medium size" theme="light" level={4} />
|
|
257
|
-
<DxcButton label="
|
|
176
|
+
<DxcButton label="MediumSize" size="medium" />
|
|
258
177
|
</ExampleContainer>
|
|
259
178
|
<ExampleContainer>
|
|
260
179
|
<Title title="Medium size with ellipsis" theme="light" level={4} />
|
|
@@ -262,11 +181,11 @@ export const Chromatic = () => (
|
|
|
262
181
|
</ExampleContainer>
|
|
263
182
|
<ExampleContainer>
|
|
264
183
|
<Title title="Medium size icon after" theme="light" level={4} />
|
|
265
|
-
<DxcButton label="
|
|
184
|
+
<DxcButton label="Medium" iconPosition="after" icon={iconSVG} size="medium" />
|
|
266
185
|
</ExampleContainer>
|
|
267
186
|
<ExampleContainer>
|
|
268
187
|
<Title title="Medium size icon before" theme="light" level={4} />
|
|
269
|
-
<DxcButton label="
|
|
188
|
+
<DxcButton label="Medium" iconPosition="before" icon={iconSVG} size="medium" />
|
|
270
189
|
</ExampleContainer>
|
|
271
190
|
<ExampleContainer>
|
|
272
191
|
<Title title="Medium size icon after with ellipsis" theme="light" level={4} />
|
|
@@ -286,11 +205,11 @@ export const Chromatic = () => (
|
|
|
286
205
|
</ExampleContainer>
|
|
287
206
|
<ExampleContainer>
|
|
288
207
|
<Title title="Large size icon after" theme="light" level={4} />
|
|
289
|
-
<DxcButton label="
|
|
208
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon={iconSVG} size="large" />
|
|
290
209
|
</ExampleContainer>
|
|
291
210
|
<ExampleContainer>
|
|
292
211
|
<Title title="Large size icon before" theme="light" level={4} />
|
|
293
|
-
<DxcButton label="
|
|
212
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon={iconSVG} size="large" />
|
|
294
213
|
</ExampleContainer>
|
|
295
214
|
<ExampleContainer>
|
|
296
215
|
<Title title="Large size icon after with ellipsis" theme="light" level={4} />
|
|
@@ -339,7 +258,7 @@ export const Chromatic = () => (
|
|
|
339
258
|
</ExampleContainer>
|
|
340
259
|
<Title title="Inside a flex" theme="light" level={2} />
|
|
341
260
|
<ExampleContainer>
|
|
342
|
-
<DxcFlex direction="column" gap="
|
|
261
|
+
<DxcFlex direction="column" gap="1rem">
|
|
343
262
|
<DxcButton label="Button" />
|
|
344
263
|
<DxcButton label="Button" />
|
|
345
264
|
<DxcButton label="Button" />
|
package/button/Button.test.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Button = _interopRequireDefault(require("./Button.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Button component tests", function () {
|
|
12
8
|
test("Button renders with correct text", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
label: "Button"
|
|
11
|
+
})),
|
|
12
|
+
getByText = _render.getByText;
|
|
18
13
|
expect(getByText("Button")).toBeTruthy();
|
|
19
14
|
});
|
|
20
15
|
test("Calls correct function on click", function () {
|
|
21
16
|
var onClick = jest.fn();
|
|
22
|
-
|
|
23
17
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
label: "Button",
|
|
19
|
+
onClick: onClick
|
|
20
|
+
})),
|
|
21
|
+
getByText = _render2.getByText;
|
|
29
22
|
var button = getByText("Button");
|
|
30
|
-
|
|
31
23
|
_react2.fireEvent.click(button);
|
|
32
|
-
|
|
33
24
|
expect(onClick).toHaveBeenCalled();
|
|
34
25
|
});
|
|
26
|
+
test("Renders with correct accessibility attributes", function () {
|
|
27
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
28
|
+
label: "Home",
|
|
29
|
+
title: "Go home",
|
|
30
|
+
tabIndex: 1
|
|
31
|
+
})),
|
|
32
|
+
getByRole = _render3.getByRole;
|
|
33
|
+
var button = getByRole("button");
|
|
34
|
+
expect(button.getAttribute("aria-label")).toBe("Go home");
|
|
35
|
+
expect(button.getAttribute("title")).toBe("Go home");
|
|
36
|
+
expect(button.getAttribute("tabindex")).toBe("1");
|
|
37
|
+
});
|
|
35
38
|
});
|