@thecb/components 3.1.1 → 3.1.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/.storybook/main.js +4 -0
- package/.storybook/page.js +61 -0
- package/.storybook/themes/apc.theme.js +1 -0
- package/.storybook/themes/index.js +2 -0
- package/.storybook/themes/sf.theme.js +1 -0
- package/.tool-versions +1 -0
- package/dist/index.cjs.js +174 -13039
- package/package.json +12 -4
- package/rollup.config.js +0 -2
- package/src/components/atoms/breadcrumb/Breadcrumb.js +7 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.theme.js +3 -1
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +31 -122
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +20 -7
- package/src/components/atoms/button-with-link/ButtonWithLink.js +17 -3
- package/src/components/atoms/dropdown/Dropdown.js +3 -6
- package/src/components/atoms/dropdown/Dropdown.stories.js +70 -0
- package/src/components/atoms/link/ExternalLink.styled.js +2 -2
- package/src/components/atoms/link/InternalLink.styled.js +7 -4
- package/src/components/atoms/radio-button/RadioButton.stories.js +69 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +1 -1
- package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +70 -0
- package/src/components/molecules/address-form/AddressForm.stories.js +21 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +22 -0
- package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +24 -0
- package/src/components/molecules/email-form/EmailForm.stories.js +24 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.stories.js +24 -0
- package/src/components/molecules/login-form/LoginForm.stories.js +24 -0
- package/src/components/molecules/phone-form/PhoneForm.stories.js +24 -0
- package/src/components/molecules/registration-form/RegistrationForm.stories.js +24 -0
- package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.stories.js +11 -0
- package/src/components/molecules/reset-password-form/ResetPasswordForm.stories.js +24 -0
- package/src/components/molecules/reset-password-success/ResetPasswordSuccess.stories.js +11 -0
- package/src/components/molecules/tab-sidebar/TabSidebar.js +2 -1
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"source": "src/index.js",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"storybook": "start-storybook",
|
|
9
10
|
"build": "rollup -c"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
@@ -27,12 +28,14 @@
|
|
|
27
28
|
"@storybook/addon-a11y": "^5.3.14",
|
|
28
29
|
"@storybook/addon-actions": "^5.3.14",
|
|
29
30
|
"@storybook/addon-console": "^1.2.1",
|
|
31
|
+
"@storybook/addon-docs": "^5.3.19",
|
|
30
32
|
"@storybook/addon-knobs": "^5.3.14",
|
|
31
33
|
"@storybook/addon-storysource": "^5.3.14",
|
|
32
34
|
"@storybook/addon-viewport": "^5.3.14",
|
|
33
35
|
"@storybook/react": "^5.3.14",
|
|
34
36
|
"babel-core": "^6.26.3",
|
|
35
37
|
"babel-eslint": "^10.1.0",
|
|
38
|
+
"babel-loader": "^8.1.0",
|
|
36
39
|
"babel-preset-env": "^1.7.0",
|
|
37
40
|
"babel-preset-react": "^6.24.1",
|
|
38
41
|
"eslint": "^6.8.0",
|
|
@@ -40,16 +43,22 @@
|
|
|
40
43
|
"eslint-plugin-babel": "^5.3.0",
|
|
41
44
|
"eslint-plugin-prettier": "^3.1.3",
|
|
42
45
|
"eslint-plugin-react": "^7.20.0",
|
|
46
|
+
"history": "^5.0.0",
|
|
43
47
|
"husky": "^4.2.3",
|
|
44
48
|
"prettier": "^1.19.1",
|
|
45
49
|
"pretty-quick": "^2.0.1",
|
|
50
|
+
"react-redux": "^7.2.0",
|
|
51
|
+
"react-router-dom": "^5.2.0",
|
|
52
|
+
"redux": "^4.0.5",
|
|
46
53
|
"rollup": "^1.21.4",
|
|
47
54
|
"rollup-plugin-babel": "^4.3.3",
|
|
48
55
|
"rollup-plugin-commonjs": "^10.0.0",
|
|
49
56
|
"rollup-plugin-json": "^4.0.0",
|
|
50
57
|
"rollup-plugin-node-resolve": "^5.1.0",
|
|
51
58
|
"rollup-plugin-visualizer": "^4.0.4",
|
|
52
|
-
"storybook": "^5.3.14"
|
|
59
|
+
"storybook": "^5.3.14",
|
|
60
|
+
"styled-components": "^5.1.1",
|
|
61
|
+
"styled-theming": "^2.2.0"
|
|
53
62
|
},
|
|
54
63
|
"peerDependencies": {
|
|
55
64
|
"ramda": "^0.27.0",
|
|
@@ -70,7 +79,6 @@
|
|
|
70
79
|
"numeral": "^2.0.6",
|
|
71
80
|
"react-aria-modal": "^4.0.0",
|
|
72
81
|
"react-pose": "^4.0.10",
|
|
73
|
-
"redux-freeform": "^4.1.3"
|
|
74
|
-
"sanctuary": "^3.0.0"
|
|
82
|
+
"redux-freeform": "^4.1.3"
|
|
75
83
|
}
|
|
76
84
|
}
|
package/rollup.config.js
CHANGED
|
@@ -5,7 +5,6 @@ import json from "rollup-plugin-json";
|
|
|
5
5
|
import visualizer from "rollup-plugin-visualizer";
|
|
6
6
|
import pkg from "./package.json";
|
|
7
7
|
|
|
8
|
-
import * as sanctuary from "sanctuary";
|
|
9
8
|
import * as formattedInput from "formatted-input";
|
|
10
9
|
|
|
11
10
|
const globals = {
|
|
@@ -23,7 +22,6 @@ const plugins = [
|
|
|
23
22
|
commonjs({
|
|
24
23
|
include: "node_modules/**",
|
|
25
24
|
namedExports: {
|
|
26
|
-
sanctuary: Object.keys(sanctuary),
|
|
27
25
|
"formatted-input": Object.keys(formattedInput)
|
|
28
26
|
}
|
|
29
27
|
}),
|
|
@@ -30,8 +30,15 @@ const Breadcrumbs = ({ breadcrumbsList = [] }) => {
|
|
|
30
30
|
margin={themeValues.margin}
|
|
31
31
|
extraStyles={`
|
|
32
32
|
text-transform: uppercase;
|
|
33
|
+
${isActive.toString() === "true" &&
|
|
34
|
+
`pointer-events: none;
|
|
35
|
+
color: ${themeValues.activeBreadcrumbColor};
|
|
36
|
+
`}
|
|
33
37
|
&:first-child {
|
|
34
38
|
margin-left: 0;
|
|
39
|
+
}
|
|
40
|
+
&:active {
|
|
41
|
+
color: ${themeValues.activeColor};
|
|
35
42
|
}`}
|
|
36
43
|
>
|
|
37
44
|
{linkText}
|
|
@@ -7,7 +7,8 @@ import { MATISSE_BLUE, STORM_GREY } from "../../../constants/colors";
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const color = `${MATISSE_BLUE}`;
|
|
10
|
-
const activeColor =
|
|
10
|
+
const activeColor = `${STORM_GREY}`;
|
|
11
|
+
const activeBreadcrumbColor = `${STORM_GREY}`;
|
|
11
12
|
const fontSize = "0.875rem";
|
|
12
13
|
const lineHeight = "1.25rem";
|
|
13
14
|
const fontWeight = "400";
|
|
@@ -17,6 +18,7 @@ const hover = `text-decoration: none;`;
|
|
|
17
18
|
export const fallbackValues = {
|
|
18
19
|
color,
|
|
19
20
|
activeColor,
|
|
21
|
+
activeBreadcrumbColor,
|
|
20
22
|
fontSize,
|
|
21
23
|
lineHeight,
|
|
22
24
|
fontWeight,
|
|
@@ -1,125 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { text, select, boolean } from "@storybook/addon-knobs";
|
|
3
3
|
import ButtonWithAction from "./ButtonWithAction";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
secondary: `#357FB8`,
|
|
18
|
-
small: `#FFFFFF`,
|
|
19
|
-
smallSecondary: `#357FB8`
|
|
20
|
-
},
|
|
21
|
-
fontWeight: `600`,
|
|
22
|
-
fontSize: `1.125rem`,
|
|
23
|
-
border: {
|
|
24
|
-
primary: `1px solid #357FB8`,
|
|
25
|
-
secondary: `2px solid #357FB8`,
|
|
26
|
-
small: `1px solid #357FB8`,
|
|
27
|
-
smallSecondary: `2px solid #357FB8`
|
|
28
|
-
},
|
|
29
|
-
height: {
|
|
30
|
-
primary: `3rem`,
|
|
31
|
-
secondary: `3rem`,
|
|
32
|
-
small: `2.5rem`,
|
|
33
|
-
smallSecondary: `2.5rem`
|
|
34
|
-
},
|
|
35
|
-
padding: {
|
|
36
|
-
primary: `0.75rem 2rem`,
|
|
37
|
-
secondary: `0.75rem 2rem`,
|
|
38
|
-
small: `0.625rem 1rem`,
|
|
39
|
-
smallSecondary: `0.625rem 1rem`
|
|
40
|
-
},
|
|
41
|
-
focus: `outline: none; box-shadow: 0 0 4px #357FB8`,
|
|
42
|
-
active: {
|
|
43
|
-
primary: `background-color: #182848; border: 1px solid #182848; box-shadow: 0 0 4px #357FB8`,
|
|
44
|
-
secondary: `background-color: #357FB8; color: #FFFFFF; box-shadow: 0 0 4px #357FB8`,
|
|
45
|
-
small: `background-color: #182848; border: 1px solid #182848; box-shadow: 0 0 4px #357FB8`,
|
|
46
|
-
smallSecondary: `background-color: #357FB8; color: #FFFFFF; box-shadow: 0 0 4px #357FB8`
|
|
47
|
-
},
|
|
48
|
-
disabled: {
|
|
49
|
-
primary: `background-color: #6E727E; border: 1px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`,
|
|
50
|
-
secondary: `color: #6E727E; border: 2px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`,
|
|
51
|
-
small: `background-color: #6E727E; border: 1px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E`,
|
|
52
|
-
smallSecondary: `color: #6E727E; border: 2px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
title: "Themed Button",
|
|
59
|
-
component: ButtonWithAction,
|
|
60
|
-
decorators: [
|
|
61
|
-
withKnobs,
|
|
62
|
-
storyFn => (
|
|
63
|
-
<ThemeProvider
|
|
64
|
-
theme={{
|
|
65
|
-
name: text("Theme Name", "default"),
|
|
66
|
-
values: fakeTheme
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
69
|
-
<Cover>
|
|
70
|
-
<div />
|
|
71
|
-
<Center>{storyFn()}</Center>
|
|
72
|
-
<div />
|
|
73
|
-
</Cover>
|
|
74
|
-
</ThemeProvider>
|
|
75
|
-
)
|
|
76
|
-
]
|
|
4
|
+
import page from "../../../../.storybook/page";
|
|
5
|
+
|
|
6
|
+
const variantsLabel = "variant";
|
|
7
|
+
const variants = {
|
|
8
|
+
primary: "primary",
|
|
9
|
+
secondary: "secondary",
|
|
10
|
+
back: "back",
|
|
11
|
+
smallPrimary: "smallPrimary",
|
|
12
|
+
smallSecondary: "smallSecondary",
|
|
13
|
+
ghost: "ghost",
|
|
14
|
+
smallGhost: "smallGhost",
|
|
15
|
+
danger: "danger",
|
|
16
|
+
None: undefined
|
|
77
17
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
smallButtonDefault.story = { name: "Default Small Button" };
|
|
96
|
-
|
|
97
|
-
export const smallSecondaryButtonDefault = () => (
|
|
98
|
-
<ButtonWithAction variant="smallSecondary" text="Small Secondary" />
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
smallSecondaryButtonDefault.story = { name: "Default Small Secondary Button" };
|
|
102
|
-
|
|
103
|
-
export const primaryButtonThemed = () => (
|
|
104
|
-
<ButtonWithAction variant="primary" text="Primary Themed" />
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
primaryButtonThemed.story = { name: "Themed Primary Button" };
|
|
108
|
-
|
|
109
|
-
export const secondaryButtonThemed = () => (
|
|
110
|
-
<ButtonWithAction variant="secondary" text="Themed Secondary" />
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
secondaryButtonThemed.story = { name: "Themed Secondary Button" };
|
|
114
|
-
|
|
115
|
-
export const smallButtonThemed = () => (
|
|
116
|
-
<ButtonWithAction variant="small" text="Themed Small" />
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
smallButtonThemed.story = { name: "Themed Small Button" };
|
|
120
|
-
|
|
121
|
-
export const smallSecondaryButtonThemed = () => (
|
|
122
|
-
<ButtonWithAction variant="smallSecondary" text="Small Secondary" />
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
smallSecondaryButtonThemed.story = { name: "Themed Small Secondary Button" };
|
|
18
|
+
const defaultValue = "primary";
|
|
19
|
+
const groupId = "props";
|
|
20
|
+
|
|
21
|
+
export const buttonWithAction = () => (
|
|
22
|
+
<ButtonWithAction
|
|
23
|
+
variant={select(variantsLabel, variants, defaultValue, groupId)}
|
|
24
|
+
text={text("text", "button", "props")}
|
|
25
|
+
isLoading={boolean("isLoading", false, "props")}
|
|
26
|
+
action={text("action", undefined, "props")}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const story = page({
|
|
31
|
+
title: "Components|Atoms/ButtonWithAction",
|
|
32
|
+
Component: ButtonWithAction
|
|
33
|
+
});
|
|
34
|
+
export default story;
|
|
@@ -51,7 +51,8 @@ const fontWeight = {
|
|
|
51
51
|
smallGhost: "400",
|
|
52
52
|
ghost: "600",
|
|
53
53
|
danger: "600",
|
|
54
|
-
whiteSecondary: "600"
|
|
54
|
+
whiteSecondary: "600",
|
|
55
|
+
whitePrimary: "600"
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
const height = {
|
|
@@ -114,7 +115,9 @@ const hoverBackgroundColor = {
|
|
|
114
115
|
smallSecondary: "transparent",
|
|
115
116
|
ghost: "transparent",
|
|
116
117
|
smallGhost: "transparent",
|
|
117
|
-
danger: "#BA002C"
|
|
118
|
+
danger: "#BA002C",
|
|
119
|
+
whiteSecondary: "transparent",
|
|
120
|
+
whitePrimary: "transparent"
|
|
118
121
|
};
|
|
119
122
|
|
|
120
123
|
const hoverBorderColor = {
|
|
@@ -125,7 +128,9 @@ const hoverBorderColor = {
|
|
|
125
128
|
smallSecondary: "#DCEAF1",
|
|
126
129
|
ghost: "transparent",
|
|
127
130
|
smallGhost: "transparent",
|
|
128
|
-
danger: "#BA002C"
|
|
131
|
+
danger: "#BA002C",
|
|
132
|
+
whiteSecondary: "2px solid transparent",
|
|
133
|
+
whitePrimary: "2px solid transparent"
|
|
129
134
|
};
|
|
130
135
|
|
|
131
136
|
const hoverColor = {
|
|
@@ -136,7 +141,9 @@ const hoverColor = {
|
|
|
136
141
|
smallSecondary: "#116285",
|
|
137
142
|
ghost: "#116285",
|
|
138
143
|
smallGhost: "#116285",
|
|
139
|
-
danger: "#FFFFFF"
|
|
144
|
+
danger: "#FFFFFF",
|
|
145
|
+
whiteSecondary: "#FFFFFF",
|
|
146
|
+
whitePrimary: "#FFFFFF"
|
|
140
147
|
};
|
|
141
148
|
|
|
142
149
|
const activeBackgroundColor = {
|
|
@@ -147,7 +154,9 @@ const activeBackgroundColor = {
|
|
|
147
154
|
smallSecondary: "transparent",
|
|
148
155
|
ghost: "transparent",
|
|
149
156
|
smallGhost: "transparent",
|
|
150
|
-
danger: "#870000"
|
|
157
|
+
danger: "#870000",
|
|
158
|
+
whiteSecondary: "transparent",
|
|
159
|
+
whitePrimary: "transparent"
|
|
151
160
|
};
|
|
152
161
|
|
|
153
162
|
const activeBorderColor = {
|
|
@@ -158,7 +167,9 @@ const activeBorderColor = {
|
|
|
158
167
|
smallSecondary: "#0E506D",
|
|
159
168
|
ghost: "transparent",
|
|
160
169
|
smallGhost: "transparent",
|
|
161
|
-
danger: "#870000"
|
|
170
|
+
danger: "#870000",
|
|
171
|
+
whiteSecondary: "2px solid transparent",
|
|
172
|
+
whitePrimary: "2px solid transparent"
|
|
162
173
|
};
|
|
163
174
|
|
|
164
175
|
const activeColor = {
|
|
@@ -169,7 +180,9 @@ const activeColor = {
|
|
|
169
180
|
smallSecondary: "#0E506D",
|
|
170
181
|
ghost: "#0E506D",
|
|
171
182
|
smallGhost: "#0E506D",
|
|
172
|
-
danger: "#FFFFFF"
|
|
183
|
+
danger: "#FFFFFF",
|
|
184
|
+
whiteSecondary: "#FFFFFF",
|
|
185
|
+
whitePrimary: "#FFFFFF"
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
export const fallbackValues = {
|
|
@@ -9,14 +9,26 @@ const ButtonWithLink = ({
|
|
|
9
9
|
url = "/",
|
|
10
10
|
disabled = false,
|
|
11
11
|
extraStyles,
|
|
12
|
+
newTab = false,
|
|
12
13
|
...otherProps
|
|
13
14
|
}) => {
|
|
14
|
-
const ButtonWithLinkWrapper = ({
|
|
15
|
+
const ButtonWithLinkWrapper = ({
|
|
16
|
+
children,
|
|
17
|
+
url,
|
|
18
|
+
disabled,
|
|
19
|
+
newTab,
|
|
20
|
+
extraStyles
|
|
21
|
+
}) => {
|
|
15
22
|
if (disabled) {
|
|
16
23
|
return safeChildren(children, <span />);
|
|
17
24
|
}
|
|
18
25
|
return R.test(URL_TEST, url) ? (
|
|
19
|
-
<ExternalLink
|
|
26
|
+
<ExternalLink
|
|
27
|
+
href={url}
|
|
28
|
+
tabIndex="-1"
|
|
29
|
+
newTab={newTab}
|
|
30
|
+
extraStyles={extraStyles}
|
|
31
|
+
>
|
|
20
32
|
{safeChildren(children, <span />)}
|
|
21
33
|
</ExternalLink>
|
|
22
34
|
) : (
|
|
@@ -30,7 +42,9 @@ const ButtonWithLink = ({
|
|
|
30
42
|
<ButtonWithLinkWrapper
|
|
31
43
|
url={url}
|
|
32
44
|
disabled={disabled}
|
|
33
|
-
|
|
45
|
+
newTab={newTab}
|
|
46
|
+
extraStyles={`text-decoration: none; ${extraStyles} &:hover {
|
|
47
|
+
text-decoration: none; }`}
|
|
34
48
|
>
|
|
35
49
|
<ButtonWithAction {...otherProps} extraStyles={extraStyles} />
|
|
36
50
|
</ButtonWithLinkWrapper>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useEffect, Fragment, useState, useRef, createRef } from "react";
|
|
2
|
-
import { pipe, find, map, prop, fromMaybe } from "sanctuary";
|
|
3
2
|
import { Box, Stack } from "../layouts";
|
|
4
3
|
import Text from "../text";
|
|
5
4
|
import { noop } from "../../../util/general";
|
|
@@ -9,6 +8,7 @@ import styled from "styled-components";
|
|
|
9
8
|
import {
|
|
10
9
|
WHITE,
|
|
11
10
|
GREY_CHATEAU,
|
|
11
|
+
STORM_GREY,
|
|
12
12
|
MINESHAFT_GREY,
|
|
13
13
|
ERROR_COLOR
|
|
14
14
|
} from "../../../constants/colors";
|
|
@@ -50,6 +50,7 @@ const DropdownItemWrapper = styled.div`
|
|
|
50
50
|
padding: 1rem;
|
|
51
51
|
box-sizing: border-box;
|
|
52
52
|
width: 100%;
|
|
53
|
+
cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
|
|
53
54
|
|
|
54
55
|
&:hover {
|
|
55
56
|
background-color: ${({ selected, disabled, themeValues }) =>
|
|
@@ -232,11 +233,7 @@ const Dropdown = ({
|
|
|
232
233
|
) : (
|
|
233
234
|
<Text variant="p">
|
|
234
235
|
{value
|
|
235
|
-
?
|
|
236
|
-
find(option => option.value === value),
|
|
237
|
-
map(prop("text")),
|
|
238
|
-
fromMaybe(placeholder)
|
|
239
|
-
])(options)
|
|
236
|
+
? options.find(option => option.value === value)?.text
|
|
240
237
|
: placeholder}
|
|
241
238
|
</Text>
|
|
242
239
|
)}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { withKnobs, text } from "@storybook/addon-knobs";
|
|
3
|
+
import Dropdown from "./Dropdown";
|
|
4
|
+
import { Cover, Center } from "../layouts";
|
|
5
|
+
import { ThemeProvider } from "styled-components";
|
|
6
|
+
|
|
7
|
+
const fakeTheme = {
|
|
8
|
+
Dropdown: {
|
|
9
|
+
selectedColor: "#15749D",
|
|
10
|
+
hoverColor: "#EFFAFF"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: "Dropdown",
|
|
16
|
+
component: Dropdown,
|
|
17
|
+
decorators: [
|
|
18
|
+
withKnobs,
|
|
19
|
+
storyFn => (
|
|
20
|
+
<ThemeProvider
|
|
21
|
+
theme={{
|
|
22
|
+
name: text("Theme Name", "default"),
|
|
23
|
+
values: fakeTheme
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Cover>
|
|
27
|
+
<div />
|
|
28
|
+
<Center>{storyFn()}</Center>
|
|
29
|
+
<div />
|
|
30
|
+
</Cover>
|
|
31
|
+
</ThemeProvider>
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const options = [
|
|
37
|
+
{ text: "Please select an option", value: "" },
|
|
38
|
+
{ text: "OPTION_1", value: "OPTION_1" },
|
|
39
|
+
{ text: "OPTION_2", value: "OPTION_2" },
|
|
40
|
+
{ text: "DISABLED_OPTION", value: "DISABLED_OPTION" }
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const disabledValues = ["DISABLED_OPTION"];
|
|
44
|
+
|
|
45
|
+
export const dropdownDefault = () => {
|
|
46
|
+
const [isOpen, setOpen] = useState(false);
|
|
47
|
+
const [value, setValue] = useState(null);
|
|
48
|
+
const [isError, setError] = useState(false);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (value === options[0].value) {
|
|
52
|
+
setError(true);
|
|
53
|
+
} else {
|
|
54
|
+
setError(false);
|
|
55
|
+
}
|
|
56
|
+
}, [value]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Dropdown
|
|
60
|
+
placeholder={options[0].text}
|
|
61
|
+
options={options}
|
|
62
|
+
disabledValues={disabledValues}
|
|
63
|
+
value={value}
|
|
64
|
+
isOpen={isOpen}
|
|
65
|
+
isError={isError}
|
|
66
|
+
onSelect={setValue}
|
|
67
|
+
onClick={() => setOpen(!isOpen)}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -8,7 +8,7 @@ import styled from "styled-components";
|
|
|
8
8
|
|
|
9
9
|
/* eslint-disable no-unused-vars */
|
|
10
10
|
export const StyledExternalLink = styled(
|
|
11
|
-
({ hoverColor, activeColor,
|
|
11
|
+
({ hoverColor, activeColor, extrastyles, ...props }) => <a {...props} />
|
|
12
12
|
)`
|
|
13
13
|
display: flex;
|
|
14
14
|
font-size: ${({ size }) => size};
|
|
@@ -19,7 +19,7 @@ export const StyledExternalLink = styled(
|
|
|
19
19
|
|
|
20
20
|
&:hover,
|
|
21
21
|
&:focus {
|
|
22
|
-
color: ${({
|
|
22
|
+
color: ${({ hoverColor }) => hoverColor};
|
|
23
23
|
text-decoration: underline;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -9,21 +9,24 @@ import { Link } from "react-router-dom";
|
|
|
9
9
|
|
|
10
10
|
/* eslint-disable no-unused-vars */
|
|
11
11
|
export const StyledInternalLink = styled(
|
|
12
|
-
({ hoverColor, activeColor, active, ...props }) =>
|
|
12
|
+
({ hoverColor, activeColor, active, color, extrastyles, ...props }) => (
|
|
13
|
+
<Link {...props} />
|
|
14
|
+
)
|
|
13
15
|
)`
|
|
14
16
|
display: flex;
|
|
15
17
|
color: ${({ color, active, activeColor }) =>
|
|
16
|
-
active === true ? activeColor : color};
|
|
18
|
+
active === "true" ? activeColor : color};
|
|
17
19
|
font-weight: ${({ fontWeight }) => fontWeight};
|
|
18
20
|
line-height: ${({ lineheight }) => lineheight};
|
|
19
21
|
font-size: ${({ fontSize }) => fontSize};
|
|
20
22
|
font-family: ${({ fontFamily }) => fontFamily};
|
|
21
23
|
margin: ${({ margin }) => margin};
|
|
22
|
-
text-decoration: ${({ active }) =>
|
|
24
|
+
text-decoration: ${({ active }) =>
|
|
25
|
+
active === "true" ? "underline" : "none"};
|
|
23
26
|
|
|
24
27
|
&:hover,
|
|
25
28
|
&:focus {
|
|
26
|
-
color: ${({
|
|
29
|
+
color: ${({ hoverColor }) => hoverColor};
|
|
27
30
|
text-decoration: underline;
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { withKnobs, text, radios } from "@storybook/addon-knobs";
|
|
3
|
+
import RadioButton from "./RadioButton";
|
|
4
|
+
import { Box, Cover, Center } from "../layouts";
|
|
5
|
+
import { ThemeProvider } from "styled-components";
|
|
6
|
+
|
|
7
|
+
const fakeTheme = {
|
|
8
|
+
RadioButton: {
|
|
9
|
+
activeColor: "#15749D",
|
|
10
|
+
inactiveColor: "#959CA8"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: "Radio Button",
|
|
16
|
+
component: RadioButton,
|
|
17
|
+
decorators: [
|
|
18
|
+
withKnobs,
|
|
19
|
+
storyFn => (
|
|
20
|
+
<ThemeProvider
|
|
21
|
+
theme={{
|
|
22
|
+
name: text("Theme Name", "default"),
|
|
23
|
+
values: fakeTheme
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Cover>
|
|
27
|
+
<div />
|
|
28
|
+
<Center>{storyFn()}</Center>
|
|
29
|
+
<div />
|
|
30
|
+
</Cover>
|
|
31
|
+
</ThemeProvider>
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const radioButtonsDefault = () => {
|
|
37
|
+
const buttons = 3;
|
|
38
|
+
|
|
39
|
+
const [selected, setSelected] = useState(null);
|
|
40
|
+
const [focused, setFocused] = useState(null);
|
|
41
|
+
|
|
42
|
+
return [...Array(buttons).keys()].map(i => {
|
|
43
|
+
const name = `radio-button-${i}`;
|
|
44
|
+
return (
|
|
45
|
+
<Box
|
|
46
|
+
key={name}
|
|
47
|
+
onFocus={() => setFocused(name)}
|
|
48
|
+
onBlur={() => setFocused(null)}
|
|
49
|
+
extraStyles="outline: none;"
|
|
50
|
+
tabIndex="0"
|
|
51
|
+
>
|
|
52
|
+
<RadioButton
|
|
53
|
+
name={name}
|
|
54
|
+
radioOn={selected === name}
|
|
55
|
+
radioFocused={focused === name}
|
|
56
|
+
toggleRadio={() => setSelected(name)}
|
|
57
|
+
disabled={
|
|
58
|
+
radios(
|
|
59
|
+
"Disable Radio Buttons",
|
|
60
|
+
{ Enabled: "enabled", Disabled: "disabled" },
|
|
61
|
+
"enabled",
|
|
62
|
+
"RADIO-GROUP-1"
|
|
63
|
+
) === "disabled"
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
</Box>
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
@@ -7,6 +7,7 @@ import Heading from "../heading";
|
|
|
7
7
|
import { Box, Center, Cover, Cluster } from "../layouts";
|
|
8
8
|
import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
|
|
9
9
|
import { CHARADE_GREY } from "../../../constants/colors";
|
|
10
|
+
import { noop } from "../../../util/general";
|
|
10
11
|
|
|
11
12
|
const HiddenToggleSwitchBox = styled.input`
|
|
12
13
|
opacity: 0;
|
|
@@ -159,7 +160,6 @@ const ToggleSwitch = ({
|
|
|
159
160
|
extraStyles={
|
|
160
161
|
labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
|
|
161
162
|
}
|
|
162
|
-
hoverStyles={`outline: ${themeValues.onBackground} auto 5px`}
|
|
163
163
|
>
|
|
164
164
|
<Center>
|
|
165
165
|
<Cluster justify="stretch" align="center">
|