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

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.6",
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,80 @@ 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 =
34
+ (typeof children === "Array" ? children.length : 1) +
35
+ (text ? 1 : 0) +
36
+ (imgSrc ? 1 : 0) +
37
+ (headerText ? 1 : 0);
38
+
18
39
  return (
19
40
  <BoxWithShadow
20
41
  variant="baseStandard"
21
42
  background={themeValues.backgroundColor}
22
- borderRadius="4px"
43
+ borderRadius={borderRadius}
23
44
  padding="0"
24
45
  margin="0"
25
46
  minWidth={width}
26
47
  extraStyles={extraStyles}
27
- {...props}
28
48
  >
29
- <Cover>{children}</Cover>
49
+ <Cover singleChild>
50
+ <Stack fullHeight childGap="0" bottomItem={numberOfChildren}>
51
+ {headerText && (
52
+ <CardHeader
53
+ headerText={headerText}
54
+ headerColor={themeValues.headerColor}
55
+ headerVariant={headerVariant}
56
+ backgroundColor={themeValues.headerBackgroundColor}
57
+ borderRadius={borderRadius}
58
+ padding={padding}
59
+ ></CardHeader>
60
+ )}
61
+ {imgSrc && (
62
+ <CardImage
63
+ height={imgHeight}
64
+ objectFit={imgObjectFit}
65
+ backgroundColor={themeValues.imageBackgroundColor}
66
+ src={imgSrc}
67
+ />
68
+ )}
69
+ {text && (
70
+ <CardText
71
+ padding={padding}
72
+ titleText={titleText}
73
+ text={text}
74
+ titleVariant={titleVariant}
75
+ />
76
+ )}
77
+ {children}
78
+ </Stack>
79
+ </Cover>
30
80
  </BoxWithShadow>
31
81
  );
32
82
  };
@@ -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,45 @@
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 Box from "../layouts/Box";
9
+ import Cover from "../layouts/Cover";
10
+ import Paragraph from "../paragraph";
11
+ import Stack from "../layouts/Stack";
12
+ import Title from "../title";
13
+
14
+ export const CardText = ({
15
+ padding,
16
+ text,
17
+ titleText,
18
+ titleVariant = "small",
19
+ themeValues
20
+ }) => {
21
+ return (
22
+ <Box padding={padding}>
23
+ <Cover>
24
+ <Stack>
25
+ {titleText && (
26
+ <Title
27
+ variant={titleVariant}
28
+ color={themeValues.titleColor}
29
+ weight={themeValues?.titleWeight}
30
+ >
31
+ {titleText}
32
+ </Title>
33
+ )}
34
+ <Paragraph color={themeValues.textColor}>{text}</Paragraph>
35
+ </Stack>
36
+ </Cover>
37
+ </Box>
38
+ );
39
+ };
40
+
41
+ export default themeComponent(
42
+ withWindowSize(CardText),
43
+ "CardText",
44
+ fallbackValues
45
+ );
@@ -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>>;