@thecb/components 11.6.3-beta.0 → 11.6.3-beta.2

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.3-beta.0",
3
+ "version": "11.6.3-beta.2",
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");
@@ -86,6 +86,10 @@ const PrimaryBadge = props => {
86
86
  );
87
87
  };
88
88
 
89
+ const PrimaryHeadlineBadge = props => {
90
+ return <Badge {...props} label={"Kiosk"} variant="primaryHeadline" />;
91
+ };
92
+
89
93
  const SecondaryBadge = props => {
90
94
  return (
91
95
  <Badge
@@ -97,6 +101,9 @@ const SecondaryBadge = props => {
97
101
  );
98
102
  };
99
103
 
104
+ const SecondaryHeadlineBadge = props => {
105
+ return <Badge {...props} label={"Online"} variant="secondaryHeadline" />;
106
+ };
100
107
  const InfoBadge = props => {
101
108
  return (
102
109
  <Badge
@@ -144,7 +151,9 @@ export const Badges = {
144
151
  <SuccessBadge {...args} />
145
152
  <DisabledBadge {...args} />
146
153
  <PrimaryBadge {...args} />
154
+ <PrimaryHeadlineBadge {...args} />
147
155
  <SecondaryBadge {...args} />
156
+ <SecondaryHeadlineBadge {...args} />
148
157
  <WarnBadge {...args} />
149
158
  </Cluster>
150
159
  <Cluster justify="flex-start" align="center" childGap="1.5rem">
@@ -10,12 +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}`,
18
25
  secondary: `${ROYAL_BLUE_VIVID}`,
26
+ secondaryHeadline: `${ROYAL_BLUE_VIVID}`,
19
27
  success: `${HINT_GREEN}`,
20
28
  disabled: `${GRECIAN_GREY}`
21
29
  };
@@ -24,12 +32,50 @@ const color = {
24
32
  info: `${MATISSE_BLUE}`,
25
33
  warn: `${ZEST_ORANGE}`,
26
34
  primary: `${ROYAL_BLUE_VIVID}`,
35
+ primaryHeadline: `${ROYAL_BLUE_VIVID}`,
27
36
  secondary: `${CORNFLOWER_BLUE}`,
37
+ secondaryHeadline: `${CORNFLOWER_BLUE}`,
28
38
  success: `${SEA_GREEN}`,
29
39
  disabled: `${MANATEE_GREY}`
30
40
  };
31
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
+
32
75
  export const fallbackValues = {
33
76
  background,
34
- color
77
+ color,
78
+ fontWeight,
79
+ fontSizeMobile,
80
+ fontSizeDesktop
35
81
  };
@@ -5,6 +5,7 @@ export interface BadgeProps {
5
5
  label: string;
6
6
  Icon?: JSX.Element;
7
7
  iconOnLeft?: boolean;
8
+ variant?: "info" | "warn" | "primary" | "primaryHeadline" | "secondary" | "secondaryHeadline" | "success" | "disabled";
8
9
  }
9
10
 
10
11
  export const Badge: React.FC<Expand<BadgeProps> & HTMLAttributes<HTMLElement>>;
@@ -22,5 +22,5 @@ export interface CollapsibleSectionProps {
22
22
  extraStyles?: string;
23
23
  }
24
24
 
25
- export const CollapsibleSection: React.FC<Expand<CollapsibleSectionProps> &
26
- React.HTMLAttributes<HTMLElement>>;
25
+ export const CollapsibleSection: React.FC<Expand<CollapsibleSectionProps> &
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