Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-pens-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

TextArea: Add contrast property
6 changes: 6 additions & 0 deletions src/Textarea/Textarea.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"defaultValue": "'both'",
"description": "Changes the resize behavior"
},
{
"name": "contrast",
"type": "boolean",
"defaultValue": "false",
"description": "Changes background color to a higher contrast color"
},
{
"name": "validationStatus",
"type": "'success' | 'error' | undefined",
Expand Down
4 changes: 4 additions & 0 deletions src/Textarea/Textarea.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Playground.args = {
cols: DEFAULT_TEXTAREA_COLS,
disabled: false,
resize: DEFAULT_TEXTAREA_RESIZE,
contrast: false,
rows: DEFAULT_TEXTAREA_ROWS,
validationStatus: undefined,
}
Expand All @@ -52,6 +53,9 @@ Playground.argTypes = {
options: ['none', 'both', 'horizontal', 'vertical'],
control: {type: 'radio'},
},
contrast: {
control: {type: 'boolean'},
},
rows: {
control: {type: 'number'},
},
Expand Down
14 changes: 12 additions & 2 deletions src/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export type TextareaProps = {
* Allows resizing of the textarea
*/
resize?: 'none' | 'both' | 'horizontal' | 'vertical'
/**
* apply a high contrast color to background
*/
contrast?: boolean
} & TextareaHTMLAttributes<HTMLTextAreaElement> &
SxProp

Expand Down Expand Up @@ -53,7 +57,6 @@ const StyledTextarea = styled.textarea<TextareaProps>`
css`
resize: none;
`}

${sx};
`

Expand All @@ -73,12 +76,19 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
cols = DEFAULT_TEXTAREA_COLS,
resize = DEFAULT_TEXTAREA_RESIZE,
block,
contrast,
...rest
}: TextareaProps,
ref,
): ReactElement => {
return (
<TextInputBaseWrapper sx={sxProp} validationStatus={validationStatus} disabled={disabled} block={block}>
<TextInputBaseWrapper
sx={sxProp}
validationStatus={validationStatus}
disabled={disabled}
block={block}
contrast={contrast}
>
<StyledTextarea
value={value}
resize={resize}
Expand Down