@thecb/components 6.0.0 → 6.0.3
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/dist/index.cjs.js +14 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +10 -6
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +3 -0
- package/src/components/molecules/modal/Modal.js +70 -57
- package/src/components/molecules/modal/Modal.stories.js +52 -3
- package/src/util/general.js +21 -0
- package/src/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, Fragment, useState, useRef, createRef } from "react";
|
|
2
2
|
import { Box, Stack } from "../layouts";
|
|
3
3
|
import Text from "../text";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
noop,
|
|
6
|
+
inputDisabledStyle,
|
|
7
|
+
inputPlaceholderTextStyle
|
|
8
|
+
} from "../../../util/general";
|
|
5
9
|
import DropdownIcon from "./DropdownIcon";
|
|
6
10
|
import styled from "styled-components";
|
|
7
11
|
// support for Array.prototype.at() in older browsers
|
|
@@ -12,7 +16,8 @@ import {
|
|
|
12
16
|
GREY_CHATEAU,
|
|
13
17
|
STORM_GREY,
|
|
14
18
|
MINESHAFT_GREY,
|
|
15
|
-
ERROR_COLOR
|
|
19
|
+
ERROR_COLOR,
|
|
20
|
+
CHARADE_GREY
|
|
16
21
|
} from "../../../constants/colors";
|
|
17
22
|
import { fallbackValues } from "./Dropdown.theme";
|
|
18
23
|
import { themeComponent } from "../../../util/themeUtils";
|
|
@@ -300,10 +305,9 @@ const Dropdown = ({
|
|
|
300
305
|
: GREY_CHATEAU
|
|
301
306
|
}
|
|
302
307
|
extraStyles={
|
|
303
|
-
disabled
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
pointer-events: none;`
|
|
308
|
+
disabled
|
|
309
|
+
? `${inputPlaceholderTextStyle}${inputDisabledStyle}`
|
|
310
|
+
: inputPlaceholderTextStyle
|
|
307
311
|
}
|
|
308
312
|
hoverStyles={`background-color: ${themeValues.hoverColor};`}
|
|
309
313
|
isOpen={isOpen}
|
|
@@ -34,6 +34,7 @@ const Modal = ({
|
|
|
34
34
|
useDangerButton = false,
|
|
35
35
|
defaultWrapper = true,
|
|
36
36
|
onlyCloseButton = false,
|
|
37
|
+
noButtons = false, // for instances where modal is closed automatically
|
|
37
38
|
maxHeight,
|
|
38
39
|
underlayClickExits = true,
|
|
39
40
|
noBorder,
|
|
@@ -98,69 +99,81 @@ const Modal = ({
|
|
|
98
99
|
align="center"
|
|
99
100
|
childGap="0rem"
|
|
100
101
|
>
|
|
101
|
-
{!
|
|
102
|
-
|
|
103
|
-
{
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
{!noButtons && (
|
|
103
|
+
<>
|
|
104
|
+
{!onlyCloseButton ? (
|
|
105
|
+
<Fragment>
|
|
106
|
+
{isMobile ? (
|
|
107
|
+
<Stack childGap="1rem" direction="row">
|
|
108
|
+
<Box width="100%" padding="0">
|
|
109
|
+
<ButtonWithAction
|
|
110
|
+
variant="secondary"
|
|
111
|
+
action={
|
|
112
|
+
cancelAction ? cancelAction : hideModal
|
|
113
|
+
}
|
|
114
|
+
text={cancelButtonText}
|
|
115
|
+
dataQa={cancelButtonText}
|
|
116
|
+
extraStyles={buttonExtraStyles}
|
|
117
|
+
className="modal-cancel-button"
|
|
118
|
+
/>
|
|
119
|
+
</Box>
|
|
120
|
+
<Box width="100%" padding="0">
|
|
121
|
+
<ButtonWithAction
|
|
122
|
+
variant={
|
|
123
|
+
useDangerButton ? "danger" : "primary"
|
|
124
|
+
}
|
|
125
|
+
action={continueAction}
|
|
126
|
+
text={continueButtonText}
|
|
127
|
+
dataQa={continueButtonText}
|
|
128
|
+
isLoading={isLoading}
|
|
129
|
+
extraStyles={buttonExtraStyles}
|
|
130
|
+
className="modal-continue-button"
|
|
131
|
+
/>
|
|
132
|
+
</Box>
|
|
133
|
+
</Stack>
|
|
134
|
+
) : (
|
|
135
|
+
<Stack
|
|
136
|
+
childGap="1rem"
|
|
137
|
+
direction="row"
|
|
138
|
+
justify="flex-end"
|
|
139
|
+
>
|
|
140
|
+
<ButtonWithAction
|
|
141
|
+
variant="secondary"
|
|
142
|
+
action={
|
|
143
|
+
cancelAction ? cancelAction : hideModal
|
|
144
|
+
}
|
|
145
|
+
text={cancelButtonText}
|
|
146
|
+
dataQa={cancelButtonText}
|
|
147
|
+
extraStyles={buttonExtraStyles}
|
|
148
|
+
className="modal-cancel-button"
|
|
149
|
+
/>
|
|
150
|
+
<ButtonWithAction
|
|
151
|
+
variant={
|
|
152
|
+
useDangerButton ? "danger" : "primary"
|
|
153
|
+
}
|
|
154
|
+
action={continueAction}
|
|
155
|
+
text={continueButtonText}
|
|
156
|
+
dataQa={continueButtonText}
|
|
157
|
+
isLoading={isLoading}
|
|
158
|
+
extraStyles={buttonExtraStyles}
|
|
159
|
+
className="modal-continue-button"
|
|
160
|
+
/>
|
|
161
|
+
</Stack>
|
|
162
|
+
)}
|
|
163
|
+
</Fragment>
|
|
127
164
|
) : (
|
|
128
|
-
<
|
|
129
|
-
childGap="1rem"
|
|
130
|
-
direction="row"
|
|
131
|
-
justify="flex-end"
|
|
132
|
-
>
|
|
165
|
+
<Box padding="0.5rem">
|
|
133
166
|
<ButtonWithAction
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
text=
|
|
137
|
-
dataQa=
|
|
167
|
+
action={hideModal}
|
|
168
|
+
variant="primary"
|
|
169
|
+
text="Close"
|
|
170
|
+
dataQa="Close"
|
|
138
171
|
extraStyles={buttonExtraStyles}
|
|
139
172
|
className="modal-cancel-button"
|
|
140
173
|
/>
|
|
141
|
-
|
|
142
|
-
variant={useDangerButton ? "danger" : "primary"}
|
|
143
|
-
action={continueAction}
|
|
144
|
-
text={continueButtonText}
|
|
145
|
-
dataQa={continueButtonText}
|
|
146
|
-
isLoading={isLoading}
|
|
147
|
-
extraStyles={buttonExtraStyles}
|
|
148
|
-
className="modal-continue-button"
|
|
149
|
-
/>
|
|
150
|
-
</Stack>
|
|
174
|
+
</Box>
|
|
151
175
|
)}
|
|
152
|
-
|
|
153
|
-
) : (
|
|
154
|
-
<Box padding="0.5rem">
|
|
155
|
-
<ButtonWithAction
|
|
156
|
-
action={hideModal}
|
|
157
|
-
variant="primary"
|
|
158
|
-
text="Close"
|
|
159
|
-
dataQa="Close"
|
|
160
|
-
extraStyles={buttonExtraStyles}
|
|
161
|
-
className="modal-cancel-button"
|
|
162
|
-
/>
|
|
163
|
-
</Box>
|
|
176
|
+
</>
|
|
164
177
|
)}
|
|
165
178
|
</Stack>
|
|
166
179
|
</Box>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { text, boolean } from "@storybook/addon-knobs";
|
|
3
3
|
import Modal from "./Modal";
|
|
4
4
|
|
|
@@ -6,7 +6,8 @@ import page from "../../../../.storybook/page";
|
|
|
6
6
|
|
|
7
7
|
import Text from "../../atoms/text";
|
|
8
8
|
import { noop } from "../../../util/general";
|
|
9
|
-
|
|
9
|
+
import Spinner from "../../atoms/spinner/Spinner";
|
|
10
|
+
import { Center } from "../../atoms/layouts";
|
|
10
11
|
const groupId = "props";
|
|
11
12
|
export const modal = () => (
|
|
12
13
|
<Modal
|
|
@@ -23,7 +24,7 @@ export const modal = () => (
|
|
|
23
24
|
)}
|
|
24
25
|
hideModal={noop}
|
|
25
26
|
continueAction={noop}
|
|
26
|
-
modalOpen={boolean("modalOpen",
|
|
27
|
+
modalOpen={boolean("modalOpen", true, groupId)}
|
|
27
28
|
modalHeaderText={text("modalHeaderText", "Modal Header Text", groupId)}
|
|
28
29
|
modalBodyText={text("modalBodyText", "Modal Body Text", groupId)}
|
|
29
30
|
cancelButtonText={text("cancelButtonText", "Cancel", groupId)}
|
|
@@ -37,6 +38,54 @@ export const modal = () => (
|
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
40
|
|
|
41
|
+
modal.storyName = "Standard Modal";
|
|
42
|
+
|
|
43
|
+
export const modalWithoutButtons = () => {
|
|
44
|
+
const [isModalOpen, setIsModalOpen] = useState(true);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
// some async action or timer closes the modal instead
|
|
48
|
+
setIsModalOpen(false);
|
|
49
|
+
}, 3000);
|
|
50
|
+
}, []);
|
|
51
|
+
return (
|
|
52
|
+
<Modal
|
|
53
|
+
ModalLink={() => (
|
|
54
|
+
<Text
|
|
55
|
+
tabIndex={0}
|
|
56
|
+
onClick={noop}
|
|
57
|
+
color={"#347BB2"}
|
|
58
|
+
fontSize="18px"
|
|
59
|
+
lineHeight="2rem"
|
|
60
|
+
extraStyles={`cursor: pointer;`}
|
|
61
|
+
>
|
|
62
|
+
Modal Link
|
|
63
|
+
</Text>
|
|
64
|
+
)}
|
|
65
|
+
hideModal={noop}
|
|
66
|
+
continueAction={noop}
|
|
67
|
+
modalOpen={isModalOpen}
|
|
68
|
+
modalHeaderText={text(
|
|
69
|
+
"modalHeaderText",
|
|
70
|
+
"Modal Without Buttons",
|
|
71
|
+
groupId
|
|
72
|
+
)}
|
|
73
|
+
modalBodyText={
|
|
74
|
+
<Center tabIndex={0}>
|
|
75
|
+
<Spinner size="100" />
|
|
76
|
+
</Center>
|
|
77
|
+
}
|
|
78
|
+
modalHeaderBg={text("modalHeaderBg", "white", groupId)}
|
|
79
|
+
modalBodyBg={text("modalBodyBg", "#F6F6F9", groupId)}
|
|
80
|
+
defaultWrapper={boolean("defaultWrapper", true, groupId)}
|
|
81
|
+
noButtons={boolean("noButtons", true, groupId)}
|
|
82
|
+
maxHeight={text("maxHeight", null, groupId)}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
modalWithoutButtons.storyName = "Modal Without Buttons";
|
|
88
|
+
|
|
40
89
|
const story = page({
|
|
41
90
|
title: "Components|Molecules/Modal",
|
|
42
91
|
Component: Modal
|
package/src/util/general.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import numeral from "numeral";
|
|
3
|
+
import { CHARADE_GREY } from "../constants/colors";
|
|
3
4
|
|
|
4
5
|
export const noop = () => {};
|
|
5
6
|
|
|
@@ -96,3 +97,23 @@ export const screenReaderOnlyStyle = `
|
|
|
96
97
|
height: 1px;
|
|
97
98
|
overflow: hidden;
|
|
98
99
|
`;
|
|
100
|
+
|
|
101
|
+
export const inputPlaceholderTextStyle = `
|
|
102
|
+
::-webkit-input-placeholder {
|
|
103
|
+
color: ${CHARADE_GREY};
|
|
104
|
+
}
|
|
105
|
+
::-moz-placeholder {
|
|
106
|
+
color: ${CHARADE_GREY};
|
|
107
|
+
}
|
|
108
|
+
::-ms-placeholder {
|
|
109
|
+
color: ${CHARADE_GREY};
|
|
110
|
+
}
|
|
111
|
+
::placeholder {
|
|
112
|
+
color: ${CHARADE_GREY};
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
export const inputDisabledStyle = `
|
|
116
|
+
color: #6e727e;
|
|
117
|
+
background-color: #f7f7f7;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
`;
|
package/src/.DS_Store
DELETED
|
Binary file
|