Skip to content

Commit 22dd354

Browse files
committed
fix: resizable and minHeight controlable as properties
1 parent c5fe2d9 commit 22dd354

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

docs/stories/03-inputs/Textarea.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ const meta: Meta<typeof Textarea> = {
5353
type: { summary: 'string' },
5454
},
5555
},
56+
resizable: {
57+
control: 'boolean',
58+
description: 'Whether the textarea is resizable.',
59+
table: {
60+
type: { summary: 'boolean' },
61+
defaultValue: { summary: 'true' },
62+
},
63+
},
5664
},
5765
parameters: {
5866
chromatic: { disableSnapshot: false },

packages/design-system/src/components/Textarea/Textarea.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ interface TextareaProps
1111
Pick<Field.InputProps, 'hasError' | 'id' | 'name' | 'required'> {
1212
value?: string;
1313
'aria-describedby'?: string;
14+
resizable?: boolean;
1415
}
1516

1617
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
17-
({ disabled, hasError: hasErrorProp, id: idProp, name: nameProp, required: requiredProp, ...props }, ref) => {
18+
(
19+
{
20+
disabled,
21+
hasError: hasErrorProp,
22+
id: idProp,
23+
name: nameProp,
24+
required: requiredProp,
25+
resizable = true,
26+
...props
27+
},
28+
ref,
29+
) => {
1830
const { error, ...field } = useField('Textarea');
1931
const hasError = Boolean(error) || hasErrorProp;
2032
const id = field.id ?? idProp;
@@ -46,6 +58,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
4658
id={id}
4759
name={name}
4860
aria-describedby={ariaDescription}
61+
$resizable={resizable}
4962
{...props}
5063
/>
5164
</Wrapper>
@@ -60,8 +73,8 @@ const Wrapper = styled<BoxComponent>(Box)<{ $hasError?: boolean }>`
6073
const TextareaElement = styled<BoxComponent<'textarea'>>(Box)`
6174
display: block;
6275
border: none;
63-
resize: vertical;
64-
min-height: 10.5rem;
76+
resize: ${({ $resizable }) => ($resizable ? 'vertical' : 'none')};
77+
min-height: ${({ minHeight }) => minHeight || '10.5rem'};
6578
6679
&::placeholder {
6780
color: ${({ theme }) => theme.colors.neutral600};

0 commit comments

Comments
 (0)