@thecb/components 6.3.1-beta.3 → 6.3.1-beta.4

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": "6.3.1-beta.3",
3
+ "version": "6.3.1-beta.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -3,30 +3,77 @@ import React, { Fragment } from "react";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import withWindowSize from "../../withWindowSize";
5
5
 
6
- import { Cover } from "../layouts";
7
- import BoxWithShadow from "../box-with-shadow";
8
6
  import { fallbackValues } from "./Card.theme";
9
7
 
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
+
10
17
  const Card = ({
11
18
  themeValues,
12
- variant,
13
19
  children,
14
20
  extraStyles,
15
21
  width = "276px",
16
- ...props
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"
17
32
  }) => {
33
+ const numberOfChildren = children.length + (imgSrc ? 1 : 0) + (text ? 1 : 0);
34
+
18
35
  return (
19
36
  <BoxWithShadow
20
37
  variant="baseStandard"
21
38
  background={themeValues.backgroundColor}
22
- borderRadius="4px"
39
+ borderRadius={borderRadius}
23
40
  padding="0"
24
41
  margin="0"
25
42
  minWidth={width}
26
43
  extraStyles={extraStyles}
27
- {...props}
28
44
  >
29
- <Cover>{children}</Cover>
45
+ <Cover singleChild>
46
+ <Stack fullHeight childGap="0" bottomItem={numberOfChildren}>
47
+ {headerText && (
48
+ <CardHeader
49
+ headerText={headerText}
50
+ headerColor={themeValues.headerColor}
51
+ headerVariant={headerVariant}
52
+ backgroundColor={themeValues.headerBackgroundColor}
53
+ borderRadius={borderRadius}
54
+ padding={padding}
55
+ ></CardHeader>
56
+ )}
57
+ {imgSrc && (
58
+ <CardImage
59
+ height={imgHeight}
60
+ objectFit={imgObjectFit}
61
+ backgroundColor={themeValues.imageBackgroundColor}
62
+ src={imgSrc}
63
+ />
64
+ )}
65
+ <Box padding={padding}>
66
+ {text && (
67
+ <CardText
68
+ titleText={titleText}
69
+ text={text}
70
+ titleVariant={titleVariant}
71
+ />
72
+ )}
73
+ {children}
74
+ </Box>
75
+ </Stack>
76
+ </Cover>
30
77
  </BoxWithShadow>
31
78
  );
32
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
+ );
@@ -0,0 +1,12 @@
1
+ import { BRIGHT_GREY } from "../../../constants/colors";
2
+
3
+ import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
4
+ const titleColor = BRIGHT_GREY;
5
+ const titleWeight = FONT_WEIGHT_BOLD;
6
+ const textColor = BRIGHT_GREY;
7
+
8
+ export const fallbackValues = {
9
+ titleColor,
10
+ titleWeight,
11
+ titleWeight
12
+ };
@@ -2,9 +2,28 @@ import React from "react";
2
2
  import Expand from "../../../util/expand";
3
3
 
4
4
  export interface CardProps {
5
- variant?: string;
6
- width?: string;
5
+ text?: string;
6
+ titleText?: string;
7
+ titleVariant?: string;
7
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;
8
27
  }
9
28
 
10
29
  export const Card: React.FC<Expand<CardProps> &
@@ -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,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>>;