@dxc-technology/halstack-react 0.0.0-ee92231 → 0.0.0-eefd559
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 +10 -0
- package/BackgroundColorContext.js +1 -4
- package/ThemeContext.d.ts +15 -0
- package/ThemeContext.js +5 -8
- package/V3Select/V3Select.js +2 -2
- package/V3Textarea/V3Textarea.js +2 -2
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +11 -22
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/types.d.ts +4 -8
- package/accordion-group/AccordionGroup.js +2 -2
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/accordion-group/types.d.ts +4 -8
- package/alert/Alert.js +2 -2
- package/alert/Alert.stories.tsx +170 -0
- package/alert/types.d.ts +1 -1
- package/badge/Badge.js +1 -1
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +84 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +13 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +4 -7
- package/box/types.d.ts +0 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +13 -19
- package/button/Button.stories.tsx +222 -241
- package/button/types.d.ts +5 -9
- package/card/Card.js +5 -6
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/Checkbox.js +2 -2
- package/checkbox/types.d.ts +2 -2
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +16 -76
- package/chip/Chip.stories.tsx +119 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/common/variables.js +70 -28
- package/date/Date.js +1 -1
- package/date-input/DateInput.js +10 -13
- package/date-input/DateInput.stories.tsx +138 -0
- package/dialog/Dialog.js +4 -3
- package/dialog/Dialog.stories.tsx +212 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +13 -35
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/types.d.ts +6 -15
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +167 -109
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +12 -21
- package/file-input/types.d.ts +112 -0
- package/file-input/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +28 -36
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +3 -3
- package/footer/types.d.ts +22 -18
- package/header/Header.js +2 -2
- package/header/Header.stories.tsx +162 -0
- package/header/Icons.d.ts +2 -0
- package/header/types.d.ts +4 -2
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +7 -24
- package/heading/Heading.stories.tsx +54 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/input-text/InputText.js +2 -2
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +84 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +13 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +10 -0
- package/layout/ApplicationLayout.js +9 -19
- package/layout/ApplicationLayout.stories.tsx +171 -0
- package/layout/types.d.ts +57 -0
- package/layout/types.js +5 -0
- package/link/Link.js +3 -3
- package/link/Link.stories.tsx +146 -0
- package/list/List.d.ts +4 -0
- package/list/List.js +47 -0
- package/list/List.stories.tsx +95 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +7 -3
- package/main.js +34 -2
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +5 -50
- package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +4 -2
- package/paginator/Paginator.js +2 -8
- package/password-input/PasswordInput.js +19 -18
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/types.d.ts +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/radio/Radio.js +2 -2
- package/radio/types.d.ts +2 -2
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +140 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +273 -0
- package/radio-group/RadioGroup.stories.tsx +79 -0
- package/radio-group/RadioGroup.test.js +248 -0
- package/radio-group/types.d.ts +36 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +5 -28
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +3 -0
- package/row/Row.js +127 -0
- package/row/Row.stories.tsx +237 -0
- package/row/types.d.ts +10 -0
- package/row/types.js +5 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +20 -22
- package/select/Select.stories.tsx +572 -0
- package/select/types.d.ts +170 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +6 -15
- package/sidenav/Sidenav.stories.tsx +182 -0
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +43 -32
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +2 -7
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +1 -0
- package/stack/Stack.d.ts +3 -0
- package/stack/Stack.js +97 -0
- package/stack/Stack.stories.tsx +164 -0
- package/stack/types.d.ts +9 -0
- package/stack/types.js +5 -0
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +1 -1
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +2 -1
- package/tabs/Tabs.js +11 -9
- package/tabs/Tabs.stories.tsx +120 -0
- package/tabs/types.d.ts +25 -18
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +9 -35
- package/tag/{Tag.stories.jsx → Tag.stories.tsx} +15 -22
- package/tag/types.d.ts +69 -0
- package/tag/types.js +5 -0
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +54 -85
- package/text-input/TextInput.stories.tsx +456 -0
- package/text-input/types.d.ts +159 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +27 -60
- package/textarea/Textarea.stories.jsx +4 -3
- package/textarea/types.d.ts +130 -0
- package/textarea/types.js +5 -0
- package/toggle/Toggle.js +1 -1
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +16 -45
- package/toggle-group/ToggleGroup.stories.tsx +173 -0
- package/toggle-group/types.d.ts +97 -0
- package/toggle-group/types.js +5 -0
- package/upload/buttons-upload/ButtonsUpload.js +2 -2
- package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
- package/upload/file-upload/FileToUpload.js +1 -1
- package/upload/files-upload/FilesToUpload.js +1 -1
- package/upload/transaction/Transaction.js +2 -2
- package/upload/transactions/Transactions.js +1 -1
- package/useTheme.d.ts +2 -0
- package/useTheme.js +1 -1
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +69 -59
- package/wizard/Wizard.stories.tsx +224 -0
- package/wizard/types.d.ts +60 -0
- package/wizard/types.js +5 -0
- package/chip/index.d.ts +0 -22
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/number-input/index.d.ts +0 -113
- package/resultsetTable/index.d.ts +0 -19
- package/select/index.d.ts +0 -131
- package/sidenav/index.d.ts +0 -13
- package/tag/index.d.ts +0 -24
- package/text-input/index.d.ts +0 -135
- package/textarea/index.d.ts +0 -117
- package/toggle-group/index.d.ts +0 -21
- package/wizard/Icons.js +0 -65
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcTabs from "./Tabs";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Tabs",
|
|
9
|
+
component: DxcTabs,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const iconSVG = (
|
|
13
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
14
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
15
|
+
<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" />
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const tabs: any = [
|
|
20
|
+
{
|
|
21
|
+
label: "Tab 1",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "Tab 2",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Tab 3",
|
|
28
|
+
isDisabled: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Tab 4",
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const tabsNotification = tabs.map((tab, index) => ({
|
|
36
|
+
...tab,
|
|
37
|
+
notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 200),
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
const tabsIcon = tabs.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
41
|
+
|
|
42
|
+
const tabsNotificationIcon = tabsNotification.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
43
|
+
|
|
44
|
+
export const Chromatic = () => (
|
|
45
|
+
<>
|
|
46
|
+
<ExampleContainer>
|
|
47
|
+
<Title title="Only label" theme="light" level={4} />
|
|
48
|
+
<DxcTabs tabs={tabs} />
|
|
49
|
+
</ExampleContainer>
|
|
50
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
51
|
+
<Title title="Hovered tabs" theme="light" level={4} />
|
|
52
|
+
<DxcTabs tabs={tabs} />
|
|
53
|
+
</ExampleContainer>
|
|
54
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
55
|
+
<Title title="Focused tabs" theme="light" level={4} />
|
|
56
|
+
<DxcTabs tabs={tabs} />
|
|
57
|
+
</ExampleContainer>
|
|
58
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
59
|
+
<Title title="Actived tabs" theme="light" level={4} />
|
|
60
|
+
<DxcTabs tabs={tabs} />
|
|
61
|
+
</ExampleContainer>
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<Title title="With notification number" theme="light" level={4} />
|
|
64
|
+
<DxcTabs tabs={tabsNotification} />
|
|
65
|
+
</ExampleContainer>
|
|
66
|
+
<ExampleContainer>
|
|
67
|
+
<Title title="With icon position top" theme="light" level={4} />
|
|
68
|
+
<DxcTabs tabs={tabsIcon} />
|
|
69
|
+
</ExampleContainer>
|
|
70
|
+
<ExampleContainer>
|
|
71
|
+
<Title title="With icon position left" theme="light" level={4} />
|
|
72
|
+
<DxcTabs tabs={tabsIcon} iconPosition="left" />
|
|
73
|
+
</ExampleContainer>
|
|
74
|
+
<ExampleContainer>
|
|
75
|
+
<Title title="With icon and notification number" theme="light" level={4} />
|
|
76
|
+
<DxcTabs tabs={tabsNotificationIcon} />
|
|
77
|
+
</ExampleContainer>
|
|
78
|
+
<ExampleContainer>
|
|
79
|
+
<Title title="With icon on the left and notification number" theme="light" level={4} />
|
|
80
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" />
|
|
81
|
+
</ExampleContainer>
|
|
82
|
+
<ExampleContainer>
|
|
83
|
+
<Title title="Scrollable" theme="light" level={4} />
|
|
84
|
+
<div style={{ width: "400px" }}>
|
|
85
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" activeTabIndex={1} />
|
|
86
|
+
</div>
|
|
87
|
+
</ExampleContainer>
|
|
88
|
+
|
|
89
|
+
<Title title="Margins" theme="light" level={2} />
|
|
90
|
+
<ExampleContainer>
|
|
91
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
92
|
+
<DxcTabs tabs={tabs} margin="xxsmall" />
|
|
93
|
+
</ExampleContainer>
|
|
94
|
+
<ExampleContainer>
|
|
95
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
96
|
+
<DxcTabs tabs={tabs} margin="xsmall" />
|
|
97
|
+
</ExampleContainer>
|
|
98
|
+
<ExampleContainer>
|
|
99
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
100
|
+
<DxcTabs tabs={tabs} margin="small" />
|
|
101
|
+
</ExampleContainer>
|
|
102
|
+
<ExampleContainer>
|
|
103
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
104
|
+
<DxcTabs tabs={tabs} margin="medium" />
|
|
105
|
+
</ExampleContainer>
|
|
106
|
+
<ExampleContainer>
|
|
107
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
108
|
+
<DxcTabs tabs={tabs} margin="large" />
|
|
109
|
+
</ExampleContainer>
|
|
110
|
+
<ExampleContainer>
|
|
111
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
112
|
+
<DxcTabs tabs={tabs} margin="xlarge" />
|
|
113
|
+
</ExampleContainer>
|
|
114
|
+
<ExampleContainer>
|
|
115
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
116
|
+
<DxcTabs tabs={tabs} margin="xxlarge" />
|
|
117
|
+
<hr />
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
</>
|
|
120
|
+
);
|
package/tabs/types.d.ts
CHANGED
|
@@ -6,20 +6,8 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type SVG = React.SVGProps<SVGSVGElement
|
|
10
|
-
declare type
|
|
11
|
-
/**
|
|
12
|
-
* Tab label.
|
|
13
|
-
*/
|
|
14
|
-
label?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Element used as the icon that will be displayed in the tab.
|
|
17
|
-
*/
|
|
18
|
-
icon?: SVG;
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated URL of the icon to be displayed in the tab.
|
|
21
|
-
*/
|
|
22
|
-
iconSrc?: string;
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
10
|
+
declare type TabCommonProps = {
|
|
23
11
|
/**
|
|
24
12
|
* Whether the tab is disabled or not.
|
|
25
13
|
*/
|
|
@@ -33,11 +21,31 @@ declare type Tab = {
|
|
|
33
21
|
*/
|
|
34
22
|
notificationNumber?: boolean | number;
|
|
35
23
|
};
|
|
24
|
+
declare type TabLabelProps = TabCommonProps & {
|
|
25
|
+
/**
|
|
26
|
+
* Tab label.
|
|
27
|
+
*/
|
|
28
|
+
label: string;
|
|
29
|
+
/**
|
|
30
|
+
* Element or path used as the icon that will be displayed in the tab.
|
|
31
|
+
*/
|
|
32
|
+
icon?: string | SVG;
|
|
33
|
+
};
|
|
34
|
+
declare type TabIconProps = TabCommonProps & {
|
|
35
|
+
/**
|
|
36
|
+
* Tab label.
|
|
37
|
+
*/
|
|
38
|
+
label?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Element or path used as the icon that will be displayed in the tab.
|
|
41
|
+
*/
|
|
42
|
+
icon: string | SVG;
|
|
43
|
+
};
|
|
36
44
|
declare type Props = {
|
|
37
45
|
/**
|
|
38
46
|
* An array of objects representing the tabs.
|
|
39
47
|
*/
|
|
40
|
-
tabs:
|
|
48
|
+
tabs: (TabLabelProps | TabIconProps)[];
|
|
41
49
|
/**
|
|
42
50
|
* Whether the icon should appear above or to the left of the label.
|
|
43
51
|
*/
|
|
@@ -58,9 +66,8 @@ declare type Props = {
|
|
|
58
66
|
*/
|
|
59
67
|
onTabHover?: (tabIndex: number) => void;
|
|
60
68
|
/**
|
|
61
|
-
* Size of the margin to be applied to the component
|
|
62
|
-
* with 'top', 'bottom', 'left' and 'right' properties in order to specify
|
|
63
|
-
* different margin sizes.
|
|
69
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
70
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
64
71
|
*/
|
|
65
72
|
margin?: Space | Margin;
|
|
66
73
|
/**
|
package/tag/Tag.d.ts
ADDED
package/tag/Tag.js
CHANGED
|
@@ -9,23 +9,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
13
|
|
|
14
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
15
|
|
|
16
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
17
|
|
|
20
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
19
|
|
|
22
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
21
|
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
22
|
var _variables = require("../common/variables.js");
|
|
27
23
|
|
|
28
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
29
25
|
|
|
30
26
|
var _utils = require("../common/utils.js");
|
|
31
27
|
|
|
@@ -39,9 +35,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
39
35
|
|
|
40
36
|
var DxcTag = function DxcTag(_ref) {
|
|
41
37
|
var icon = _ref.icon,
|
|
42
|
-
|
|
43
|
-
label = _ref
|
|
44
|
-
margin = _ref.margin,
|
|
38
|
+
_ref$label = _ref.label,
|
|
39
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
45
40
|
linkHref = _ref.linkHref,
|
|
46
41
|
onClick = _ref.onClick,
|
|
47
42
|
_ref$iconBgColor = _ref.iconBgColor,
|
|
@@ -50,6 +45,7 @@ var DxcTag = function DxcTag(_ref) {
|
|
|
50
45
|
labelPosition = _ref$labelPosition === void 0 ? "after" : _ref$labelPosition,
|
|
51
46
|
_ref$newWindow = _ref.newWindow,
|
|
52
47
|
newWindow = _ref$newWindow === void 0 ? false : _ref$newWindow,
|
|
48
|
+
margin = _ref.margin,
|
|
53
49
|
_ref$size = _ref.size,
|
|
54
50
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
55
51
|
_ref$tabIndex = _ref.tabIndex,
|
|
@@ -72,9 +68,9 @@ var DxcTag = function DxcTag(_ref) {
|
|
|
72
68
|
labelPosition: labelPosition
|
|
73
69
|
}, /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
74
70
|
iconBgColor: iconBgColor
|
|
75
|
-
}, icon
|
|
76
|
-
src:
|
|
77
|
-
})), size !== "small" && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label)));
|
|
71
|
+
}, icon && /*#__PURE__*/_react["default"].createElement(TagIconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(TagIcon, {
|
|
72
|
+
src: icon
|
|
73
|
+
}) : icon)), size !== "small" && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label)));
|
|
78
74
|
|
|
79
75
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
80
76
|
theme: colorsTheme.tag
|
|
@@ -149,11 +145,7 @@ var StyledButton = _styledComponents["default"].button(_templateObject4 || (_tem
|
|
|
149
145
|
return props.theme.focusColor;
|
|
150
146
|
});
|
|
151
147
|
|
|
152
|
-
var TagIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["
|
|
153
|
-
return props.theme.iconWidth;
|
|
154
|
-
}, function (props) {
|
|
155
|
-
return props.theme.iconHeight;
|
|
156
|
-
});
|
|
148
|
+
var TagIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
157
149
|
|
|
158
150
|
var TagIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
159
151
|
return props.theme.iconWidth;
|
|
@@ -192,23 +184,5 @@ var TagLabel = _styledComponents["default"].div(_templateObject8 || (_templateOb
|
|
|
192
184
|
return props.theme.labelPaddingRight;
|
|
193
185
|
});
|
|
194
186
|
|
|
195
|
-
DxcTag.propTypes = {
|
|
196
|
-
size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
|
|
197
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
198
|
-
iconSrc: _propTypes["default"].string,
|
|
199
|
-
iconBgColor: _propTypes["default"].string,
|
|
200
|
-
label: _propTypes["default"].string,
|
|
201
|
-
labelPosition: _propTypes["default"].oneOf(["before", "after"]),
|
|
202
|
-
linkHref: _propTypes["default"].string,
|
|
203
|
-
onClick: _propTypes["default"].func,
|
|
204
|
-
newWindow: _propTypes["default"].bool,
|
|
205
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
206
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
207
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
208
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
209
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
210
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
211
|
-
tabIndex: _propTypes["default"].number
|
|
212
|
-
};
|
|
213
187
|
var _default = DxcTag;
|
|
214
188
|
exports["default"] = _default;
|
|
@@ -9,29 +9,22 @@ export default {
|
|
|
9
9
|
component: DxcTag,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const icon = (
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</svg>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
12
|
+
const icon = (
|
|
13
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
14
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
15
|
+
<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" />
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const largeIcon = (
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
|
|
21
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
22
|
+
<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" />
|
|
23
|
+
</svg>
|
|
24
|
+
);
|
|
28
25
|
|
|
29
26
|
export const Chromatic = () => (
|
|
30
27
|
<>
|
|
31
|
-
<ExampleContainer>
|
|
32
|
-
<Title title="Without label" theme="light" level={4} />
|
|
33
|
-
<DxcTag />
|
|
34
|
-
</ExampleContainer>
|
|
35
28
|
<ExampleContainer>
|
|
36
29
|
<Title title="With icon" theme="light" level={4} />
|
|
37
30
|
<DxcTag icon={icon} />
|
|
@@ -46,7 +39,7 @@ export const Chromatic = () => (
|
|
|
46
39
|
</ExampleContainer>
|
|
47
40
|
<ExampleContainer>
|
|
48
41
|
<Title title="With label and icon" theme="light" level={4} />
|
|
49
|
-
<DxcTag label="Tag" icon=
|
|
42
|
+
<DxcTag label="Tag" icon="https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png" />
|
|
50
43
|
</ExampleContainer>
|
|
51
44
|
<ExampleContainer>
|
|
52
45
|
<Title title="With right icon" theme="light" level={4} />
|
|
@@ -132,7 +125,7 @@ export const Chromatic = () => (
|
|
|
132
125
|
);
|
|
133
126
|
|
|
134
127
|
const LinkTag = () => (
|
|
135
|
-
<ExampleContainer>
|
|
128
|
+
<ExampleContainer expanded>
|
|
136
129
|
<Title title="Hover link tag" theme="light" level={4} />
|
|
137
130
|
<DxcTag label="Tag" icon={icon} linkHref="https://www.dxc.com" />
|
|
138
131
|
</ExampleContainer>
|
package/tag/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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>;
|
|
10
|
+
declare type TagCommonProps = {
|
|
11
|
+
/**
|
|
12
|
+
* If defined, the tag will be displayed as an anchor, using this prop as "href".
|
|
13
|
+
* Component will show some visual feedback on hover.
|
|
14
|
+
*/
|
|
15
|
+
linkHref?: string;
|
|
16
|
+
/**
|
|
17
|
+
* If defined, the tag will be displayed as a button. This function will
|
|
18
|
+
* be called when the user clicks the tag. Component will show some
|
|
19
|
+
* visual feedback on hover.
|
|
20
|
+
*/
|
|
21
|
+
onClick?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Background color of the icon section of the tag.
|
|
24
|
+
*/
|
|
25
|
+
iconBgColor?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the label should appear after or before the icon.
|
|
28
|
+
*/
|
|
29
|
+
labelPosition?: "before" | "after";
|
|
30
|
+
/**
|
|
31
|
+
* If true, the page is opened in a new browser tab.
|
|
32
|
+
*/
|
|
33
|
+
newWindow?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
36
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
37
|
+
*/
|
|
38
|
+
margin?: Space | Margin;
|
|
39
|
+
/**
|
|
40
|
+
* Size of the component.
|
|
41
|
+
*/
|
|
42
|
+
size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
|
|
43
|
+
/**
|
|
44
|
+
* Value of the tabindex attribute.
|
|
45
|
+
*/
|
|
46
|
+
tabIndex?: number;
|
|
47
|
+
};
|
|
48
|
+
declare type TagLabelProps = TagCommonProps & {
|
|
49
|
+
/**
|
|
50
|
+
* Element or path used as the icon that will be placed next to the label.
|
|
51
|
+
*/
|
|
52
|
+
icon?: string | SVG;
|
|
53
|
+
/**
|
|
54
|
+
* Text to be placed next inside the tag.
|
|
55
|
+
*/
|
|
56
|
+
label: string;
|
|
57
|
+
};
|
|
58
|
+
declare type TagIconProps = TagCommonProps & {
|
|
59
|
+
/**
|
|
60
|
+
* Element or path used as the icon that will be placed next to the label.
|
|
61
|
+
*/
|
|
62
|
+
icon: string | SVG;
|
|
63
|
+
/**
|
|
64
|
+
* Text to be placed next inside the tag.
|
|
65
|
+
*/
|
|
66
|
+
label?: string;
|
|
67
|
+
};
|
|
68
|
+
declare type Props = TagLabelProps | TagIconProps;
|
|
69
|
+
export default Props;
|
package/tag/types.js
ADDED
package/text/Text.d.ts
ADDED
package/text/Text.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _templateObject;
|
|
17
|
+
|
|
18
|
+
function Text(_ref) {
|
|
19
|
+
var _ref$as = _ref.as,
|
|
20
|
+
as = _ref$as === void 0 ? "span" : _ref$as,
|
|
21
|
+
children = _ref.children;
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement(StyledText, {
|
|
23
|
+
as: as
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var StyledText = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: 0px;\n font-family: Open Sans, sans-serif;\n line-height: 1.5em;\n"])));
|
|
28
|
+
|
|
29
|
+
var _default = Text;
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import DxcText from "./Text";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Text",
|
|
7
|
+
component: DxcText,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const Chromatic = () => (
|
|
11
|
+
<>
|
|
12
|
+
<Title title="Two texts as span" theme="light" level={4} />
|
|
13
|
+
<DxcText>Text 1.</DxcText>
|
|
14
|
+
<DxcText>Text 2.</DxcText>
|
|
15
|
+
<Title title="Two texts as p" theme="light" level={4} />
|
|
16
|
+
<DxcText as="p">Text 1.</DxcText>
|
|
17
|
+
<DxcText as="p">Text 2.</DxcText>
|
|
18
|
+
</>
|
|
19
|
+
);
|