Skip to content

Commit

Permalink
feat(BoemlyFormControl): Make Textarea available
Browse files Browse the repository at this point in the history
  • Loading branch information
raulsteurer committed Oct 27, 2022
1 parent 8c2c2bf commit ef2586e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
Expand Up @@ -103,6 +103,13 @@ Checkbox.args = {
checkboxProps: { children: 'Checkbox' },
};

export const Textarea = Template.bind({});
Textarea.args = {
id: 'textarea',
inputType: 'Textarea',
textareaProps: { placeholder: 'Textarea' },
};

export const DatePicker = Template.bind({});
DatePicker.args = {
id: 'date-picker',
Expand Down
22 changes: 14 additions & 8 deletions src/components/BoemlyFormControl/BoemlyFormControl.tsx
@@ -1,25 +1,27 @@
import { StyleProps } from '@chakra-ui/react';
import React, { ReactNode } from 'react';
import {
Checkbox,
CheckboxProps,
Text,
FormControl,
FormErrorMessage,
FormHelperText,
FormLabel,
Input,
InputGroup,
InputProps,
InputRightElement,
Input,
NumberDecrementStepper,
NumberIncrementStepper,
NumberInput,
NumberInputField,
NumberInputProps,
NumberInputStepper,
NumberIncrementStepper,
NumberDecrementStepper,
Select,
InputProps,
NumberInputProps,
SelectProps,
StyleProps,
Text,
Textarea,
TextareaProps,
useToken,
} from '@chakra-ui/react';
import { CaretDown, CaretUp, Check, WarningOctagon } from 'phosphor-react';
Expand All @@ -34,13 +36,14 @@ export interface BoemlyFormControlProps extends StyleProps {
errorMessage?: string;

// Input type
inputType?: 'Input' | 'NumberInput' | 'Select' | 'Checkbox' | 'DatePicker';
inputType?: 'Input' | 'NumberInput' | 'Select' | 'Checkbox' | 'DatePicker' | 'Textarea';
inputProps?: InputProps;
numberInputProps?: NumberInputProps;
selectProps?: SelectProps;
selectOptions?: { value: string; label: string; disabled?: boolean }[];
checkboxProps?: CheckboxProps;
datePickerProps?: DatePickerProps;
textareaProps?: TextareaProps;

// Inner input elements
leftAddonsOrElements?: ReactNode[];
Expand All @@ -67,6 +70,7 @@ export const BoemlyFormControl: React.FC<BoemlyFormControlProps> = ({
selectOptions = [],
checkboxProps,
datePickerProps,
textareaProps,

leftAddonsOrElements = [],
rightAddonsOrElements = [],
Expand Down Expand Up @@ -114,6 +118,8 @@ export const BoemlyFormControl: React.FC<BoemlyFormControlProps> = ({
return <Checkbox {...checkboxProps} />;
case 'DatePicker':
return <DatePicker size={size} {...datePickerProps} />;
case 'Textarea':
return <Textarea bgColor="white" {...textareaProps} />;
default:
return <Input bgColor="white" {...inputProps} />;
}
Expand Down
33 changes: 33 additions & 0 deletions src/constants/componentCustomizations.tsx
Expand Up @@ -460,6 +460,39 @@ export const CustomizedPinInput = {
},
};

export const CustomizedTextarea = {
sizes: {
xl: {
...CustomizedText.sizes.mdRegularNormal,
py: '2',
px: '4',
borderRadius: 'xl',
},
lg: {
...CustomizedText.sizes.mdLowNormal,
py: '2',
px: '4',
borderRadius: 'lg',
},
md: {
...CustomizedText.sizes.smRegularNormal,
py: '2',
px: '4',
borderRadius: 'lg',
},
sm: {
...CustomizedText.sizes.smLowNormal,
py: '2',
px: '3',
borderRadius: 'md',
},
},
defaultProps: {
size: 'lg',
focusBorderColor: 'black',
},
};

export const CustomizedSelect = {
defaultProps: {
variant: 'outline',
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getTheme.ts
Expand Up @@ -13,6 +13,7 @@ import {
CustomizedSelect,
CustomizedTable,
CustomizedText,
CustomizedTextarea,
CustomizedTooltip,
} from '../constants/componentCustomizations';
import {
Expand Down Expand Up @@ -62,6 +63,7 @@ const getTheme = ({ customColors, customFonts, customRadii }: Options) => {
Select: CustomizedSelect,
Table: CustomizedTable,
Text: CustomizedText,
Textarea: CustomizedTextarea,
Tooltip: CustomizedTooltip,
},
});
Expand Down

1 comment on commit ef2586e

@vercel
Copy link

@vercel vercel bot commented on ef2586e Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.