Skip to content

Commit e403789

Browse files
adds contrast property to textArea component (#3484)
* adds a contrast property to textarea component * Update src/Textarea/Textarea.tsx Co-authored-by: Armağan <[email protected]> * Add changeset --------- Co-authored-by: Armağan <[email protected]>
1 parent 40b2978 commit e403789

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

.changeset/sweet-pens-occur.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
TextArea: Add contrast property

src/Textarea/Textarea.docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
"defaultValue": "'both'",
3636
"description": "Changes the resize behavior"
3737
},
38+
{
39+
"name": "contrast",
40+
"type": "boolean",
41+
"defaultValue": "false",
42+
"description": "Changes background color to a higher contrast color"
43+
},
3844
{
3945
"name": "validationStatus",
4046
"type": "'success' | 'error' | undefined",

src/Textarea/Textarea.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Playground.args = {
3535
cols: DEFAULT_TEXTAREA_COLS,
3636
disabled: false,
3737
resize: DEFAULT_TEXTAREA_RESIZE,
38+
contrast: false,
3839
rows: DEFAULT_TEXTAREA_ROWS,
3940
validationStatus: undefined,
4041
}
@@ -52,6 +53,9 @@ Playground.argTypes = {
5253
options: ['none', 'both', 'horizontal', 'vertical'],
5354
control: {type: 'radio'},
5455
},
56+
contrast: {
57+
control: {type: 'boolean'},
58+
},
5559
rows: {
5660
control: {type: 'number'},
5761
},

src/Textarea/Textarea.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export type TextareaProps = {
2525
* Allows resizing of the textarea
2626
*/
2727
resize?: 'none' | 'both' | 'horizontal' | 'vertical'
28+
/**
29+
* apply a high contrast color to background
30+
*/
31+
contrast?: boolean
2832
} & TextareaHTMLAttributes<HTMLTextAreaElement> &
2933
SxProp
3034

@@ -53,7 +57,6 @@ const StyledTextarea = styled.textarea<TextareaProps>`
5357
css`
5458
resize: none;
5559
`}
56-
5760
${sx};
5861
`
5962

@@ -73,12 +76,19 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
7376
cols = DEFAULT_TEXTAREA_COLS,
7477
resize = DEFAULT_TEXTAREA_RESIZE,
7578
block,
79+
contrast,
7680
...rest
7781
}: TextareaProps,
7882
ref,
7983
): ReactElement => {
8084
return (
81-
<TextInputBaseWrapper sx={sxProp} validationStatus={validationStatus} disabled={disabled} block={block}>
85+
<TextInputBaseWrapper
86+
sx={sxProp}
87+
validationStatus={validationStatus}
88+
disabled={disabled}
89+
block={block}
90+
contrast={contrast}
91+
>
8292
<StyledTextarea
8393
value={value}
8494
resize={resize}

0 commit comments

Comments
 (0)