orcs-design-system 3.2.4 → 3.2.6
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/es/GlobalStyles.js +1 -31
- package/es/SystemThemeProvider.js +11 -5
- package/es/assets/Colour/Colour.stories.js +211 -0
- package/es/assets/Colour/index.js +3 -3
- package/es/components/ActionsMenu/ActionsMenu.stories.js +260 -233
- package/es/components/ActionsMenu/index.js +144 -229
- package/es/components/Avatar/Avatar.stories.js +212 -196
- package/es/components/Avatar/index.js +280 -307
- package/es/components/Badge/Badge.stories.js +71 -46
- package/es/components/Badge/index.js +71 -74
- package/es/components/Box/Box.stories.js +51 -35
- package/es/components/Box/index.js +33 -34
- package/es/components/Button/Button.stories.js +161 -145
- package/es/components/Button/ButtonLink.stories.js +152 -139
- package/es/components/Button/index.js +79 -99
- package/es/components/ButtonGroup/ButtonGroup.stories.js +43 -42
- package/es/components/ButtonGroup/ButtonGroupItem.stories.js +11 -13
- package/es/components/ButtonGroup/index.js +103 -99
- package/es/components/Card/Card.stories.js +94 -62
- package/es/components/Card/index.js +50 -71
- package/es/components/Checkbox/Checkbox.stories.js +37 -43
- package/es/components/Checkbox/index.js +61 -76
- package/es/components/DatePicker/DatePicker.stories.js +86 -118
- package/es/components/DatePicker/index.js +71 -187
- package/es/components/Divider/Divider.stories.js +39 -42
- package/es/components/Divider/index.js +21 -27
- package/es/components/Expandable/Expandable.stories.js +46 -36
- package/es/components/Expandable/index.js +55 -82
- package/es/components/Flex/Flex.stories.js +19 -5
- package/es/components/Flex/FlexItem.stories.js +10 -9
- package/es/components/Flex/index.js +34 -27
- package/es/components/Grid/Grid.stories.js +129 -55
- package/es/components/Grid/index.js +25 -24
- package/es/components/Header/Header.stories.js +101 -92
- package/es/components/Header/index.js +433 -436
- package/es/components/HeaderSimple/HeaderSimple.stories.js +23 -27
- package/es/components/HeaderSimple/index.js +73 -68
- package/es/components/Icon/Icon.stories.js +58 -57
- package/es/components/Icon/index.js +48 -46
- package/es/components/Loading/Loading.stories.js +32 -39
- package/es/components/Loading/index.js +44 -51
- package/es/components/Modal/Modal.stories.js +172 -153
- package/es/components/Modal/index.js +126 -134
- package/es/components/Notification/Notification.stories.js +59 -58
- package/es/components/Notification/index.js +123 -133
- package/es/components/Popover/Popover.stories.js +134 -102
- package/es/components/Popover/index.js +65 -111
- package/es/components/ProgressBar/ProgressBar.stories.js +36 -39
- package/es/components/ProgressBar/index.js +29 -34
- package/es/components/RadioButton/RadioButton.stories.js +32 -37
- package/es/components/RadioButton/index.js +170 -184
- package/es/components/Range/Range.stories.js +19 -19
- package/es/components/Range/index.js +35 -45
- package/es/components/Select/Select.stories.js +107 -128
- package/es/components/Select/index.js +324 -336
- package/es/components/SideNav/NavItem.js +112 -122
- package/es/components/SideNav/SideNav.stories.js +84 -57
- package/es/components/SideNav/index.js +161 -185
- package/es/components/Sidebar/Sidebar.stories.js +50 -33
- package/es/components/Sidebar/index.js +152 -155
- package/es/components/Spacer/Spacer.stories.js +35 -32
- package/es/components/Spacer/index.js +20 -20
- package/es/components/StatusDot/StatusDot.stories.js +103 -90
- package/es/components/StatusDot/index.js +36 -38
- package/es/components/StyledLink/StyledLink.stories.js +68 -69
- package/es/components/StyledLink/index.js +47 -48
- package/es/components/Table/Table.stories.js +118 -112
- package/es/components/Table/getExpandColumnConfig.js +67 -62
- package/es/components/Table/index.js +24 -27
- package/es/components/Table/muiStyleOverrides.js +10 -8
- package/es/components/Tabs/Tab.stories.js +55 -38
- package/es/components/Tabs/TabsContainer.stories.js +30 -22
- package/es/components/Tabs/index.js +95 -92
- package/es/components/Tag/Tag.stories.js +250 -220
- package/es/components/Tag/index.js +118 -190
- package/es/components/TextArea/TextArea.stories.js +76 -89
- package/es/components/TextArea/index.js +117 -115
- package/es/components/TextInput/TextInput.stories.js +41 -61
- package/es/components/TextInput/index.js +127 -171
- package/es/components/Toggle/Toggle.stories.js +63 -62
- package/es/components/Toggle/index.js +43 -77
- package/es/components/TreeNav/TreeNav.stories.js +7 -8
- package/es/components/TreeNav/index.js +72 -69
- package/es/components/Typography/Typography.stories.js +174 -0
- package/es/components/Typography/index.js +252 -308
- package/es/components.test.js +1 -1
- package/es/hooks/isVisible.js +6 -10
- package/es/hooks/keepInView.js +27 -32
- package/es/hooks/keypress.js +14 -14
- package/es/hooks/useInputFocus.js +5 -5
- package/es/hooks/usePrevious.js +3 -3
- package/es/systemThemeCollapsed.js +53 -53
- package/es/systemtheme.js +53 -53
- package/es/utils/selectUtil.js +1 -1
- package/es/utils/selectUtil.test.js +6 -6
- package/package.json +29 -38
|
@@ -3,186 +3,199 @@ import Icon from "../Icon";
|
|
|
3
3
|
import Spacer from "../Spacer";
|
|
4
4
|
import Flex from "../Flex";
|
|
5
5
|
import { VARIANT_COLORS, ButtonLink } from ".";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
7
|
export default {
|
|
7
8
|
title: "Components/Buttons/ButtonLink",
|
|
8
9
|
component: ButtonLink
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
11
|
+
const link = "http://www.google.com";
|
|
12
|
+
export const defaultButton = () => /*#__PURE__*/_jsx(ButtonLink, {
|
|
13
|
+
href: link,
|
|
14
|
+
children: "Default button"
|
|
15
|
+
});
|
|
16
16
|
defaultButton.storyName = "Default button";
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export var alternateSize = function alternateSize() {
|
|
30
|
-
return /*#__PURE__*/React.createElement(Spacer, {
|
|
31
|
-
my: "3"
|
|
32
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
17
|
+
export const variants = () => /*#__PURE__*/_jsx(Spacer, {
|
|
18
|
+
my: "3",
|
|
19
|
+
children: Object.keys(VARIANT_COLORS).map(variant => /*#__PURE__*/_jsx(ButtonLink, {
|
|
20
|
+
large: true,
|
|
21
|
+
variant: variant,
|
|
22
|
+
href: link,
|
|
23
|
+
children: variant
|
|
24
|
+
}, variant))
|
|
25
|
+
});
|
|
26
|
+
export const alternateSize = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
27
|
+
my: "3",
|
|
28
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
33
29
|
small: true,
|
|
34
|
-
href: link
|
|
35
|
-
|
|
30
|
+
href: link,
|
|
31
|
+
children: "Small button"
|
|
32
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
36
33
|
large: true,
|
|
37
|
-
href: link
|
|
38
|
-
|
|
34
|
+
href: link,
|
|
35
|
+
children: "Large button"
|
|
36
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
39
37
|
height: "xxxl",
|
|
40
|
-
href: link
|
|
41
|
-
}, "Specified height button"), /*#__PURE__*/React.createElement(ButtonLink, {
|
|
42
38
|
href: link,
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
39
|
+
children: "Specified height button"
|
|
40
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
41
|
+
href: link,
|
|
42
|
+
width: "100px",
|
|
43
|
+
children: "A multiple-line button with specified width"
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
46
|
alternateSize.storyName = "Alternate sizes";
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
47
|
+
export const alternateColours = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
48
|
+
my: "3",
|
|
49
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
51
50
|
variant: "success",
|
|
52
|
-
href: link
|
|
53
|
-
|
|
51
|
+
href: link,
|
|
52
|
+
children: "Success/green button"
|
|
53
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
54
54
|
variant: "danger",
|
|
55
|
-
href: link
|
|
56
|
-
|
|
57
|
-
}
|
|
55
|
+
href: link,
|
|
56
|
+
children: "Danger/red button"
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
58
59
|
alternateColours.storyName = "Alternate colours";
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
60
|
+
export const ghost = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
61
|
+
my: "3",
|
|
62
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
63
63
|
small: true,
|
|
64
64
|
variant: "ghost",
|
|
65
|
-
href: link
|
|
66
|
-
|
|
65
|
+
href: link,
|
|
66
|
+
children: "Small ghost button"
|
|
67
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
67
68
|
variant: "ghost",
|
|
68
|
-
href: link
|
|
69
|
-
|
|
69
|
+
href: link,
|
|
70
|
+
children: "Regular ghost button"
|
|
71
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
70
72
|
large: true,
|
|
71
73
|
variant: "ghost",
|
|
72
|
-
href: link
|
|
73
|
-
|
|
74
|
-
}
|
|
74
|
+
href: link,
|
|
75
|
+
children: "Large ghost button"
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
75
78
|
ghost.storyName = "Ghost style";
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
79
|
+
export const fullWidth = () => /*#__PURE__*/_jsx(ButtonLink, {
|
|
80
|
+
fullWidth: true,
|
|
81
|
+
href: link,
|
|
82
|
+
children: "Full width button"
|
|
83
|
+
});
|
|
82
84
|
fullWidth.storyName = "Full width";
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
85
|
+
export const disabled = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
86
|
+
my: "r",
|
|
87
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
87
88
|
disabled: true,
|
|
88
|
-
href: link
|
|
89
|
-
|
|
89
|
+
href: link,
|
|
90
|
+
children: "Disabled button"
|
|
91
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
90
92
|
variant: "disabled",
|
|
91
|
-
href: link
|
|
92
|
-
|
|
93
|
-
}
|
|
93
|
+
href: link,
|
|
94
|
+
children: "Alternate way of making button disabled"
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
94
97
|
disabled.storyName = "Disabled state";
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
98
|
+
export const withIcon = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
99
|
+
my: "3",
|
|
100
|
+
children: [/*#__PURE__*/_jsxs(ButtonLink, {
|
|
99
101
|
iconLeft: true,
|
|
100
102
|
href: link,
|
|
101
|
-
isLoading: true
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
isLoading: true,
|
|
104
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
105
|
+
icon: ["fas", "user-plus"]
|
|
106
|
+
}), "Left aligned icon"]
|
|
107
|
+
}), /*#__PURE__*/_jsxs(ButtonLink, {
|
|
105
108
|
iconRight: true,
|
|
106
|
-
href: link
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
href: link,
|
|
110
|
+
children: ["Right aligned icon", /*#__PURE__*/_jsx(Icon, {
|
|
111
|
+
icon: ["fas", "download"]
|
|
112
|
+
})]
|
|
113
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
110
114
|
leftIcon: ["fas", "star"],
|
|
111
|
-
href: link
|
|
112
|
-
|
|
113
|
-
}
|
|
115
|
+
href: link,
|
|
116
|
+
children: "Left icon magic!"
|
|
117
|
+
})]
|
|
118
|
+
});
|
|
114
119
|
withIcon.storyName = "With icon";
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
120
|
+
export const iconOnly = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
121
|
+
my: "3",
|
|
122
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
119
123
|
small: true,
|
|
120
124
|
iconOnly: true,
|
|
121
125
|
p: "s",
|
|
122
|
-
ariaLabel: /*#__PURE__*/
|
|
126
|
+
ariaLabel: /*#__PURE__*/_jsx(Icon, {
|
|
123
127
|
icon: ["fas", "download"]
|
|
124
128
|
}),
|
|
125
|
-
href: link
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
href: link,
|
|
130
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
131
|
+
icon: ["far", "calendar-alt"]
|
|
132
|
+
})
|
|
133
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
129
134
|
iconOnly: true,
|
|
130
135
|
p: "s",
|
|
131
136
|
ariaLabel: "Show calendar",
|
|
132
|
-
href: link
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
href: link,
|
|
138
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
139
|
+
icon: ["far", "calendar-alt"]
|
|
140
|
+
})
|
|
141
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
136
142
|
large: true,
|
|
137
143
|
iconOnly: true,
|
|
138
144
|
p: "s",
|
|
139
145
|
ariaLabel: "Show calendar",
|
|
140
|
-
href: link
|
|
141
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
142
|
-
icon: ["far", "calendar-alt"]
|
|
143
|
-
})), /*#__PURE__*/React.createElement(Flex, {
|
|
144
|
-
alignItems: "center",
|
|
145
|
-
mt: "r"
|
|
146
|
-
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
147
|
-
mr: "r"
|
|
148
|
-
}, /*#__PURE__*/React.createElement(ButtonLink, {
|
|
149
|
-
iconOnly: true,
|
|
150
|
-
variant: "success",
|
|
151
|
-
href: link,
|
|
152
|
-
width: "33px",
|
|
153
|
-
height: "32px",
|
|
154
|
-
ariaLabel: "Confirm"
|
|
155
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
156
|
-
icon: ["fas", "check"]
|
|
157
|
-
})), /*#__PURE__*/React.createElement(ButtonLink, {
|
|
158
|
-
iconOnly: true,
|
|
159
|
-
variant: "successAlternate",
|
|
160
|
-
href: link,
|
|
161
|
-
width: "33px",
|
|
162
|
-
height: "32px",
|
|
163
|
-
ariaLabel: "Confirm"
|
|
164
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
165
|
-
icon: ["fas", "check"]
|
|
166
|
-
})), /*#__PURE__*/React.createElement(ButtonLink, {
|
|
167
|
-
iconOnly: true,
|
|
168
|
-
variant: "danger",
|
|
169
146
|
href: link,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}, /*#__PURE__*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
147
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
148
|
+
icon: ["far", "calendar-alt"]
|
|
149
|
+
})
|
|
150
|
+
}), /*#__PURE__*/_jsx(Flex, {
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
mt: "r",
|
|
153
|
+
children: /*#__PURE__*/_jsxs(Spacer, {
|
|
154
|
+
mr: "r",
|
|
155
|
+
children: [/*#__PURE__*/_jsx(ButtonLink, {
|
|
156
|
+
iconOnly: true,
|
|
157
|
+
variant: "success",
|
|
158
|
+
href: link,
|
|
159
|
+
width: "33px",
|
|
160
|
+
height: "32px",
|
|
161
|
+
ariaLabel: "Confirm",
|
|
162
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
163
|
+
icon: ["fas", "check"]
|
|
164
|
+
})
|
|
165
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
166
|
+
iconOnly: true,
|
|
167
|
+
variant: "successAlternate",
|
|
168
|
+
href: link,
|
|
169
|
+
width: "33px",
|
|
170
|
+
height: "32px",
|
|
171
|
+
ariaLabel: "Confirm",
|
|
172
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
173
|
+
icon: ["fas", "check"]
|
|
174
|
+
})
|
|
175
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
176
|
+
iconOnly: true,
|
|
177
|
+
variant: "danger",
|
|
178
|
+
href: link,
|
|
179
|
+
width: "33px",
|
|
180
|
+
height: "32px",
|
|
181
|
+
ariaLabel: "Cancel",
|
|
182
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
183
|
+
icon: ["fas", "times"]
|
|
184
|
+
})
|
|
185
|
+
}), /*#__PURE__*/_jsx(ButtonLink, {
|
|
186
|
+
iconOnly: true,
|
|
187
|
+
variant: "dangerAlternate",
|
|
188
|
+
href: link,
|
|
189
|
+
width: "33px",
|
|
190
|
+
height: "32px",
|
|
191
|
+
ariaLabel: "Cancel",
|
|
192
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
193
|
+
icon: ["fas", "times"]
|
|
194
|
+
})
|
|
195
|
+
})]
|
|
196
|
+
})
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
186
199
|
iconOnly.storyName = "Icon only";
|
|
187
200
|
defaultButton.__docgenInfo = {
|
|
188
201
|
"description": "",
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
5
|
-
var _excluded = ["ariaLabel"];
|
|
6
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
1
|
import React from "react";
|
|
9
2
|
import styled, { ThemeProvider, css } from "styled-components";
|
|
10
3
|
import PropTypes from "prop-types";
|
|
@@ -15,8 +8,9 @@ import Loading from "../Loading";
|
|
|
15
8
|
import { themeGet } from "@styled-system/theme-get";
|
|
16
9
|
import { Link } from "react-router-dom";
|
|
17
10
|
import { omit } from "lodash";
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
export const VARIANT_COLORS = {
|
|
13
|
+
default: {
|
|
20
14
|
background: "colors.primary",
|
|
21
15
|
color: "colors.white",
|
|
22
16
|
borderColor: "colors.primary",
|
|
@@ -102,80 +96,52 @@ export var VARIANT_COLORS = {
|
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
var addVariantColors = function addVariantColors(key) {
|
|
111
|
-
var variantStyle = VARIANT_COLORS[key];
|
|
99
|
+
const getOutlineStyle = color => css(["outline:0;box-shadow:", ";"], props => [themeGet("shadows.thinOutline")(props), themeGet(color)(props)].join(" "));
|
|
100
|
+
const addVariantColors = key => {
|
|
101
|
+
const variantStyle = VARIANT_COLORS[key];
|
|
112
102
|
return css(["background:", ";color:", ";border-color:", ";&:hover{background:", ";color:", ";border-color:", ";}", ""], themeGet(variantStyle.background), themeGet(variantStyle.color), themeGet(variantStyle.borderColor), themeGet(variantStyle.hovered.background), themeGet(variantStyle.hovered.color), themeGet(variantStyle.hovered.borderColor), variantStyle.focused && css(["&:focus{", "}"], getOutlineStyle(variantStyle.focused.outline)));
|
|
113
103
|
};
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
const getVariantStyle = props => {
|
|
105
|
+
const styles = Object.keys(VARIANT_COLORS).reduce((obj, key) => {
|
|
116
106
|
obj[key] = css(["", ""], addVariantColors(key));
|
|
117
107
|
return obj;
|
|
118
108
|
}, {});
|
|
119
109
|
if (props.disabled) return styles.disabled;
|
|
120
|
-
return styles[props.variant] || styles
|
|
110
|
+
return styles[props.variant] || styles.default;
|
|
121
111
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
var buttonStyles = css(["background:", ";color:", ";border-color:", ";display:flex;align-items:center;justify-content:center;appearance:none;box-shadow:none;margin:0;text-decoration:none;text-align:center;font-family:", ";font-weight:", ";border-radius:", ";transition:", ";border-width:", ";cursor:", ";width:", ";height:auto;font-size:", ";padding:", " ", ";svg{margin-right:", ";margin-left:", ";}&:hover{background:", ";border-color:", ";border-width:", ";border-style:solid;}&:focus{outline:0;box-shadow:", " ", ";}", " ", ""], themeGet(VARIANT_COLORS["default"].background), themeGet(VARIANT_COLORS["default"].color), themeGet("colors.primary"), themeGet("fonts.main"), themeGet("fontWeights.2"), themeGet("radii.2"), themeGet("transition.transitionDefault"), themeGet("borderWidths.1"), function (props) {
|
|
128
|
-
return props.disabled ? "not-allowed" : props.isLoading ? "progress" : "pointer";
|
|
129
|
-
}, function (props) {
|
|
130
|
-
return props.fullWidth ? "100%" : "auto";
|
|
131
|
-
}, function (props) {
|
|
132
|
-
var fontSize = 2;
|
|
112
|
+
const getSpace = getter => props => themeGet("space.".concat(getter(props)))(props);
|
|
113
|
+
const buttonStyles = css(["background:", ";color:", ";border-color:", ";display:flex;align-items:center;justify-content:center;appearance:none;box-shadow:none;margin:0;text-decoration:none;text-align:center;font-family:", ";font-weight:", ";border-radius:", ";transition:", ";border-width:", ";cursor:", ";width:", ";height:auto;font-size:", ";padding:", " ", ";svg{margin-right:", ";margin-left:", ";}&:hover{background:", ";border-color:", ";border-width:", ";border-style:solid;}&:focus{outline:0;box-shadow:", " ", ";}", " ", ""], themeGet(VARIANT_COLORS.default.background), themeGet(VARIANT_COLORS.default.color), themeGet("colors.primary"), themeGet("fonts.main"), themeGet("fontWeights.2"), themeGet("radii.2"), themeGet("transition.transitionDefault"), themeGet("borderWidths.1"), props => props.disabled ? "not-allowed" : props.isLoading ? "progress" : "pointer", props => props.fullWidth ? "100%" : "auto", props => {
|
|
114
|
+
let fontSize = 2;
|
|
133
115
|
if (props.large && props.iconOnly) fontSize = 5;
|
|
134
116
|
if (props.large) fontSize = 3;
|
|
135
117
|
if (props.small) fontSize = 1;
|
|
136
118
|
return themeGet("fontSizes.".concat(fontSize))(props);
|
|
137
|
-
}, getSpace(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}), themeGet(VARIANT_COLORS["default"].hovered.background), themeGet("colors.primaryDark"), themeGet("borderWidths.1"), themeGet("shadows.thinOutline"), themeGet("colors.primaryDarker"), getVariantStyle, compose(space, layout, color, border));
|
|
146
|
-
var attrs = function attrs(props) {
|
|
147
|
-
return {
|
|
148
|
-
"data-testid": props.dataTestId || props["data-testid"],
|
|
149
|
-
disabled: props.disabled || props.variant == "disabled",
|
|
150
|
-
className: "".concat(props.className || "", " variant-").concat(props.variant || "default")
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
var StyledButton = styled("button").withConfig({
|
|
154
|
-
shouldForwardProp: shouldForwardProp
|
|
119
|
+
}, getSpace(props => props.large ? "s" : props.small ? "xxs" : "xs"), getSpace(props => props.large ? "r" : props.small ? "s" : "between"), getSpace(props => !props.iconLeft ? "" : props.small ? "xs" : "s"), getSpace(props => !props.iconRight ? "" : props.small ? "xs" : "s"), themeGet(VARIANT_COLORS.default.hovered.background), themeGet("colors.primaryDark"), themeGet("borderWidths.1"), themeGet("shadows.thinOutline"), themeGet("colors.primaryDarker"), getVariantStyle, compose(space, layout, color, border));
|
|
120
|
+
const attrs = props => ({
|
|
121
|
+
"data-testid": props.dataTestId || props["data-testid"],
|
|
122
|
+
disabled: props.disabled || props.variant == "disabled",
|
|
123
|
+
className: "".concat(props.className || "", " variant-").concat(props.variant || "default")
|
|
124
|
+
});
|
|
125
|
+
const StyledButton = styled("button").withConfig({
|
|
126
|
+
shouldForwardProp
|
|
155
127
|
}).attrs(attrs).withConfig({
|
|
156
128
|
displayName: "Button__StyledButton",
|
|
157
129
|
componentId: "sc-10uojnk-0"
|
|
158
130
|
})(["", ""], buttonStyles);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return props.height || props.width ? "flex" : props.display || "inline-block";
|
|
163
|
-
}, function (props) {
|
|
164
|
-
return props.alignItems || "center";
|
|
165
|
-
});
|
|
166
|
-
var StyledButtonLink = styled.a.withConfig({
|
|
167
|
-
shouldForwardProp: shouldForwardProp
|
|
131
|
+
const linkStyles = css(["width:", ";display:", ";align-items:", ";"], props => props.width || "fit-content", props => props.height || props.width ? "flex" : props.display || "inline-block", props => props.alignItems || "center");
|
|
132
|
+
const StyledButtonLink = styled.a.withConfig({
|
|
133
|
+
shouldForwardProp
|
|
168
134
|
}).attrs(attrs).withConfig({
|
|
169
135
|
displayName: "Button__StyledButtonLink",
|
|
170
136
|
componentId: "sc-10uojnk-1"
|
|
171
137
|
})(["", " ", ""], buttonStyles, linkStyles);
|
|
172
|
-
|
|
173
|
-
shouldForwardProp
|
|
138
|
+
const StyledReactButtonLink = styled(Link).withConfig({
|
|
139
|
+
shouldForwardProp
|
|
174
140
|
}).attrs(attrs).withConfig({
|
|
175
141
|
displayName: "Button__StyledReactButtonLink",
|
|
176
142
|
componentId: "sc-10uojnk-2"
|
|
177
143
|
})(["", " ", ""], buttonStyles, linkStyles);
|
|
178
|
-
|
|
144
|
+
const buttonPropTypes = {
|
|
179
145
|
/** Large button */
|
|
180
146
|
large: PropTypes.bool,
|
|
181
147
|
/** Small button */
|
|
@@ -205,62 +171,75 @@ var buttonPropTypes = {
|
|
|
205
171
|
/** Specifies the `data-testid` attribute for testing. */
|
|
206
172
|
dataTestId: PropTypes.string,
|
|
207
173
|
/** Specifies aria-label for iconOnly buttons. This is only required if the iconOnly button is used, as it doesn't have supporting text for accessibility.*/
|
|
208
|
-
ariaLabel:
|
|
174
|
+
ariaLabel: (props, propName) => {
|
|
209
175
|
if (props.iconOnly && (props[propName] == null || props[propName] === "")) {
|
|
210
176
|
return new Error("Missing prop `".concat(propName, "` not specified for Button component. When `iconOnly` is true, `").concat(propName, "` is required."));
|
|
211
177
|
}
|
|
212
178
|
if (props[propName] && typeof props[propName] !== "string") {
|
|
213
|
-
return new Error("Invalid propType for `".concat(propName, "` supplied to Button component. Expected `string`, received `").concat(
|
|
179
|
+
return new Error("Invalid propType for `".concat(propName, "` supplied to Button component. Expected `string`, received `").concat(typeof props[propName], "`."));
|
|
214
180
|
}
|
|
215
181
|
return null;
|
|
216
182
|
},
|
|
217
183
|
/** Specifies the color theme object. */
|
|
218
184
|
theme: PropTypes.object
|
|
219
185
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
186
|
+
const renderButton = (ButtonComponent, _ref) => {
|
|
187
|
+
let {
|
|
188
|
+
ariaLabel,
|
|
189
|
+
...props
|
|
190
|
+
} = _ref;
|
|
191
|
+
return /*#__PURE__*/_jsxs(ButtonComponent, {
|
|
192
|
+
borderStyle: "solid",
|
|
193
|
+
...props.ButtonStyles,
|
|
194
|
+
...props,
|
|
226
195
|
"aria-label": ariaLabel,
|
|
227
|
-
ref: props.ref
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
196
|
+
ref: props.ref,
|
|
197
|
+
children: [props.leftIcon && /*#__PURE__*/_jsx(Icon, {
|
|
198
|
+
icon: props.leftIcon,
|
|
199
|
+
mr: props.small ? "xxs" : "xs"
|
|
200
|
+
}), props.children, props.rightIcon && /*#__PURE__*/_jsx(Icon, {
|
|
201
|
+
icon: props.rightIcon,
|
|
202
|
+
ml: props.small ? "xxs" : "xs"
|
|
203
|
+
}), props.isLoading && /*#__PURE__*/_jsx(Loading, {
|
|
204
|
+
inverted: true,
|
|
205
|
+
ml: "s"
|
|
206
|
+
})]
|
|
207
|
+
});
|
|
238
208
|
};
|
|
239
|
-
export
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
209
|
+
export const ButtonLink = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
210
|
+
const {
|
|
211
|
+
theme
|
|
212
|
+
} = props;
|
|
213
|
+
const component = renderButton(props.to ? StyledReactButtonLink : StyledButtonLink, {
|
|
214
|
+
...omit(props, "isLoading"),
|
|
215
|
+
ref
|
|
216
|
+
});
|
|
217
|
+
return theme ? /*#__PURE__*/_jsx(ThemeProvider, {
|
|
218
|
+
theme: theme,
|
|
219
|
+
children: component
|
|
220
|
+
}) : component;
|
|
247
221
|
});
|
|
248
|
-
ButtonLink.propTypes =
|
|
222
|
+
ButtonLink.propTypes = {
|
|
223
|
+
...buttonPropTypes,
|
|
249
224
|
target: PropTypes.string,
|
|
250
225
|
/** Link to navigate user to */
|
|
251
226
|
href: PropTypes.string
|
|
252
|
-
}
|
|
227
|
+
};
|
|
253
228
|
ButtonLink.defaultProps = {
|
|
254
229
|
variant: "default"
|
|
255
230
|
};
|
|
256
|
-
export
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
231
|
+
export const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
232
|
+
const {
|
|
233
|
+
theme
|
|
234
|
+
} = props;
|
|
235
|
+
const component = renderButton(StyledButton, {
|
|
236
|
+
...props,
|
|
237
|
+
ref
|
|
238
|
+
});
|
|
239
|
+
return theme ? /*#__PURE__*/_jsx(ThemeProvider, {
|
|
240
|
+
theme: theme,
|
|
241
|
+
children: component
|
|
242
|
+
}) : component;
|
|
264
243
|
});
|
|
265
244
|
Button.__docgenInfo = {
|
|
266
245
|
"description": "",
|
|
@@ -416,10 +395,11 @@ Button.__docgenInfo = {
|
|
|
416
395
|
}
|
|
417
396
|
};
|
|
418
397
|
export default Button;
|
|
419
|
-
Button.propTypes =
|
|
398
|
+
Button.propTypes = {
|
|
399
|
+
...buttonPropTypes,
|
|
420
400
|
/** Function to run when the `Button` is clicked */
|
|
421
401
|
onClick: PropTypes.func
|
|
422
|
-
}
|
|
402
|
+
};
|
|
423
403
|
Button.defaultProps = {
|
|
424
404
|
variant: "default"
|
|
425
405
|
};
|