@thecb/components 11.6.4-beta.0 → 11.6.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": "11.6.4-beta.0",
3
+ "version": "11.6.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import styled from "styled-components";
1
+ import React, { useContext } from "react";
2
+ import styled, { ThemeContext } from "styled-components";
3
3
  import Box from "../layouts/Box";
4
4
  import Text from "../../atoms/text/";
5
5
  import { themeComponent } from "../../../util/themeUtils";
@@ -15,31 +15,45 @@ const StyledBadgeContainer = styled(Box)`
15
15
  `;
16
16
 
17
17
  const StyledBadge = styled(Text)`
18
- font-family: "Public Sans", sans-serif;
19
- font-size: 10px;
20
- font-style: normal;
21
- font-weight: 400;
22
- line-height: 150%; /* 15px */
23
- letter-spacing: 0.2px;
18
+ line-height: 150%;
19
+ letter-spacing: ${props => (props.isMobile ? "0.2px" : "0.24px")};
24
20
  white-space: nowrap;
25
-
26
- @media screen and (min-width: 1049px) {
27
- font-size: 12px;
28
- line-height: 150%; /* 18px */
29
- letter-spacing: 0.24px;
30
- }
31
21
  `;
32
22
 
33
- const Badge = ({ label, Icon, themeValues, iconOnLeft = true, id }) => (
34
- <StyledBadgeContainer background={themeValues.background} id={id}>
35
- {iconOnLeft && Icon && (
36
- <Icon color={themeValues.color} fill={themeValues.color} />
37
- )}
38
- <StyledBadge color={themeValues.color}>{label}</StyledBadge>
39
- {!iconOnLeft && Icon && (
40
- <Icon color={themeValues.color} fill={themeValues.color} />
41
- )}
42
- </StyledBadgeContainer>
43
- );
23
+ const Badge = ({
24
+ label,
25
+ Icon,
26
+ themeValues,
27
+ iconOnLeft = true,
28
+ id,
29
+ extraStyles
30
+ }) => {
31
+ const { isMobile } = useContext(ThemeContext);
32
+
33
+ return (
34
+ <StyledBadgeContainer
35
+ background={themeValues.background}
36
+ id={id}
37
+ extraStyles={extraStyles}
38
+ >
39
+ {iconOnLeft && Icon && (
40
+ <Icon color={themeValues.color} fill={themeValues.color} />
41
+ )}
42
+ <StyledBadge
43
+ color={themeValues.color}
44
+ weight={themeValues.fontWeight}
45
+ fontSize={
46
+ isMobile ? themeValues.fontSizeMobile : themeValues.fontSizeDesktop
47
+ }
48
+ isMobile={isMobile}
49
+ >
50
+ {label}
51
+ </StyledBadge>
52
+ {!iconOnLeft && Icon && (
53
+ <Icon color={themeValues.color} fill={themeValues.color} />
54
+ )}
55
+ </StyledBadgeContainer>
56
+ );
57
+ };
44
58
 
45
59
  export default themeComponent(Badge, "Badge", fallbackValues, "success");
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import {
3
3
  MANATEE_GREY,
4
- MATISSE_BLUE,
5
4
  ROYAL_BLUE_VIVID,
6
- ZEST_ORANGE
5
+ ZEST_ORANGE,
6
+ CORNFLOWER_BLUE
7
7
  } from "../../../constants/colors";
8
8
  import Badge from "./Badge";
9
9
  import { Box, Stack, Cluster } from "../layouts";
@@ -80,12 +80,30 @@ const PrimaryBadge = props => {
80
80
  <Badge
81
81
  {...props}
82
82
  label={"Item in Cart"}
83
- Icon={() => MultiCartIcon({ color: ROYAL_BLUE_VIVID })}
83
+ Icon={() => MultiCartIcon({ iconFill: ROYAL_BLUE_VIVID })}
84
84
  variant="primary"
85
85
  />
86
86
  );
87
87
  };
88
88
 
89
+ const PrimaryHeadlineBadge = props => {
90
+ return <Badge {...props} label={"Kiosk"} variant="primaryHeadline" />;
91
+ };
92
+
93
+ const SecondaryBadge = props => {
94
+ return (
95
+ <Badge
96
+ {...props}
97
+ label={"Item in Cart"}
98
+ Icon={() => MultiCartIcon({ iconFill: CORNFLOWER_BLUE })}
99
+ variant="secondary"
100
+ />
101
+ );
102
+ };
103
+
104
+ const SecondaryHeadlineBadge = props => {
105
+ return <Badge {...props} label={"Online"} variant="secondaryHeadline" />;
106
+ };
89
107
  const InfoBadge = props => {
90
108
  return (
91
109
  <Badge
@@ -133,6 +151,9 @@ export const Badges = {
133
151
  <SuccessBadge {...args} />
134
152
  <DisabledBadge {...args} />
135
153
  <PrimaryBadge {...args} />
154
+ <PrimaryHeadlineBadge {...args} />
155
+ <SecondaryBadge {...args} />
156
+ <SecondaryHeadlineBadge {...args} />
136
157
  <WarnBadge {...args} />
137
158
  </Cluster>
138
159
  <Cluster justify="flex-start" align="center" childGap="1.5rem">
@@ -10,11 +10,20 @@ import {
10
10
  SEA_GREEN,
11
11
  ZEST_ORANGE
12
12
  } from "../../../constants/colors";
13
+ import {
14
+ FONT_SIZE,
15
+ FONT_WEIGHT_REGULAR,
16
+ FONT_WEIGHT_SEMIBOLD
17
+ } from "../../../constants/style_constants";
18
+ import { fallbackValues as textTheme } from "../text/Text.theme";
13
19
 
14
20
  const background = {
15
21
  info: `${INFO_BLUE}`,
16
22
  warn: `${HALF_COLONIAL_WHITE}`,
17
23
  primary: `${CORNFLOWER_BLUE}`,
24
+ primaryHeadline: `${CORNFLOWER_BLUE}`,
25
+ secondary: `${ROYAL_BLUE_VIVID}`,
26
+ secondaryHeadline: `${ROYAL_BLUE_VIVID}`,
18
27
  success: `${HINT_GREEN}`,
19
28
  disabled: `${GRECIAN_GREY}`
20
29
  };
@@ -23,11 +32,50 @@ const color = {
23
32
  info: `${MATISSE_BLUE}`,
24
33
  warn: `${ZEST_ORANGE}`,
25
34
  primary: `${ROYAL_BLUE_VIVID}`,
35
+ primaryHeadline: `${ROYAL_BLUE_VIVID}`,
36
+ secondary: `${CORNFLOWER_BLUE}`,
37
+ secondaryHeadline: `${CORNFLOWER_BLUE}`,
26
38
  success: `${SEA_GREEN}`,
27
39
  disabled: `${MANATEE_GREY}`
28
40
  };
29
41
 
42
+ const fontWeight = {
43
+ info: FONT_WEIGHT_REGULAR,
44
+ warn: FONT_WEIGHT_REGULAR,
45
+ primary: FONT_WEIGHT_REGULAR,
46
+ primaryHeadline: FONT_WEIGHT_SEMIBOLD,
47
+ secondary: FONT_WEIGHT_REGULAR,
48
+ secondaryHeadline: FONT_WEIGHT_SEMIBOLD,
49
+ success: FONT_WEIGHT_REGULAR,
50
+ disabled: FONT_WEIGHT_REGULAR
51
+ };
52
+
53
+ const fontSizeMobile = {
54
+ info: textTheme.fontSize.pXXS,
55
+ warn: textTheme.fontSize.pXXS,
56
+ primary: textTheme.fontSize.pXXS,
57
+ primaryHeadline: textTheme.fontSize.pXS,
58
+ secondary: textTheme.fontSize.pXXS,
59
+ secondaryHeadline: textTheme.fontSize.pXS,
60
+ success: textTheme.fontSize.pXXS,
61
+ disabled: textTheme.fontSize.pXXS
62
+ };
63
+
64
+ const fontSizeDesktop = {
65
+ info: textTheme.fontSize.pXS,
66
+ warn: textTheme.fontSize.pXS,
67
+ primary: textTheme.fontSize.pXS,
68
+ primaryHeadline: textTheme.fontSize.pS,
69
+ secondary: textTheme.fontSize.pXS,
70
+ secondaryHeadline: textTheme.fontSize.pS,
71
+ success: textTheme.fontSize.pXS,
72
+ disabled: textTheme.fontSize.pXS
73
+ };
74
+
30
75
  export const fallbackValues = {
31
76
  background,
32
- color
77
+ color,
78
+ fontWeight,
79
+ fontSizeMobile,
80
+ fontSizeDesktop
33
81
  };
@@ -5,6 +5,17 @@ export interface BadgeProps {
5
5
  label: string;
6
6
  Icon?: JSX.Element;
7
7
  iconOnLeft?: boolean;
8
+ variant?:
9
+ | "info"
10
+ | "warn"
11
+ | "primary"
12
+ | "primaryHeadline"
13
+ | "secondary"
14
+ | "secondaryHeadline"
15
+ | "success"
16
+ | "disabled";
17
+ id?: string;
18
+ extraStyles?: string;
8
19
  }
9
20
 
10
21
  export const Badge: React.FC<Expand<BadgeProps> & HTMLAttributes<HTMLElement>>;
@@ -54,6 +54,6 @@ export interface DropdownProps {
54
54
  }
55
55
 
56
56
  export const Dropdown: React.FC<Expand<DropdownProps> &
57
- React.HTMLAttributes<HTMLElement>>;
57
+ Omit<React.HTMLAttributes<HTMLElement>, "onSelect">>;
58
58
 
59
59
  export default Dropdown;
@@ -1,4 +1,5 @@
1
1
  export * from "./alert";
2
+ export * from "./badge";
2
3
  export * from "./button-with-action";
3
4
  export * from "./button-with-link";
4
5
  export * from "./card";
@@ -8,7 +8,7 @@ export interface CollapsibleSectionProps {
8
8
  ) => void;
9
9
  isMobile?: boolean;
10
10
  supportsTouch?: boolean;
11
- title?: string;
11
+ title?: string | JSX.Element;
12
12
  customPadding?: string;
13
13
  initiallyOpen?: boolean;
14
14
  openHeight?: string;
@@ -23,4 +23,4 @@ export interface CollapsibleSectionProps {
23
23
  }
24
24
 
25
25
  export const CollapsibleSection: React.FC<Expand<CollapsibleSectionProps> &
26
- React.HTMLAttributes<HTMLElement>>;
26
+ Omit<React.HTMLAttributes<HTMLElement>, "title">>; // ommitting title prop to avoid conflicts with component's title prop
@@ -5,6 +5,7 @@ export const BORDER_RADIUS = {
5
5
  };
6
6
  export const BORDER_THIN = "1px";
7
7
  export const FONT_SIZE = {
8
+ XXS: "0.625rem", // 10px
8
9
  XS: "0.750rem", // 12px
9
10
  SM: "0.875rem", // 14px
10
11
  MD: "1.000rem", // 16px