@thecb/components 6.3.1-beta.2 → 6.3.1-beta.5

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.
Files changed (28) hide show
  1. package/README.md +39 -0
  2. package/dist/index.cjs.js +587 -414
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +51 -24
  5. package/dist/index.esm.js +585 -411
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/atoms/card/Card.js +60 -21
  9. package/src/components/atoms/card/Card.theme.js +9 -2
  10. package/src/components/atoms/card/CardHeader.js +27 -0
  11. package/src/components/atoms/card/CardImage.styled.js +9 -0
  12. package/src/components/atoms/card/CardText.js +41 -0
  13. package/src/components/{molecules/welcome-card/WelcomeCard.theme.js → atoms/card/CardText.theme.js} +3 -6
  14. package/src/components/atoms/card/index.d.ts +21 -1
  15. package/src/components/atoms/display-card/DisplayCard.js +1 -1
  16. package/src/components/atoms/index.d.ts +1 -0
  17. package/src/components/atoms/layouts/Switcher.d.ts +17 -0
  18. package/src/components/atoms/layouts/index.d.ts +1 -0
  19. package/src/components/atoms/text/index.d.ts +16 -0
  20. package/src/components/molecules/index.d.ts +0 -2
  21. package/src/components/molecules/index.js +0 -2
  22. package/src/components/molecules/card-with-header/CardWithHeader.js +0 -34
  23. package/src/components/molecules/card-with-header/CardWithHeader.theme.js +0 -9
  24. package/src/components/molecules/card-with-header/index.d.ts +0 -11
  25. package/src/components/molecules/card-with-header/index.js +0 -2
  26. package/src/components/molecules/welcome-card/WelcomeCard.js +0 -64
  27. package/src/components/molecules/welcome-card/index.d.ts +0 -15
  28. package/src/components/molecules/welcome-card/index.js +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.3.1-beta.2",
3
+ "version": "6.3.1-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -3,38 +3,77 @@ import React, { Fragment } from "react";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import withWindowSize from "../../withWindowSize";
5
5
 
6
- import { Box, Stack, Cover } from "../layouts";
7
- import BoxWithShadow from "../box-with-shadow";
8
6
  import { fallbackValues } from "./Card.theme";
9
7
 
10
- const CardVariantSwitcher = ({ variant, children }) => {
11
- return variant === "vertical" ? (
12
- <Fragment>{children}</Fragment>
13
- ) : (
14
- <Box padding="0" extraStyles={`width: 100%`}>
15
- <Stack childGap="0" maxWidth="100%" fullHeight>
16
- {children}
17
- </Stack>
18
- </Box>
19
- );
20
- };
8
+ import Box from "../layouts/Box";
9
+ import BoxWithShadow from "../box-with-shadow";
10
+ import Cover from "../layouts/Cover";
11
+ import Stack from "../layouts/Stack";
12
+
13
+ import CardImage from "./CardImage.styled";
14
+ import CardText from "./CardText";
15
+ import CardHeader from "./CardHeader";
16
+
17
+ const Card = ({
18
+ themeValues,
19
+ children,
20
+ extraStyles,
21
+ width = "276px",
22
+ text,
23
+ titleText,
24
+ titleVariant = "small",
25
+ imgSrc,
26
+ imgHeight = "150px",
27
+ imgObjectFit = "none",
28
+ headerText,
29
+ headerVariant = "small",
30
+ borderRadius = "4px",
31
+ padding = "24px"
32
+ }) => {
33
+ const numberOfChildren =
34
+ children.length + (imgSrc ? 1 : 0) + (text ? 1 : 0) + (headerText ? 1 : 0);
21
35
 
22
- const Card = ({ themeValues, variant, children, extraStyles, ...props }) => {
23
36
  return (
24
37
  <BoxWithShadow
25
38
  variant="baseStandard"
26
39
  background={themeValues.backgroundColor}
27
- borderRadius="4px"
40
+ borderRadius={borderRadius}
28
41
  padding="0"
29
42
  margin="0"
30
- maxWidth={variant !== "vertical" ? "100%" : "276px"}
31
- minHeight="100%"
32
- minWidth={variant !== "vertical" && "276px"}
43
+ minWidth={width}
33
44
  extraStyles={extraStyles}
34
- {...props}
35
45
  >
36
- <Cover singleChild fillCenter>
37
- <CardVariantSwitcher variant={variant}>{children}</CardVariantSwitcher>
46
+ <Cover singleChild>
47
+ <Stack fullHeight childGap="0" bottomItem={numberOfChildren}>
48
+ {headerText && (
49
+ <CardHeader
50
+ headerText={headerText}
51
+ headerColor={themeValues.headerColor}
52
+ headerVariant={headerVariant}
53
+ backgroundColor={themeValues.headerBackgroundColor}
54
+ borderRadius={borderRadius}
55
+ padding={padding}
56
+ ></CardHeader>
57
+ )}
58
+ {imgSrc && (
59
+ <CardImage
60
+ height={imgHeight}
61
+ objectFit={imgObjectFit}
62
+ backgroundColor={themeValues.imageBackgroundColor}
63
+ src={imgSrc}
64
+ />
65
+ )}
66
+ <Box padding={padding}>
67
+ {text && (
68
+ <CardText
69
+ titleText={titleText}
70
+ text={text}
71
+ titleVariant={titleVariant}
72
+ />
73
+ )}
74
+ {children}
75
+ </Box>
76
+ </Stack>
38
77
  </Cover>
39
78
  </BoxWithShadow>
40
79
  );
@@ -1,7 +1,14 @@
1
- import { WHITE } from "../../../constants/colors";
1
+ import { INFO_BLUE, STORM_GREY, WHITE } from "../../../constants/colors";
2
2
 
3
3
  const backgroundColor = WHITE;
4
+ const imageBackgroundColor = INFO_BLUE;
5
+
6
+ const headerBackgroundColor = STORM_GREY;
7
+ const headerColor = WHITE;
4
8
 
5
9
  export const fallbackValues = {
6
- backgroundColor
10
+ backgroundColor,
11
+ imageBackgroundColor,
12
+ headerBackgroundColor,
13
+ headerColor
7
14
  };
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+
3
+ import Box from "../layouts/Box";
4
+ import Title from "../title";
5
+
6
+ export const CardHeader = ({
7
+ headerText,
8
+ headerColor,
9
+ headerVariant,
10
+ backgroundColor,
11
+ padding,
12
+ borderRadius
13
+ }) => {
14
+ return (
15
+ <Box
16
+ padding={padding}
17
+ background={backgroundColor}
18
+ borderRadius={`${borderRadius} ${borderRadius} 0 0`}
19
+ >
20
+ <Title variant={headerVariant} color={headerColor}>
21
+ {headerText}
22
+ </Title>
23
+ </Box>
24
+ );
25
+ };
26
+
27
+ export default CardHeader;
@@ -0,0 +1,9 @@
1
+ import styled from "styled-components";
2
+
3
+ const CardImage = styled.img`
4
+ background: ${({ backgroundColor }) => backgroundColor};
5
+ object-fit: ${({ objectFit }) => objectFit};
6
+ height: ${({ height }) => height};
7
+ `;
8
+
9
+ export default CardImage;
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+ import withWindowSize from "../../withWindowSize";
5
+
6
+ import { fallbackValues } from "./CardText.theme";
7
+
8
+ import Cover from "../layouts/Cover";
9
+ import Paragraph from "../paragraph";
10
+ import Stack from "../layouts/Stack";
11
+ import Title from "../title";
12
+
13
+ export const CardText = ({
14
+ text,
15
+ titleText,
16
+ titleVariant = "small",
17
+ themeValues
18
+ }) => {
19
+ return (
20
+ <Cover>
21
+ <Stack>
22
+ {titleText && (
23
+ <Title
24
+ variant={titleVariant}
25
+ color={themeValues.titleColor}
26
+ weight={themeValues?.titleWeight}
27
+ >
28
+ {titleText}
29
+ </Title>
30
+ )}
31
+ <Paragraph color={themeValues.textColor}>{text}</Paragraph>
32
+ </Stack>
33
+ </Cover>
34
+ );
35
+ };
36
+
37
+ export default themeComponent(
38
+ withWindowSize(CardText),
39
+ "CardText",
40
+ fallbackValues
41
+ );
@@ -1,15 +1,12 @@
1
- import { BRIGHT_GREY, INFO_BLUE } from "../../../constants/colors";
1
+ import { BRIGHT_GREY } from "../../../constants/colors";
2
2
 
3
3
  import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
4
-
5
4
  const titleColor = BRIGHT_GREY;
6
- const textColor = BRIGHT_GREY;
7
5
  const titleWeight = FONT_WEIGHT_BOLD;
8
- const imageBackgroundColor = INFO_BLUE;
6
+ const textColor = BRIGHT_GREY;
9
7
 
10
8
  export const fallbackValues = {
11
- textColor,
12
9
  titleColor,
13
10
  titleWeight,
14
- imageBackgroundColor
11
+ titleWeight
15
12
  };
@@ -2,8 +2,28 @@ import React from "react";
2
2
  import Expand from "../../../util/expand";
3
3
 
4
4
  export interface CardProps {
5
- variant?: string;
5
+ text?: string;
6
+ titleText?: string;
7
+ titleVariant?: string;
6
8
  extraStyles?: string;
9
+ imgSrc?: string;
10
+ imgHeight?: string;
11
+ imgObjectFit?:
12
+ | "contain"
13
+ | "cover"
14
+ | "fill"
15
+ | "none"
16
+ | "scale-down"
17
+ | "inherit"
18
+ | "initial"
19
+ | "revert"
20
+ | "revert-layer"
21
+ | "unset";
22
+ headerText?: string;
23
+ headerVariant?: string;
24
+ borderRadius?: string;
25
+ width?: string;
26
+ padding?: string;
7
27
  }
8
28
 
9
29
  export const Card: React.FC<Expand<CardProps> &
@@ -7,7 +7,7 @@ import Cluster from "../layouts/Cluster";
7
7
  import ButtonWithAction from "../button-with-action";
8
8
  import ButtonWithLink from "../button-with-link";
9
9
  import { WHITE, CHARADE_GREY, STORM_GREY } from "../../../constants/colors";
10
- import { Popover } from "../../molecules";
10
+ import Popover from "../../molecules/popover";
11
11
 
12
12
  const DisplayCard = ({
13
13
  title,
@@ -7,4 +7,5 @@ export * from "./nav-footer";
7
7
  export * from "./nav-header";
8
8
  export * from "./nav-tabs";
9
9
  export * from "./paragraph";
10
+ export * from "./text";
10
11
  export * from "./title";
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface SwitcherProps {
5
+ breakpoint?: string;
6
+ childGap?: string;
7
+ largeChild?: string;
8
+ largeChildSize?: string;
9
+ maxChildren?: string;
10
+ maxChildrenOnly?: boolean;
11
+ padding?: string;
12
+ extraStyles?: string;
13
+ constrainMobile?: boolean;
14
+ }
15
+
16
+ export const Switcher: React.FC<Expand<SwitcherProps> &
17
+ React.HTMLAttributes<HTMLElement>>;
@@ -3,3 +3,4 @@ export * from "./Center";
3
3
  export * from "./Cluster";
4
4
  export * from "./Cover";
5
5
  export * from "./Stack";
6
+ export * from "./Switcher";
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface TextProps {
5
+ weight?: string;
6
+ color?: string;
7
+ textWrap?: boolean;
8
+ extraStyles?: string;
9
+ hoverStyles?: string;
10
+ as?: string;
11
+ dataQa?: string;
12
+ variant?: string;
13
+ }
14
+
15
+ export const Text: React.FC<Expand<TextProps> &
16
+ React.HTMLAttributes<HTMLElement>>;
@@ -1,3 +1 @@
1
- export * from "./card-with-header";
2
1
  export * from "./footer-with-subfooter";
3
- export * from "./welcome-card";
@@ -1,5 +1,4 @@
1
1
  export { default as AddressForm } from "./address-form";
2
- export { default as CardWithHeader } from "./card-with-header";
3
2
  export { default as ChangePasswordForm } from "./change-password-form";
4
3
  export { default as CollapsibleSection } from "./collapsible-section";
5
4
  export { default as EditNameForm } from "./edit-name-form";
@@ -35,6 +34,5 @@ export { default as TabSidebar } from "./tab-sidebar";
35
34
  export { default as TermsAndConditions } from "./terms-and-conditions";
36
35
  export { default as TermsAndConditionsModal } from "./terms-and-conditions-modal";
37
36
  export { default as Timeout } from "./timeout";
38
- export { default as WelcomeCard } from "./welcome-card";
39
37
  export { default as WelcomeModule } from "./welcome-module";
40
38
  export { default as WorkflowTile } from "./workflow-tile";
@@ -1,34 +0,0 @@
1
- import React from "react";
2
-
3
- import { fallbackValues } from "./CardWithHeader.theme";
4
- import { themeComponent } from "../../../util/themeUtils";
5
-
6
- import { Box, Card, Title } from "../../atoms";
7
-
8
- const CardWithHeader = ({
9
- themeValues,
10
- children,
11
- header,
12
- extraStyles,
13
- variant,
14
- ...props
15
- }) => {
16
- return (
17
- <Card extraStyles={extraStyles} {...props}>
18
- <Box
19
- padding="24px"
20
- background={themeValues.headerBackgroundColor}
21
- extraStyles={`
22
- border-radius: 4px 4px 0 0;
23
- `}
24
- >
25
- <Title variant="small" color={themeValues.headerTextColor}>
26
- {header}
27
- </Title>
28
- </Box>
29
- <Box padding="24px">{children}</Box>
30
- </Card>
31
- );
32
- };
33
-
34
- export default themeComponent(CardWithHeader, "CardWithHeader", fallbackValues);
@@ -1,9 +0,0 @@
1
- import { STORM_GREY, WHITE } from "../../../constants/colors";
2
-
3
- const headerBackgroundColor = STORM_GREY;
4
- const headerTextColor = WHITE;
5
-
6
- export const fallbackValues = {
7
- headerBackgroundColor,
8
- headerTextColor
9
- };
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- import Expand from "../../../util/expand";
3
-
4
- export interface CardWithHeaderProps {
5
- header: string;
6
- extraStyles?: string;
7
- variant?: string;
8
- }
9
-
10
- export const CardWithHeader: React.FC<Expand<CardWithHeaderProps> &
11
- React.HTMLAttributes<HTMLElement>>;
@@ -1,2 +0,0 @@
1
- import CardWithHeader from "./CardWithHeader";
2
- export default CardWithHeader;
@@ -1,64 +0,0 @@
1
- import React from "react";
2
-
3
- import { fallbackValues } from "./WelcomeCard.theme";
4
- import { themeComponent } from "../../../util/themeUtils";
5
-
6
- import {
7
- Box,
8
- ButtonWithLink,
9
- Card,
10
- Cover,
11
- Paragraph,
12
- Title
13
- } from "../../atoms";
14
-
15
- const WelcomeCard = ({
16
- themeValues,
17
- title,
18
- text,
19
- buttonText,
20
- url,
21
- imageSrc,
22
- newTab,
23
- variant
24
- }) => {
25
- return (
26
- <Card variant={variant}>
27
- {imageSrc && (
28
- <Cover>
29
- <img
30
- src={imageSrc}
31
- style={{
32
- background: `${themeValues.imageBackgroundColor}`,
33
- objectFit: "none",
34
- height: "150px"
35
- }}
36
- />
37
- </Cover>
38
- )}
39
- <Box padding="24px">
40
- <Title
41
- variant="small"
42
- color={themeValues.titleColor}
43
- weight={themeValues.titleWeight}
44
- >
45
- {title}
46
- </Title>
47
- <Paragraph color={themeValues.textColor}>{text}</Paragraph>
48
- {url && buttonText && (
49
- <Box extraStyles="margin-top: 4rem; padding: 0">
50
- <ButtonWithLink
51
- extraStyles="margin: 0; width: 100%"
52
- linkExtraStyles="text-decoration:none"
53
- url={url}
54
- text={buttonText}
55
- newTab={newTab}
56
- />
57
- </Box>
58
- )}
59
- </Box>
60
- </Card>
61
- );
62
- };
63
-
64
- export default themeComponent(WelcomeCard, "WelcomeCard", fallbackValues);
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import Expand from "../../../util/expand";
3
-
4
- export interface WelcomeCardProps {
5
- title: string;
6
- text: string;
7
- url?: string;
8
- buttonText?: string;
9
- imageSrc?: string;
10
- newTab?: boolean;
11
- variant?: string;
12
- }
13
-
14
- export const WelcomeCard: React.FC<Expand<WelcomeCardProps> &
15
- React.HTMLAttributes<HTMLElement>>;
@@ -1,3 +0,0 @@
1
- import WelcomeCard from "./WelcomeCard";
2
-
3
- export default WelcomeCard;