@thecb/components 3.3.2 → 3.3.5-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "3.3.2",
3
+ "version": "3.3.5-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -25,7 +25,7 @@
25
25
  "@babel/preset-react": "^7.0.0",
26
26
  "@babel/register": "^7.6.2",
27
27
  "@rollup/plugin-json": "^4.0.3",
28
- "@storybook/addon-a11y": "^5.3.14",
28
+ "@storybook/addon-a11y": "^5.3.19",
29
29
  "@storybook/addon-actions": "^5.3.14",
30
30
  "@storybook/addon-console": "^1.2.1",
31
31
  "@storybook/addon-docs": "^5.3.19",
@@ -61,6 +61,7 @@
61
61
  "styled-theming": "^2.2.0"
62
62
  },
63
63
  "peerDependencies": {
64
+ "ramda": "^0.27.0",
64
65
  "react": "^16.13.1",
65
66
  "react-dom": "^16.13.1",
66
67
  "react-router-dom": "6.0.0-alpha.3",
@@ -73,12 +74,12 @@
73
74
  }
74
75
  },
75
76
  "dependencies": {
76
- "ramda": "^0.27.0",
77
77
  "formatted-input": "^0.1.3",
78
78
  "framer-motion": "^1.11.0",
79
79
  "numeral": "^2.0.6",
80
80
  "react-aria-modal": "^4.0.0",
81
81
  "react-pose": "^4.0.10",
82
+ "react-router": "^5.2.0",
82
83
  "redux-freeform": "^4.1.3"
83
84
  }
84
85
  }
@@ -17,7 +17,6 @@ import CheckmarkIcon from "./CheckmarkIcon";
17
17
  import BankIcon from "./BankIcon";
18
18
  import GenericCard from "./GenericCard";
19
19
  import PaymentIcon from "./PaymentIcon";
20
- import IconAdd from "./IconAdd";
21
20
 
22
21
  export {
23
22
  AccountsIcon,
@@ -38,6 +37,5 @@ export {
38
37
  CheckmarkIcon,
39
38
  BankIcon,
40
39
  GenericCard,
41
- PaymentIcon,
42
- IconAdd
40
+ PaymentIcon
43
41
  };
@@ -1,4 +1,3 @@
1
- export { default as AddObligation } from "./add-obligation";
2
1
  export { default as Alert } from "./alert";
3
2
  export { default as AmountCallout } from "./amount-callout";
4
3
  export { default as Breadcrumb } from "./breadcrumb";
@@ -23,7 +23,7 @@ import { CoverOuterContainer } from "./Cover.styled";
23
23
  */
24
24
 
25
25
  const Cover = ({
26
- minHeight = "100vh",
26
+ minHeight = "100%",
27
27
  childGap,
28
28
  padding,
29
29
  fillCenter,
@@ -1,16 +1,15 @@
1
- import React from "react";
1
+ import React, { useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
2
3
  import { Link } from "react-router-dom";
3
4
  import Text from "../text";
4
- import { Box, Switcher, Center, Cluster, Cover } from "../layouts";
5
+ import { Box, Switcher, Center, Cluster } from "../layouts";
5
6
  import { fallbackValues } from "./Placeholder.theme";
6
7
  import { themeComponent } from "../../../util/themeUtils";
7
- import {
8
- STORM_GREY,
9
- GRECIAN_GREY,
10
- CHARADE_GREY
11
- } from "../../../constants/colors";
12
- import { AccountsAddIcon, PropertiesAddIcon, IconAdd } from "../icons";
8
+ import { IconAdd } from "../../../deprecated/icons";
9
+ import { STORM_GREY, GRECIAN_GREY } from "../../../constants/colors";
10
+ import { AccountsAddIcon, PropertiesAddIcon } from "../icons";
13
11
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
12
+ import withWindowSize from "../../withWindowSize";
14
13
 
15
14
  const PlaceholderContentWrapper = ({
16
15
  isLink,
@@ -41,26 +40,30 @@ const Placeholder = ({
41
40
  text,
42
41
  action,
43
42
  visible = true,
43
+ iconID,
44
44
  isLink = false,
45
45
  destination,
46
46
  variant,
47
47
  largeIcon,
48
48
  themeValues,
49
49
  dataQa
50
- }) => (
51
- <PlaceholderContentWrapper
52
- isLink={isLink}
53
- action={action}
54
- destination={destination}
55
- dataQa={dataQa}
56
- >
57
- <Box
58
- padding="0"
59
- borderRadius="4px"
60
- border="none"
61
- minHeight={themeValues.height}
62
- hiddenStyles={!visible}
63
- extraStyles={`
50
+ }) => {
51
+ const { isMobile } = useContext(ThemeContext);
52
+
53
+ return (
54
+ <PlaceholderContentWrapper
55
+ isLink={isLink}
56
+ action={action}
57
+ destination={destination}
58
+ dataQa={dataQa}
59
+ >
60
+ <Box
61
+ padding="0"
62
+ borderRadius="4px"
63
+ border="none"
64
+ minHeight={themeValues.height}
65
+ hiddenStyles={!visible}
66
+ extraStyles={`
64
67
  background: linear-gradient(
65
68
  to right,
66
69
  ${STORM_GREY} 40%,
@@ -75,65 +78,45 @@ const Placeholder = ({
75
78
  display: flex;
76
79
  justify-content: center;
77
80
  align-items:center;`}
78
- hoverStyles={`background-color: ${GRECIAN_GREY};`}
79
- >
80
- <Center maxWidth="300px">
81
- <Box padding="0px 0px 0px 0px">
82
- <Cluster justify="center" align="center" minHeight="100%">
83
- <Switcher maxChildren={2} childGap="0">
84
- {variant === "large" && <div></div>}
85
- <Box
86
- padding="0"
87
- extraStyles={`.fill {
88
- fill: ${CHARADE_GREY};
89
- } .stroke {
90
- stroke: ${CHARADE_GREY};
91
- }`}
92
- >
93
- {variant === "large" ? (
94
- <Center intrinsic>
95
- {largeIcon === "accounts" ? (
81
+ hoverStyles={`background-color: ${GRECIAN_GREY};`}
82
+ >
83
+ <Center maxWidth="300px">
84
+ <Box padding="0px 0px 0px 0px">
85
+ <Cluster justify="center" align="center" minHeight="100%">
86
+ <Switcher maxChildren={2} childGap="0">
87
+ {variant === "large" && <div></div>}
88
+ <Cluster justify="center" align="center" minHeight="100%">
89
+ {variant === "large" ? (
90
+ largeIcon === "accounts" ? (
96
91
  <AccountsAddIcon />
97
92
  ) : (
98
93
  <PropertiesAddIcon />
99
- )}
100
- <Text
101
- variant="pS"
102
- color={themeValues.color}
103
- weight={FONT_WEIGHT_REGULAR}
104
- extraStyles={`text-align: center;`}
105
- >
106
- {text}
107
- </Text>
108
- </Center>
109
- ) : (
110
- <Cover singleChild minHeight="100%">
111
- <Cluster justify="center" align="center">
112
- <IconAdd />
113
- <Center intrinsic>
114
- <Text
115
- variant="pS"
116
- color={themeValues.color}
117
- weight={FONT_WEIGHT_REGULAR}
118
- extraStyles={`padding: 0 0 0 8px; text-align: center;`}
119
- >
120
- {text}
121
- </Text>
122
- </Center>
123
- </Cluster>
124
- </Cover>
125
- )}
126
- </Box>
127
- </Switcher>
128
- </Cluster>
129
- </Box>
130
- </Center>
131
- </Box>
132
- </PlaceholderContentWrapper>
133
- );
134
-
94
+ )
95
+ ) : (
96
+ <IconAdd iconID={iconID} isMobile={isMobile} />
97
+ )}
98
+ </Cluster>
99
+ <Center intrinsic>
100
+ <Text
101
+ variant="pS"
102
+ color={themeValues.color}
103
+ weight={FONT_WEIGHT_REGULAR}
104
+ textAlign="center"
105
+ extraStyles={variant !== "large" && `padding: 0 0 0 8px;`}
106
+ >
107
+ {text}
108
+ </Text>
109
+ </Center>
110
+ </Switcher>
111
+ </Cluster>
112
+ </Box>
113
+ </Center>
114
+ </Box>
115
+ </PlaceholderContentWrapper>
116
+ );
117
+ };
135
118
  export default themeComponent(
136
- Placeholder,
119
+ withWindowSize(Placeholder),
137
120
  "Placeholder",
138
121
  fallbackValues,
139
122
  "default"
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect } from "react";
2
- import { required, isProbablyEmail } from "redux-freeform";
2
+ import { required, matchesField, isProbablyEmail } from "redux-freeform";
3
3
  import {
4
4
  FormInput,
5
5
  FormContainer,
@@ -22,6 +22,10 @@ const EmailForm = ({
22
22
  [required.error]: "Email is required",
23
23
  [isProbablyEmail.error]: "Invalid email address"
24
24
  };
25
+ const confirmEmailFieldErrorMessages = {
26
+ [matchesField.error]: "Confirm email must match email",
27
+ [required.error]: "Confirm email must match email"
28
+ };
25
29
 
26
30
  return (
27
31
  <FormContainer variant={variant} role="form" aria-label="Email">
@@ -35,6 +39,15 @@ const EmailForm = ({
35
39
  showErrors={showErrors}
36
40
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
37
41
  />
42
+ <FormInput
43
+ labelTextWhenNoError="Confirm email"
44
+ errorMessages={confirmEmailFieldErrorMessages}
45
+ type="email"
46
+ field={fields.confirmEmail}
47
+ fieldActions={actions.fields.confirmEmail}
48
+ showErrors={showErrors}
49
+ onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
50
+ />
38
51
  </FormInputColumn>
39
52
  </FormContainer>
40
53
  );
@@ -1,8 +1,16 @@
1
- import { createFormState, required, isProbablyEmail } from "redux-freeform";
1
+ import {
2
+ createFormState,
3
+ required,
4
+ matchesField,
5
+ isProbablyEmail
6
+ } from "redux-freeform";
2
7
 
3
8
  const formConfig = {
4
9
  email: {
5
10
  validators: [required(), isProbablyEmail()]
11
+ },
12
+ confirmEmail: {
13
+ validators: [required(), matchesField("email")]
6
14
  }
7
15
  };
8
16
 
@@ -20,11 +20,13 @@ const CenterSingle = ({
20
20
  const { isMobile } = themeContext;
21
21
 
22
22
  return (
23
- <Box padding="0" minWidth="100%" background={themeValues.pageBackground}>
24
- <Cover
25
- minHeight="100vh"
26
- centerOverride={isMobile && !centeredMobileContent}
27
- >
23
+ <Box
24
+ padding="0"
25
+ minWidth="100%"
26
+ background={themeValues.pageBackground}
27
+ extraStyles="flex-grow: 1;"
28
+ >
29
+ <Cover centerOverride={isMobile && !centeredMobileContent}>
28
30
  {header ? header : <Box padding="0" />}
29
31
  <Box
30
32
  padding="0"
@@ -20,8 +20,13 @@ const CenterStack = ({
20
20
  const { isMobile } = themeContext;
21
21
 
22
22
  return (
23
- <Box padding="0" minWidth="100%" background={themeValues.pageBackground}>
24
- <Cover minHeight="100vh">
23
+ <Box
24
+ padding="0"
25
+ minWidth="100%"
26
+ background={themeValues.pageBackground}
27
+ extraStyles="flex-grow: 1;"
28
+ >
29
+ <Cover>
25
30
  {header ? header : <Box padding="0" />}
26
31
  <Box padding="0" minWidth="100%" role="main">
27
32
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
@@ -19,8 +19,13 @@ const CenterSingle = ({
19
19
  const { isMobile } = themeContext;
20
20
 
21
21
  return (
22
- <Box padding="0" minWidth="100%" background={themeValues.pageBackground}>
23
- <Cover minHeight="100vh" childGap="0" fillCenter>
22
+ <Box
23
+ padding="0"
24
+ minWidth="100%"
25
+ background={themeValues.pageBackground}
26
+ extraStyles="flex-grow: 1;"
27
+ >
28
+ <Cover childGap="0" fillCenter>
24
29
  {header ? header : <Box padding="0" />}
25
30
  <Box
26
31
  padding="0"
@@ -25,8 +25,13 @@ const SidebarSingleContent = ({
25
25
  const { isMobile } = themeContext;
26
26
 
27
27
  return (
28
- <Box padding="0" minWidth="100%" background={themeValues.pageBackground}>
29
- <Cover minHeight="100vh" centerOverride={!sidebarVerticalCenter}>
28
+ <Box
29
+ padding="0"
30
+ minWidth="100%"
31
+ background={themeValues.pageBackground}
32
+ extraStyles="flex-grow: 1;"
33
+ >
34
+ <Cover centerOverride={!sidebarVerticalCenter}>
30
35
  {header ? header : <Box padding="0" />}
31
36
  <Box padding="0" minWidth="100%" role="main">
32
37
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
@@ -31,12 +31,9 @@ const SidebarStackContent = ({
31
31
  minWidth="100%"
32
32
  background={themeValues.pageBackground}
33
33
  key="page-bg"
34
+ extraStyles="flex-grow: 1;"
34
35
  >
35
- <Cover
36
- minHeight="100vh"
37
- centerOverride={!sidebarVerticalCenter}
38
- key="page-cover"
39
- >
36
+ <Cover centerOverride={!sidebarVerticalCenter} key="page-cover">
40
37
  {header ? header : <Box padding="0" key="header-box" />}
41
38
  <Box padding="0" minWidth="100%" key="content-box" role="main">
42
39
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { WHITE, CHARADE_GREY } from "../../constants/colors";
3
+
4
+ export const IconAdd = ({ fill = CHARADE_GREY, iconID, isMobile }) => (
5
+ <svg
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ xmlnsXlink="http://www.w3.org/1999/xlink"
8
+ width="18"
9
+ height="18"
10
+ viewBox={isMobile ? "0 -0.25 20 20" : "-0.5 -0.5 18 18"}
11
+ id={`icon-add-${iconID}`}
12
+ >
13
+ <defs>
14
+ <path
15
+ id="path-1"
16
+ d="M9.91666623 6.78508747L6.78508747 6.78508747 6.78508747 9.91666623 5.74122788 9.91666623 5.74122788 6.78508747 2.60964912 6.78508747 2.60964912 5.74122788 5.74122788 5.74122788 5.74122788 2.60964912 6.78508747 2.60964912 6.78508747 5.74122788 9.91666623 5.74122788z"
17
+ ></path>
18
+ </defs>
19
+ <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
20
+ <g transform="translate(-383 -15)">
21
+ <g transform="translate(384 16)">
22
+ <g>
23
+ <g transform="translate(1.94 1.858)">
24
+ <mask id="mask-2" fill={WHITE}>
25
+ <use xlinkHref="#path-1"></use>
26
+ </mask>
27
+ <use fill="#000" fillRule="evenodd" xlinkHref="#path-1"></use>
28
+ <g fill={fill} fillRule="evenodd" mask="url(#mask-2)">
29
+ <path d="M0 0H12.526V12.526H0z"></path>
30
+ </g>
31
+ </g>
32
+ <circle
33
+ cx="8.155"
34
+ cy="8.072"
35
+ r="8"
36
+ stroke={fill}
37
+ strokeWidth="0.644"
38
+ ></circle>
39
+ </g>
40
+ </g>
41
+ </g>
42
+ </g>
43
+ </svg>
44
+ );
@@ -1,3 +1,4 @@
1
+ import { IconAdd } from "./IconAdd";
1
2
  import { IconWarn } from "./IconWarn";
2
3
  import { IconCheck } from "./IconCheck";
3
4
  import { IconCheckEmail } from "./IconCheckEmail";
@@ -23,6 +24,7 @@ const AlertIcons = {
23
24
  };
24
25
 
25
26
  export {
27
+ IconAdd,
26
28
  IconWarn,
27
29
  IconCheck,
28
30
  IconCheckEmail,
package/src/util/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as formats from "./formats";
2
2
  import * as general from "./general";
3
+ import * as theme from "./themeUtils";
3
4
 
4
- export { formats, general };
5
+ export { formats, general, theme };
@@ -1,64 +0,0 @@
1
- import React from "react";
2
- import ButtonWithAction from "../button-with-action";
3
- import { Box, Center, Cluster, Cover } from "../layouts";
4
- import { IconAdd } from "../icons";
5
- import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
6
- import { fallbackValues } from "./AddObligation.theme";
7
- import { themeComponent } from "../../../util/themeUtils";
8
-
9
- const AddObligation = ({
10
- text,
11
- action,
12
- themeValues,
13
- extraStyles,
14
- textExtraStyles
15
- }) => {
16
- const hoverStyles = `
17
- &:hover {
18
- .fill { fill: ${themeValues.hoverColor}; }
19
- .stroke { stroke: ${themeValues.hoverColor}; }
20
- button { text-decoration: underline; text-decoration-color: ${themeValues.hoverColor}; }
21
- span { color: ${themeValues.hoverColor}; }
22
- }`;
23
-
24
- const activeStyles = `
25
- &:active {
26
- .fill { fill: ${themeValues.activeColor}; }
27
- .stroke { stroke: ${themeValues.activeColor}; }
28
- button { text-decoration: underline; text-decoration-color: ${themeValues.activeColor}; }
29
- span { color: ${themeValues.activeColor}; }
30
- }`;
31
-
32
- const defaultStyles = `
33
- min-height: 0;
34
- .fill { fill: ${themeValues.color}; }
35
- .stroke { stroke: ${themeValues.color}; }
36
- `;
37
- return (
38
- <Box
39
- className="button"
40
- padding="0.5rem 0"
41
- hoverStyles={hoverStyles}
42
- activeStyles={activeStyles}
43
- extraStyles={defaultStyles}
44
- onClick={action}
45
- >
46
- <Cover singleChild minHeight="100%">
47
- <Cluster justify="center" align="center" minHeight="100%">
48
- <IconAdd />
49
- <Center intrinsic>
50
- <ButtonWithAction
51
- action={action}
52
- text={text}
53
- variant="smallGhost"
54
- extraStyles={`min-height: 0; ${extraStyles}`}
55
- textExtraStyles={`padding: 0 0 0 0.75rem; font-size: 0.875rem; font-weight ${FONT_WEIGHT_SEMIBOLD}; ${textExtraStyles}`}
56
- />
57
- </Center>
58
- </Cluster>
59
- </Cover>
60
- </Box>
61
- );
62
- };
63
-
64
- export default themeComponent(AddObligation, "AddObligation", fallbackValues);
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import { text } from "@storybook/addon-knobs";
3
- import AddObligation from "./AddObligation";
4
- import page from "../../../../.storybook/page";
5
-
6
- export const addObligation = () => (
7
- <AddObligation
8
- text={text("text", "Lorem", "props")}
9
- extraStyles={text("extraStyles", "", "props")}
10
- textExtraStyles={text("textExtraStyles", "", "props")}
11
- />
12
- );
13
-
14
- const story = page({
15
- title: "Components|Atoms/AddObligation",
16
- Component: AddObligation
17
- });
18
- export default story;
@@ -1,9 +0,0 @@
1
- const color = "#15749D";
2
- const hoverColor = "#116285";
3
- const activeColor = "#0E506D";
4
-
5
- export const fallbackValues = {
6
- color,
7
- hoverColor,
8
- activeColor
9
- };
@@ -1,3 +0,0 @@
1
- import AddObligation from "./AddObligation";
2
-
3
- export default AddObligation;
@@ -1,36 +0,0 @@
1
- import React from "react";
2
-
3
- const IconAdd = () => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- xmlnsXlink="http://www.w3.org/1999/xlink"
7
- width="18"
8
- height="18"
9
- viewBox="0 0 18 18"
10
- className="icon"
11
- >
12
- <defs>
13
- <path
14
- id="path-1"
15
- d="M7.91666623 4.78508747L4.78508747 4.78508747 4.78508747 7.91666623 3.74122788 7.91666623 3.74122788 4.78508747 0.609649123 4.78508747 0.609649123 3.74122788 3.74122788 3.74122788 3.74122788 0.609649123 4.78508747 0.609649123 4.78508747 3.74122788 7.91666623 3.74122788z"
16
- ></path>
17
- </defs>
18
- <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
19
- <g transform="translate(-407 -563)">
20
- <g transform="translate(408 562)">
21
- <g transform="translate(0 2)">
22
- <g transform="translate(3.94 3.858)">
23
- <mask fill="#fff">
24
- <use xlinkHref="#path-1"></use>
25
- </mask>
26
- <use className="fill" xlinkHref="#path-1"></use>
27
- </g>
28
- <circle className="stroke" cx="8.155" cy="8.072" r="8"></circle>
29
- </g>
30
- </g>
31
- </g>
32
- </g>
33
- </svg>
34
- );
35
-
36
- export default IconAdd;