Skip to content

Commit

Permalink
adds contrast property to textArea component (#3484)
Browse files Browse the repository at this point in the history
* adds a contrast property to textarea component

* Update src/Textarea/Textarea.tsx

Co-authored-by: Armağan <broccolinisoup@github.com>

* Add changeset

---------

Co-authored-by: Armağan <broccolinisoup@github.com>
  • Loading branch information
ValbertMartins and broccolinisoup authored Nov 22, 2023
1 parent 40b2978 commit e403789
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
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

0 comments on commit e403789

Please sign in to comment.