@thecb/components 11.6.3 → 11.6.4-beta.0

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",
3
+ "version": "11.6.4-beta.0",
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, { useContext } from "react";
2
- import styled, { ThemeContext } from "styled-components";
1
+ import React from "react";
2
+ import styled 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,45 +15,31 @@ const StyledBadgeContainer = styled(Box)`
15
15
  `;
16
16
 
17
17
  const StyledBadge = styled(Text)`
18
- line-height: 150%;
19
- letter-spacing: ${props => (props.isMobile ? "0.2px" : "0.24px")};
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;
20
24
  white-space: nowrap;
21
- `;
22
25
 
23
- const Badge = ({
24
- label,
25
- Icon,
26
- themeValues,
27
- iconOnLeft = true,
28
- id,
29
- extraStyles
30
- }) => {
31
- const { isMobile } = useContext(ThemeContext);
26
+ @media screen and (min-width: 1049px) {
27
+ font-size: 12px;
28
+ line-height: 150%; /* 18px */
29
+ letter-spacing: 0.24px;
30
+ }
31
+ `;
32
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
- };
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
+ );
58
44
 
59
45
  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,
4
5
  ROYAL_BLUE_VIVID,
5
- ZEST_ORANGE,
6
- CORNFLOWER_BLUE
6
+ ZEST_ORANGE
7
7
  } from "../../../constants/colors";
8
8
  import Badge from "./Badge";
9
9
  import { Box, Stack, Cluster } from "../layouts";
@@ -80,30 +80,12 @@ const PrimaryBadge = props => {
80
80
  <Badge
81
81
  {...props}
82
82
  label={"Item in Cart"}
83
- Icon={() => MultiCartIcon({ iconFill: ROYAL_BLUE_VIVID })}
83
+ Icon={() => MultiCartIcon({ color: 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
- };
107
89
  const InfoBadge = props => {
108
90
  return (
109
91
  <Badge
@@ -151,9 +133,6 @@ export const Badges = {
151
133
  <SuccessBadge {...args} />
152
134
  <DisabledBadge {...args} />
153
135
  <PrimaryBadge {...args} />
154
- <PrimaryHeadlineBadge {...args} />
155
- <SecondaryBadge {...args} />
156
- <SecondaryHeadlineBadge {...args} />
157
136
  <WarnBadge {...args} />
158
137
  </Cluster>
159
138
  <Cluster justify="flex-start" align="center" childGap="1.5rem">
@@ -10,20 +10,11 @@ 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";
19
13
 
20
14
  const background = {
21
15
  info: `${INFO_BLUE}`,
22
16
  warn: `${HALF_COLONIAL_WHITE}`,
23
17
  primary: `${CORNFLOWER_BLUE}`,
24
- primaryHeadline: `${CORNFLOWER_BLUE}`,
25
- secondary: `${ROYAL_BLUE_VIVID}`,
26
- secondaryHeadline: `${ROYAL_BLUE_VIVID}`,
27
18
  success: `${HINT_GREEN}`,
28
19
  disabled: `${GRECIAN_GREY}`
29
20
  };
@@ -32,50 +23,11 @@ const color = {
32
23
  info: `${MATISSE_BLUE}`,
33
24
  warn: `${ZEST_ORANGE}`,
34
25
  primary: `${ROYAL_BLUE_VIVID}`,
35
- primaryHeadline: `${ROYAL_BLUE_VIVID}`,
36
- secondary: `${CORNFLOWER_BLUE}`,
37
- secondaryHeadline: `${CORNFLOWER_BLUE}`,
38
26
  success: `${SEA_GREEN}`,
39
27
  disabled: `${MANATEE_GREY}`
40
28
  };
41
29
 
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
-
75
30
  export const fallbackValues = {
76
31
  background,
77
- color,
78
- fontWeight,
79
- fontSizeMobile,
80
- fontSizeDesktop
32
+ color
81
33
  };
@@ -5,17 +5,6 @@ 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;
19
8
  }
20
9
 
21
10
  export const Badge: React.FC<Expand<BadgeProps> & HTMLAttributes<HTMLElement>>;
@@ -135,7 +135,8 @@ const Dropdown = ({
135
135
  autocompleteValue, // browser autofill value, like country-name
136
136
  smoothScroll = true,
137
137
  ariaInvalid = false,
138
- isRequired = false
138
+ isRequired = false,
139
+ extraStyles
139
140
  }) => {
140
141
  const [inputValue, setInputValue] = useState("");
141
142
  const [optionsState, setOptionsState] = useState([]);
@@ -316,7 +317,7 @@ const Dropdown = ({
316
317
  <Box
317
318
  padding="0"
318
319
  background={isOpen ? themeValues.hoverColor : WHITE}
319
- extraStyles={`position: relative;`}
320
+ extraStyles={`position: relative;${extraStyles ? ` ${extraStyles}` : ""}`}
320
321
  minWidth="100%"
321
322
  onClick={() => {
322
323
  if (!isOpen) {
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+ import { FormSelectOption } from "../../../types/common";
4
+
5
+ export interface DropdownThemeValues {
6
+ selectedColor?: string;
7
+ hoverColor?: string;
8
+ focusColor?: string;
9
+ }
10
+
11
+ export interface DropdownProps {
12
+ /** Placeholder text displayed when no value is selected */
13
+ placeholder?: string;
14
+ /** Array of options to display in the dropdown */
15
+ options: FormSelectOption[];
16
+ /** Currently selected value */
17
+ value?: string;
18
+ /** Whether the dropdown is currently open */
19
+ isOpen?: boolean;
20
+ /** Whether the dropdown is in an error state */
21
+ isError?: boolean;
22
+ /** Callback fired when an option is selected */
23
+ onSelect: (value: string) => void;
24
+ /** Array of values that should be disabled */
25
+ disabledValues?: string[];
26
+ /** Callback fired when the dropdown is clicked */
27
+ onClick?: () => void;
28
+ /** Theme values for styling the dropdown */
29
+ themeValues?: DropdownThemeValues;
30
+ /** Maximum height of the dropdown content */
31
+ maxHeight?: string;
32
+ /** Whether the dropdown width should fit its content */
33
+ widthFitOptions?: boolean;
34
+ /** Whether the dropdown is disabled */
35
+ disabled?: boolean;
36
+ /** Whether to show title attributes on options */
37
+ hasTitles?: boolean;
38
+ /** Whether to auto-erase type-ahead input after timeout */
39
+ autoEraseTypeAhead?: boolean;
40
+ /** ID of the element that labels this dropdown */
41
+ ariaLabelledby?: string;
42
+ /** ID of the element that describes this dropdown */
43
+ ariaDescribedby?: string;
44
+ /** Autocomplete attribute value for browser autofill */
45
+ autocompleteValue?: string;
46
+ /** Whether to use smooth scrolling when scrolling to selected item */
47
+ smoothScroll?: boolean;
48
+ /** Whether the dropdown has an invalid value */
49
+ ariaInvalid?: boolean;
50
+ /** Whether the dropdown is required */
51
+ isRequired?: boolean;
52
+ /** Custom CSS styles */
53
+ extraStyles?: string;
54
+ }
55
+
56
+ export const Dropdown: React.FC<Expand<DropdownProps> &
57
+ React.HTMLAttributes<HTMLElement>>;
58
+
59
+ export default Dropdown;
@@ -1,8 +1,8 @@
1
1
  export * from "./alert";
2
- export * from "./badge";
3
2
  export * from "./button-with-action";
4
3
  export * from "./button-with-link";
5
4
  export * from "./card";
5
+ export * from "./dropdown";
6
6
  export * from "./sortable-table-heading";
7
7
  export * from "./form-layouts";
8
8
  export * from "./form-select";
@@ -8,7 +8,7 @@ export interface CollapsibleSectionProps {
8
8
  ) => void;
9
9
  isMobile?: boolean;
10
10
  supportsTouch?: boolean;
11
- title?: string | JSX.Element;
11
+ title?: string;
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
- Omit<React.HTMLAttributes<HTMLElement>, "title">>; // ommitting title prop to avoid conflicts with component's title prop
26
+ React.HTMLAttributes<HTMLElement>>;
@@ -5,7 +5,6 @@ export const BORDER_RADIUS = {
5
5
  };
6
6
  export const BORDER_THIN = "1px";
7
7
  export const FONT_SIZE = {
8
- XXS: "0.625rem", // 10px
9
8
  XS: "0.750rem", // 12px
10
9
  SM: "0.875rem", // 14px
11
10
  MD: "1.000rem", // 16px