@thecb/components 10.11.2-beta.2 → 10.12.0-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": "10.11.2-beta.2",
3
+ "version": "10.12.0-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",
Binary file
@@ -14,6 +14,7 @@ import Stack from "../layouts/Stack";
14
14
  import CardImage from "./CardImage.styled";
15
15
  import CardText from "./CardText";
16
16
  import CardHeader from "./CardHeader";
17
+ import { noop } from "../../../util/general";
17
18
 
18
19
  const Card = ({
19
20
  borderRadius = "4px",
@@ -26,8 +27,12 @@ const Card = ({
26
27
  imgHeight = "150px",
27
28
  imgObjectFit = "none",
28
29
  imgAltText,
30
+ onQuitClick = noop,
29
31
  padding = "24px",
32
+ showQuitLink = false,
30
33
  text,
34
+ textAs = "p",
35
+ titleAs = "h2",
31
36
  titleText,
32
37
  titleVariant = "small",
33
38
  themeValues,
@@ -90,9 +95,13 @@ const Card = ({
90
95
  <Box padding="0" width="100%" extraStyles="flex-basis: 100%;">
91
96
  {text && (
92
97
  <CardText
98
+ onQuitClick={onQuitClick}
93
99
  padding={padding}
100
+ showQuitLink={showQuitLink}
101
+ titleAs={titleAs}
94
102
  titleText={titleText}
95
103
  text={text}
104
+ textAs={textAs}
96
105
  titleVariant={titleVariant}
97
106
  />
98
107
  )}
@@ -10,10 +10,16 @@ import Cover from "../layouts/Cover";
10
10
  import Paragraph from "../paragraph";
11
11
  import Stack from "../layouts/Stack";
12
12
  import Title from "../title";
13
+ import IconQuitLarge from "../../atoms/icons/IconQuitLarge";
14
+ import { Cluster } from "../layouts";
13
15
 
14
16
  export const CardText = ({
17
+ showQuitLink,
18
+ onQuitClick,
19
+ titleAs,
15
20
  padding,
16
21
  text,
22
+ textAs = "p",
17
23
  titleText,
18
24
  titleVariant = "small",
19
25
  themeValues
@@ -22,17 +28,34 @@ export const CardText = ({
22
28
  <Box padding={padding}>
23
29
  <Cover>
24
30
  <Stack>
25
- {titleText && (
26
- <Title
27
- as="p"
28
- variant={titleVariant}
29
- color={themeValues.titleColor}
30
- weight={themeValues.titleWeight}
31
- >
32
- {titleText}
33
- </Title>
34
- )}
35
- <Paragraph color={themeValues.textColor}>{text}</Paragraph>
31
+ <Cluster justify="space-between" align="center" overflow={true}>
32
+ {titleText && (
33
+ <Title
34
+ as={titleAs}
35
+ variant={titleVariant}
36
+ color={themeValues.titleColor}
37
+ weight={themeValues.titleWeight}
38
+ >
39
+ {titleText}
40
+ </Title>
41
+ )}
42
+ {showQuitLink && (
43
+ <Box
44
+ padding="0"
45
+ onClick={onQuitClick}
46
+ onKeyDown={e => e.key === "Enter" && onQuitClick()}
47
+ role="button"
48
+ tabIndex={0}
49
+ aria-label={`Close Card: ${titleText}`}
50
+ extraStyles="cursor: pointer;"
51
+ >
52
+ <IconQuitLarge />
53
+ </Box>
54
+ )}
55
+ </Cluster>
56
+ <Paragraph as={textAs} color={themeValues.textColor}>
57
+ {text}
58
+ </Paragraph>
36
59
  </Stack>
37
60
  </Cover>
38
61
  </Box>
@@ -3,7 +3,9 @@ import Expand from "../../../util/expand";
3
3
 
4
4
  export interface CardProps {
5
5
  text?: string;
6
+ textAs?: string;
6
7
  titleText?: string;
8
+ titleAs?: string;
7
9
  titleVariant?: string;
8
10
  extraStyles?: string;
9
11
  imgSrc?: string;
@@ -27,6 +29,10 @@ export interface CardProps {
27
29
  borderRadius?: string;
28
30
  width?: string;
29
31
  padding?: string;
32
+ showQuitLink?: boolean;
33
+ onQuitClick?: (
34
+ event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>
35
+ ) => void;
30
36
  }
31
37
 
32
38
  export const Card: React.FC<Expand<CardProps> &
@@ -119,8 +119,6 @@ const FormInput = ({
119
119
  isRequired = false,
120
120
  errorFieldExtraStyles,
121
121
  showFieldErrorRow = true,
122
- labelTextVariant = "pS",
123
- errorTextVariant = "pXS",
124
122
  ...props
125
123
  }) => {
126
124
  const [showPassword, setShowPassword] = useState(false);
@@ -150,7 +148,7 @@ const FormInput = ({
150
148
  <Text
151
149
  as="label"
152
150
  color={themeValues.labelColor}
153
- variant={labelTextVariant}
151
+ variant="pS"
154
152
  weight={themeValues.fontWeight}
155
153
  extraStyles={`word-break: break-word;
156
154
  font-family: Public Sans;
@@ -169,7 +167,7 @@ const FormInput = ({
169
167
  <Text
170
168
  as="label"
171
169
  color={themeValues.labelColor}
172
- variant={labelTextVariant}
170
+ variant="pS"
173
171
  fontWeight={themeValues.fontWeight}
174
172
  extraStyles={`word-break: break-word;
175
173
  font-family: Public Sans;
@@ -182,7 +180,7 @@ const FormInput = ({
182
180
  </Text>
183
181
  {type === "password" && (
184
182
  <Text
185
- variant={labelTextVariant}
183
+ variant="pS"
186
184
  color={themeValues.linkColor}
187
185
  weight={themeValues.fontWeight}
188
186
  hoverStyles={themeValues.hoverFocusStyles}
@@ -284,7 +282,7 @@ const FormInput = ({
284
282
  (field.hasErrors && showErrors) ? (
285
283
  <Text
286
284
  color={ERROR_COLOR}
287
- variant={errorTextVariant}
285
+ variant="pXS"
288
286
  weight={themeValues.fontWeight}
289
287
  extraStyles={`word-break: break-word;
290
288
  font-family: Public Sans;
@@ -26,11 +26,6 @@ export interface FormInputProps {
26
26
  autocompleteValue?: string;
27
27
  removeFromValue?: RegExp;
28
28
  dataQa?: string | null;
29
- isRequired?: boolean;
30
- errorFieldExtraStyles?: string;
31
- showFieldErrorRow?: boolean;
32
- labelTextVariant?: string;
33
- errorTextVariant?: string;
34
29
  }
35
30
 
36
31
  export const FormInput: React.FC<Expand<FormInputProps> &
@@ -25,9 +25,7 @@ const FormSelect = ({
25
25
  smoothScroll = true, // whether the browser should animate scroll to selected item on first open
26
26
  dataQa = null,
27
27
  widthFitOptions = false,
28
- isRequired = false,
29
- labelTextVariant = "pS",
30
- errorLabelTextVariant = "pXS"
28
+ isRequired = false
31
29
  }) => {
32
30
  const [open, setOpen] = useState(false);
33
31
  const dropdownRef = useRef(null);
@@ -56,7 +54,7 @@ const FormSelect = ({
56
54
  <Cluster justify="space-between" align="center">
57
55
  <Text
58
56
  as="label"
59
- variant={labelTextVariant}
57
+ variant="pS"
60
58
  color={themeValues.labelColor}
61
59
  weight={themeValues.fontWeight}
62
60
  extraStyles={`word-break: break-word;
@@ -103,7 +101,7 @@ const FormSelect = ({
103
101
  {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
104
102
  <Text
105
103
  color={ERROR_COLOR}
106
- variant={errorLabelTextVariant}
104
+ variant="pXS"
107
105
  weight={themeValues.fontWeight}
108
106
  extraStyles={`
109
107
  word-break: break-word;
@@ -24,9 +24,6 @@ export interface FormSelectProps {
24
24
  smoothScroll?: boolean;
25
25
  dataQa?: string | null;
26
26
  widthFitOptions?: boolean;
27
- isRequired?: boolean;
28
- labelTextVariant?: string;
29
- errorLabelTextVariant?: string;
30
27
  }
31
28
 
32
29
  export const FormSelect: React.FC<Expand<FormSelectProps> &
@@ -6,8 +6,8 @@ import styled from "styled-components";
6
6
  import { noop } from "../../../util/general";
7
7
 
8
8
  const DefaultHeading = styled.div`
9
- ${({ fontSize }) => `font-size: ${fontSize};`}
10
- color: ${colors.CHARADE_GREY};
9
+ font-size: 0.875rem;
10
+ color: ${colors.CHARADE_GREY}
11
11
  margin: 0;
12
12
  padding: 8px 0px;
13
13
  `;
@@ -19,13 +19,8 @@ const StyledFieldset = styled.fieldset`
19
19
  const RadioGroup = ({
20
20
  headingText,
21
21
  groupName,
22
- headingFontSize = "0.875rem",
23
22
  heading: Heading = (
24
- <DefaultHeading
25
- role="heading"
26
- id={`radio-group-${groupName}-heading`}
27
- fontSize={headingFontSize}
28
- >
23
+ <DefaultHeading role="heading" id={`radio-group-${groupName}-heading`}>
29
24
  {headingText}
30
25
  </DefaultHeading>
31
26
  ),
@@ -17,7 +17,6 @@ export interface RadioGroupProps {
17
17
  handleChange?: () => void;
18
18
  heading?: ReactNode;
19
19
  headingText: string;
20
- headingFontSize?: string;
21
20
  }
22
21
 
23
22
  export const RadioGroup: React.FC<Expand<RadioGroupProps> &
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import { text } from "@storybook/addon-knobs";
3
- import FormInput from "./FormInput";
4
- import { Box } from "../layouts";
5
- import page from "../../../../.storybook/page";
6
- const data = {
7
- fieldOne: {
8
- rawValue: "Form Input One"
9
- }
10
- };
11
- export const formInputs = () => {
12
- return (
13
- <Box padding="1rem">
14
- <FormInput
15
- labelTextWhenNoError={text(
16
- "labelTextWhenNoError",
17
- "Label Text When No Error",
18
- "props"
19
- )}
20
- type="text"
21
- labelTextVariant={text("labelTextVariant", "pS", "props")}
22
- errorLabelTextVariant={text("errorLabelTextVariant", "pS", "props")}
23
- field={data.fieldOne}
24
- />
25
- </Box>
26
- );
27
- };
28
-
29
- const story = page({
30
- title: "Components|Atoms/FormInput",
31
- Component: FormInput
32
- });
33
- export default story;