@thecb/components 10.12.0-beta.0 → 10.12.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.12.0-beta.0",
3
+ "version": "10.12.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import Expand from "../../../util/expand";
3
3
 
4
4
  export interface CardProps {
5
- text?: string;
5
+ text?: string | React.ReactNode;
6
6
  textAs?: string;
7
7
  titleText?: string;
8
8
  titleAs?: string;
@@ -119,6 +119,8 @@ const FormInput = ({
119
119
  isRequired = false,
120
120
  errorFieldExtraStyles,
121
121
  showFieldErrorRow = true,
122
+ labelTextVariant = "pS",
123
+ errorTextVariant = "pXS",
122
124
  ...props
123
125
  }) => {
124
126
  const [showPassword, setShowPassword] = useState(false);
@@ -148,7 +150,7 @@ const FormInput = ({
148
150
  <Text
149
151
  as="label"
150
152
  color={themeValues.labelColor}
151
- variant="pS"
153
+ variant={labelTextVariant}
152
154
  weight={themeValues.fontWeight}
153
155
  extraStyles={`word-break: break-word;
154
156
  font-family: Public Sans;
@@ -167,7 +169,7 @@ const FormInput = ({
167
169
  <Text
168
170
  as="label"
169
171
  color={themeValues.labelColor}
170
- variant="pS"
172
+ variant={labelTextVariant}
171
173
  fontWeight={themeValues.fontWeight}
172
174
  extraStyles={`word-break: break-word;
173
175
  font-family: Public Sans;
@@ -180,7 +182,7 @@ const FormInput = ({
180
182
  </Text>
181
183
  {type === "password" && (
182
184
  <Text
183
- variant="pS"
185
+ variant={labelTextVariant}
184
186
  color={themeValues.linkColor}
185
187
  weight={themeValues.fontWeight}
186
188
  hoverStyles={themeValues.hoverFocusStyles}
@@ -282,7 +284,7 @@ const FormInput = ({
282
284
  (field.hasErrors && showErrors) ? (
283
285
  <Text
284
286
  color={ERROR_COLOR}
285
- variant="pXS"
287
+ variant={errorTextVariant}
286
288
  weight={themeValues.fontWeight}
287
289
  extraStyles={`word-break: break-word;
288
290
  font-family: Public Sans;
@@ -0,0 +1,33 @@
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;
@@ -26,6 +26,11 @@ 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;
29
34
  }
30
35
 
31
36
  export const FormInput: React.FC<Expand<FormInputProps> &
@@ -25,7 +25,9 @@ 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
28
+ isRequired = false,
29
+ labelTextVariant = "pS",
30
+ errorLabelTextVariant = "pXS"
29
31
  }) => {
30
32
  const [open, setOpen] = useState(false);
31
33
  const dropdownRef = useRef(null);
@@ -54,7 +56,7 @@ const FormSelect = ({
54
56
  <Cluster justify="space-between" align="center">
55
57
  <Text
56
58
  as="label"
57
- variant="pS"
59
+ variant={labelTextVariant}
58
60
  color={themeValues.labelColor}
59
61
  weight={themeValues.fontWeight}
60
62
  extraStyles={`word-break: break-word;
@@ -101,7 +103,7 @@ const FormSelect = ({
101
103
  {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
102
104
  <Text
103
105
  color={ERROR_COLOR}
104
- variant="pXS"
106
+ variant={errorLabelTextVariant}
105
107
  weight={themeValues.fontWeight}
106
108
  extraStyles={`
107
109
  word-break: break-word;
@@ -24,6 +24,9 @@ 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;
27
30
  }
28
31
 
29
32
  export const FormSelect: React.FC<Expand<FormSelectProps> &
@@ -100,7 +100,9 @@ const EditableList = ({
100
100
  disabled={expiredItem === EXPIRED}
101
101
  >
102
102
  <Text variant="p" color={CHARADE_GREY}>
103
- {renderItem(item)}
103
+ {!!renderItem &&
104
+ typeof renderItem === "function" &&
105
+ renderItem(item)}
104
106
  </Text>
105
107
  <EditableListItemControls>
106
108
  {item.isPrimary && (
@@ -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
- font-size: 0.875rem;
10
- color: ${colors.CHARADE_GREY}
9
+ ${({ fontSize }) => `font-size: ${fontSize};`}
10
+ color: ${colors.CHARADE_GREY};
11
11
  margin: 0;
12
12
  padding: 8px 0px;
13
13
  `;
@@ -19,8 +19,13 @@ const StyledFieldset = styled.fieldset`
19
19
  const RadioGroup = ({
20
20
  headingText,
21
21
  groupName,
22
+ headingFontSize = "0.875rem",
22
23
  heading: Heading = (
23
- <DefaultHeading role="heading" id={`radio-group-${groupName}-heading`}>
24
+ <DefaultHeading
25
+ role="heading"
26
+ id={`radio-group-${groupName}-heading`}
27
+ fontSize={headingFontSize}
28
+ >
24
29
  {headingText}
25
30
  </DefaultHeading>
26
31
  ),
@@ -17,6 +17,7 @@ export interface RadioGroupProps {
17
17
  handleChange?: () => void;
18
18
  heading?: ReactNode;
19
19
  headingText: string;
20
+ headingFontSize?: string;
20
21
  }
21
22
 
22
23
  export const RadioGroup: React.FC<Expand<RadioGroupProps> &