@thecb/components 10.11.1 → 10.11.2-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.1",
3
+ "version": "10.11.2-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",
@@ -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> &
@@ -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
  ),
@@ -24,6 +24,7 @@ const config = [
24
24
  export const radioGroup = () => (
25
25
  <RadioGroup
26
26
  headingText="Radio Group Title"
27
+ headingFontSize="1rem"
27
28
  config={config}
28
29
  groupName="radio-button-group"
29
30
  field={{
@@ -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> &
Binary file