@thecb/components 4.4.3 → 4.5.0-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": "4.4.3",
3
+ "version": "4.5.0-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+ import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
3
+ import { FIREFLY_GREY } from "../../../constants/colors";
4
+ import { DetailText } from "./Detail.styled";
5
+ import { safeChildren } from "../../../util/general";
6
+ import {
7
+ fallbackValues,
8
+ mobileFallbackValues,
9
+ MOBILE_BREAKPOINT
10
+ } from "./Detail.theme";
11
+ import { themeComponent } from "../../../util/themeUtils";
12
+
13
+ /*
14
+ New responsive text component for Detail elements
15
+ (Block level text elements which are smaller than "Title" elements)
16
+ Size is decoupled from tag
17
+ Comes with two variants - "large" and "small"
18
+ Large variant results in text that is 1.5rem (24px desktop, 21px mobile)
19
+ Small variant results in text that is 1.25rem/1.2142rem (20px desktop, 17px mobile)
20
+
21
+ If you need a smaller larger size, use the <Title /> atom, which has larger variants
22
+
23
+ Use the "as" prop to specify element type, can use any of: h1/h2/h3/h4/h5/h6/p
24
+ If you need an inline text element (span), use the <Text /> atom
25
+ The "as" value should be dictated by the structure of your page, not what font-size you want
26
+
27
+ Title / Detail both use slightly different desktop/mobile scales
28
+ (Mobile scale is different to allow for design-friendly px values)
29
+ Both atoms detect the presence of a mobile device on their own
30
+ and apply the corresponding scale
31
+
32
+ Mobile breakpoint value is specified in Detail.theme.js
33
+
34
+ If you want to disable mobile text scales (use the same rem scale for desktop/mobile), then use a theme in FCS to set all of the variants to use the same rem sizes. FCS themes override fallbacks defined in the .theme file
35
+ */
36
+
37
+ const isBelowBreakpoint = window.innerWidth < MOBILE_BREAKPOINT;
38
+ const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 1;
39
+ const mobileDeviceDetected = isBelowBreakpoint && isTouchDevice;
40
+ const fallbacks = mobileDeviceDetected ? mobileFallbackValues : fallbackValues;
41
+
42
+ const Detail = ({
43
+ themeValues,
44
+ weight = FONT_WEIGHT_REGULAR,
45
+ color = FIREFLY_GREY,
46
+ margin = 0,
47
+ textAlign,
48
+ extraStyles = ``,
49
+ className,
50
+ variant = "regular",
51
+ as = "p",
52
+ dataQa,
53
+ children,
54
+ ...rest
55
+ }) => {
56
+ return (
57
+ <DetailText
58
+ variant={variant}
59
+ as={as}
60
+ weight={weight}
61
+ color={color}
62
+ margin={margin}
63
+ textAlign={textAlign}
64
+ extraStyles={extraStyles}
65
+ className={className}
66
+ fontFamily={themeValues.fontFamily}
67
+ fontSize={themeValues.fontSize}
68
+ data-qa={dataQa}
69
+ {...rest}
70
+ >
71
+ {safeChildren(children, <span />)}
72
+ </DetailText>
73
+ );
74
+ };
75
+
76
+ export default themeComponent(Detail, "Detail", fallbacks, "regular");
@@ -0,0 +1,13 @@
1
+ import styled from "styled-components";
2
+
3
+ export const DetailText = styled.p`
4
+ font-size: ${({ fontSize }) => fontSize};
5
+ line-height: 1.5;
6
+ color: ${({ color }) => color};
7
+ font-weight: ${({ weight }) => weight};
8
+ margin: ${({ margin }) => margin};
9
+ text-align: ${({ textAlign }) => textAlign};
10
+ font-family: ${({ fontFamily }) => fontFamily};
11
+
12
+ ${({ extraStyles }) => extraStyles};
13
+ `;
@@ -0,0 +1,32 @@
1
+ const fontSize = {
2
+ large: "1.125rem",
3
+ regular: "1rem",
4
+ small: "0.875rem",
5
+ extraSmall: "0.75rem"
6
+ };
7
+
8
+ const fontFamily = {
9
+ large: "Public Sans",
10
+ regular: "Public Sans",
11
+ small: "Public Sans",
12
+ extraSmall: "Public Sans"
13
+ };
14
+
15
+ const mobileFontSize = {
16
+ large: "1.14285rem",
17
+ regular: "1",
18
+ small: "0.85714rem",
19
+ extraSmall: "0.71428rem"
20
+ };
21
+
22
+ export const fallbackValues = {
23
+ fontFamily,
24
+ fontSize
25
+ };
26
+
27
+ export const mobileFallbackValues = {
28
+ fontFamily,
29
+ fontSize: mobileFontSize
30
+ };
31
+
32
+ export const MOBILE_BREAKPOINT = 768;
@@ -0,0 +1,3 @@
1
+ import Detail from "./Detail";
2
+
3
+ export default Detail;
@@ -1,3 +1,9 @@
1
+ /*
2
+ SOON TO BE DEPRECATED AS OF 8/1/2021
3
+
4
+ For new pages/applications, please us <Title /> and <Detail /> atoms
5
+
6
+ */
1
7
  import React from "react";
2
8
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
3
9
  import { FIREFLY_GREY } from "../../../constants/colors";
@@ -51,7 +51,6 @@ import NoPaymentResultsIcon from "./NoPaymentResultsIcon";
51
51
  import CustomerSearchIcon from "./CustomerSearchIcon";
52
52
  import PaymentSearchIcon from "./PaymentSearchIcon";
53
53
  import ResetPasswordIcon from "./ResetPasswordIcon";
54
- import PeriscopeFailedIcon from "./PeriscopeFailedIcon";
55
54
 
56
55
  export {
57
56
  AccountsIcon,
@@ -106,6 +105,5 @@ export {
106
105
  NoPaymentResultsIcon,
107
106
  CustomerSearchIcon,
108
107
  PaymentSearchIcon,
109
- ResetPasswordIcon,
110
- PeriscopeFailedIcon
108
+ ResetPasswordIcon
111
109
  };
@@ -9,6 +9,7 @@ export { default as cardRegistry } from "./card";
9
9
  export { default as Checkbox } from "./checkbox";
10
10
  export { default as CheckboxList } from "./checkbox-list";
11
11
  export { default as CountryDropdown } from "./country-dropdown";
12
+ export { default as Detail } from "./detail";
12
13
  export { default as DisplayBox } from "./display-box";
13
14
  export { default as DisplayCard } from "./display-card";
14
15
  export { default as Dropdown } from "./dropdown";
@@ -37,5 +38,6 @@ export { default as SolidDivider } from "./solid-divider";
37
38
  export { default as Spinner } from "./spinner";
38
39
  export { default as StateProvinceDropdown } from "./state-province-dropdown";
39
40
  export { default as Text } from "./text";
41
+ export { default as Title } from "./title";
40
42
  export { default as ToggleSwitch } from "./toggle-switch";
41
43
  export { default as TypeaheadInput } from "./typeahead-input";
@@ -5,14 +5,7 @@ import { Stack } from "../layouts";
5
5
  import Heading from "../heading";
6
6
  import Paragraph from "../paragraph";
7
7
 
8
- const LabeledAmount = ({
9
- variant = "pL",
10
- label,
11
- amount,
12
- themeValues,
13
- as,
14
- extraStyles
15
- }) => {
8
+ const LabeledAmount = ({ variant = "pL", label, amount, themeValues, as }) => {
16
9
  const LabeledAmountText = variant === "h6" ? Heading : Paragraph;
17
10
  return (
18
11
  <Stack direction="row">
@@ -20,7 +13,7 @@ const LabeledAmount = ({
20
13
  variant={variant}
21
14
  as={as}
22
15
  weight={themeValues.fontWeight}
23
- extraStyles={`${extraStyles}; text-align: start; flex: 3;`}
16
+ extraStyles="text-align: start; flex: 3;"
24
17
  >
25
18
  {label}:
26
19
  </LabeledAmountText>
@@ -28,7 +21,7 @@ const LabeledAmount = ({
28
21
  variant={variant}
29
22
  as={as}
30
23
  weight={themeValues.fontWeight}
31
- extraStyles={`${extraStyles}; text-align: end; flex: 1;`}
24
+ extraStyles="text-align: end; flex: 1;"
32
25
  >
33
26
  {amount}
34
27
  </LabeledAmountText>
@@ -1,6 +1,5 @@
1
1
  const fontWeight = {
2
2
  default: "600",
3
- pS: "600",
4
3
  p: "600",
5
4
  pL: "600",
6
5
  h6: "700"
@@ -1,5 +1,5 @@
1
1
  const weightTitle = { default: "600", small: "400" };
2
- const paragraphVariant = { default: "pL", small: "pS" };
2
+ const paragraphVariant = { default: "pL", small: "p" };
3
3
 
4
4
  export const fallbackValues = {
5
5
  weightTitle,
@@ -1,3 +1,9 @@
1
+ /*
2
+ SOON TO BE DEPRECATED AS OF 8/1/2021
3
+
4
+ For new pages/applications, please us <Title /> and <Detail /> atoms
5
+
6
+ */
1
7
  import React from "react";
2
8
  import { fallbackValues } from "./Paragraph.theme";
3
9
  import { themeComponent } from "../../../util/themeUtils";
@@ -0,0 +1,75 @@
1
+ import React from "react";
2
+ import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
3
+ import { FIREFLY_GREY } from "../../../constants/colors";
4
+ import { TitleText } from "./Title.styled";
5
+ import { safeChildren } from "../../../util/general";
6
+ import {
7
+ fallbackValues,
8
+ mobileFallbackValues,
9
+ MOBILE_BREAKPOINT
10
+ } from "./Title.theme";
11
+ import { themeComponent } from "../../../util/themeUtils";
12
+
13
+ /*
14
+ New responsive text component for Title elements
15
+ Size is decoupled from tag
16
+ Comes with two variants - "large" and "small"
17
+ Large variant results in text that is 1.5rem (24px desktop, 21px mobile)
18
+ Small variant results in text that is 1.25rem/1.2142rem (20px desktop, 17px mobile)
19
+
20
+ If you need a smaller text size, use the <Detail /> atom, which has smaller variants
21
+
22
+ Use the "as" prop to specify element type, can use any of: h1/h2/h3/h4/h5/h6/p
23
+ If you need an inline text element (span), use the <Text /> atom
24
+ The "as" value should be dictated by the structure of your page, not what font-size you want
25
+
26
+ Title / Detail both use slightly different desktop/mobile scales
27
+ (Mobile scale is different to allow for design-friendly px values)
28
+ Both atoms detect the presence of a mobile device on their own
29
+ and apply the corresponding scale
30
+
31
+ Mobile breakpoint value is specified in Title.theme.js
32
+
33
+ If you want to disable mobile text scales (use the same rem scale for desktop/mobile), then use a theme in FCS to set both the "large" and "small" variants to use the same rem sizes. FCS themes override fallbacks defined in the .theme file
34
+ */
35
+
36
+ const isBelowBreakpoint = window.innerWidth < MOBILE_BREAKPOINT;
37
+ const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 1;
38
+ const mobileDeviceDetected = isBelowBreakpoint && isTouchDevice;
39
+ const fallbacks = mobileDeviceDetected ? mobileFallbackValues : fallbackValues;
40
+
41
+ const Title = ({
42
+ themeValues,
43
+ weight = FONT_WEIGHT_REGULAR,
44
+ color = FIREFLY_GREY,
45
+ margin = 0,
46
+ textAlign,
47
+ extraStyles = ``,
48
+ className,
49
+ variant = "large",
50
+ as = "h1",
51
+ dataQa,
52
+ children,
53
+ ...rest
54
+ }) => {
55
+ return (
56
+ <TitleText
57
+ variant={variant}
58
+ as={as}
59
+ weight={weight}
60
+ color={color}
61
+ margin={margin}
62
+ textAlign={textAlign}
63
+ extraStyles={extraStyles}
64
+ className={className}
65
+ fontFamily={themeValues.fontFamily}
66
+ fontSize={themeValues.fontSize}
67
+ data-qa={dataQa}
68
+ {...rest}
69
+ >
70
+ {safeChildren(children, <span />)}
71
+ </TitleText>
72
+ );
73
+ };
74
+
75
+ export default themeComponent(Title, "Title", fallbacks, "large");
@@ -0,0 +1,13 @@
1
+ import styled from "styled-components";
2
+
3
+ export const TitleText = styled.h1`
4
+ font-size: ${({ fontSize }) => fontSize};
5
+ line-height: 1.5;
6
+ color: ${({ color }) => color};
7
+ font-weight: ${({ weight }) => weight};
8
+ margin: ${({ margin }) => margin};
9
+ text-align: ${({ textAlign }) => textAlign};
10
+ font-family: ${({ fontFamily }) => fontFamily};
11
+
12
+ ${({ extraStyles }) => extraStyles};
13
+ `;
@@ -0,0 +1,26 @@
1
+ const fontSize = {
2
+ large: "1.5rem",
3
+ small: "1.25rem"
4
+ };
5
+
6
+ const fontFamily = {
7
+ large: "Public Sans",
8
+ small: "Public Sans"
9
+ };
10
+
11
+ const mobileFontSize = {
12
+ large: "1.5rem",
13
+ small: "1.2142rem"
14
+ };
15
+
16
+ export const fallbackValues = {
17
+ fontFamily,
18
+ fontSize
19
+ };
20
+
21
+ export const mobileFallbackValues = {
22
+ fontFamily,
23
+ fontSize: mobileFontSize
24
+ };
25
+
26
+ export const MOBILE_BREAKPOINT = 768;
@@ -0,0 +1,3 @@
1
+ import Title from "./Title";
2
+
3
+ export default Title;
@@ -16,9 +16,7 @@ const Module = ({
16
16
  <Fragment>
17
17
  {heading && (
18
18
  <Heading
19
- variant={
20
- variant === "small" ? "h6" : variant === "default" ? "h5" : "h2"
21
- }
19
+ variant={variant === "default" ? "h5" : "h2"}
22
20
  weight={themeValues.fontWeight}
23
21
  color={themeValues.fontColor}
24
22
  margin={`${spacing} 0 ${themeValues.titleSpacing} 0`}
@@ -1,38 +1,20 @@
1
1
  import { WHITE, CHARADE_GREY } from "../../../constants/colors";
2
2
 
3
- const fontSize = {
4
- default: "1.375rem",
5
- largeTitle: "1.75rem",
6
- small: "1.25rem"
7
- };
8
- const fontWeight = { default: "600", largeTitle: "700", small: "600" };
9
- const fontColor = {
10
- default: CHARADE_GREY,
11
- largeTitle: CHARADE_GREY,
12
- small: CHARADE_GREY
13
- };
14
- const lineHeight = { default: "2rem", largeTitle: "2rem", small: "2rem" };
15
- const textAlign = { default: "left", largeTitle: "left", small: "left" };
16
- const titleType = { default: "h5", largeTitle: "h1", small: "h6" };
17
- const titleSpacing = {
18
- default: "0.5rem",
19
- largeTitle: "1.125rem",
20
- small: "0.5rem"
21
- };
3
+ const fontSize = { default: "1.375rem", largeTitle: "1.75rem" };
4
+ const fontWeight = { default: "600", largeTitle: "700" };
5
+ const fontColor = { default: CHARADE_GREY, largeTitle: CHARADE_GREY };
6
+ const lineHeight = { default: "2rem", largeTitle: "2rem" };
7
+ const textAlign = { default: "left", largeTitle: "left" };
8
+ const titleType = { default: "h5", largeTitle: "h1" };
9
+ const titleSpacing = { default: "0.5rem", largeTitle: "1.125rem" };
22
10
  const boxShadow = {
23
11
  default:
24
12
  "0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)",
25
13
  largeTitle:
26
- "0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)",
27
- small:
28
14
  "0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
29
15
  };
30
- const borderRadius = {
31
- default: "0.25rem",
32
- largeTitle: "0.25rem",
33
- small: "0.25rem"
34
- };
35
- const backgroundColor = { default: WHITE, largeTitle: WHITE, small: WHITE };
16
+ const borderRadius = { default: "0.25rem", largeTitle: "0.25rem" };
17
+ const backgroundColor = { default: WHITE, largeTitle: WHITE };
36
18
 
37
19
  export const fallbackValues = {
38
20
  fontSize,
@@ -10,14 +10,12 @@ import LabeledAmount from "../../atoms/labeled-amount";
10
10
  import LineItem from "../../atoms/line-item";
11
11
  import Heading from "../../atoms/heading";
12
12
  import SolidDivider from "../../atoms/solid-divider";
13
- import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
14
13
 
15
14
  const PaymentDetailsContent = ({
16
15
  lineItemElems,
17
16
  feeElems,
18
17
  subtotal,
19
18
  total,
20
- variant,
21
19
  themeValues
22
20
  }) => (
23
21
  <Stack childGap="16px">
@@ -37,7 +35,6 @@ const PaymentDetailsContent = ({
37
35
  variant={themeValues.labeledAmountTotal}
38
36
  label="Total"
39
37
  amount={displayCurrency(total)}
40
- extraStyles={variant === "small" && `font-weight: ${FONT_WEIGHT_BOLD};`}
41
38
  />
42
39
  </Stack>
43
40
  );
@@ -77,7 +74,6 @@ const PaymentDetails = ({
77
74
  fees: _fees,
78
75
  subtotal,
79
76
  total,
80
- variant = "default",
81
77
  hideTitle = false,
82
78
  titleText = "Payment Details",
83
79
  initiallyOpen = false,
@@ -117,12 +113,12 @@ const PaymentDetails = ({
117
113
  <SolidDivider />
118
114
  <Box padding="8px" />
119
115
  <PaymentDetailsContent
120
- {...{ lineItemElems, feeElems, subtotal, total, themeValues, variant }}
116
+ {...{ lineItemElems, feeElems, subtotal, total, themeValues }}
121
117
  />
122
118
  </Stack>
123
119
  ) : (
124
120
  <PaymentDetailsContent
125
- {...{ lineItemElems, feeElems, subtotal, total, themeValues, variant }}
121
+ {...{ lineItemElems, feeElems, subtotal, total, themeValues }}
126
122
  />
127
123
  );
128
124
  const title = hideTitle ? (
@@ -1,7 +1,7 @@
1
1
  const backgroundColor = { default: "transparent", small: "transparent" };
2
2
  const lineItem = { default: "default", small: "small" };
3
- const labeledAmountSubtotal = { default: "pL", small: "pS" };
4
- const labeledAmountTotal = { default: "h6", small: "p" };
3
+ const labeledAmountSubtotal = { default: "pL", small: "p" };
4
+ const labeledAmountTotal = { default: "h6", small: "pL" };
5
5
 
6
6
  export const fallbackValues = {
7
7
  backgroundColor,