-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16615e7
commit d461961
Showing
4 changed files
with
126 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { TextareaHTMLAttributes } from 'react' | ||
import React, { forwardRef } from 'react' | ||
|
||
export interface TextareaProps | ||
extends TextareaHTMLAttributes<HTMLTextAreaElement> { | ||
/** | ||
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest). | ||
*/ | ||
testId?: string | ||
/** | ||
* Controls the resize property of the textare (e.g.: none, vertical, horizontal, both). | ||
* Default is 'both'. | ||
*/ | ||
resize?: 'none' | 'vertical' | 'horizontal' | 'both' | ||
} | ||
|
||
const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>( | ||
function Textarea( | ||
{ testId = 'fs-textarea', resize = 'both', ...otherProps }, | ||
ref | ||
) { | ||
return ( | ||
<textarea | ||
ref={ref} | ||
data-fs-textarea | ||
data-fs-textarea-resize={resize} | ||
data-testid={testId} | ||
{...otherProps} | ||
/> | ||
) | ||
} | ||
) | ||
export default Textarea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './Textarea' | ||
export type { TextareaProps } from './Textarea' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
[data-fs-textarea] { | ||
// -------------------------------------------------------- | ||
// Design Tokens for Textarea | ||
// -------------------------------------------------------- | ||
|
||
// Default properties | ||
--fs-textarea-padding: var(--fs-spacing-1) var(--fs-spacing-2); | ||
--fs-textarea-height: calc(var(--fs-control-tap-size) * 3); | ||
|
||
--fs-textarea-bkg-color: var(--fs-color-body-bkg); | ||
--fs-textarea-box-shadow: none; | ||
--fs-textarea-box-shadow-hover: 0 0 0 var(--fs-border-width) | ||
var(--fs-border-color-active); | ||
|
||
--fs-textarea-border-radius: var(--fs-border-radius); | ||
--fs-textarea-border-width: var(--fs-border-width); | ||
--fs-textarea-border-color: var(--fs-border-color); | ||
--fs-textarea-border-color-hover: var(--fs-border-color-active); | ||
|
||
--fs-textarea-text-color: var(--fs-color-text); | ||
--fs-textarea-text-size: var(--fs-text-size-body); | ||
|
||
--fs-textarea-line-height: 1.25; | ||
|
||
--fs-textarea-transition-function: var(--fs-transition-function); | ||
--fs-textarea-transition-property: var(--fs-transition-property); | ||
--fs-textarea-transition-timing: var(--fs-transition-timing); | ||
|
||
// Disabled properties | ||
--fs-textarea-disabled-bkg-color: var(--fs-color-disabled-bkg); | ||
--fs-textarea-disabled-text-color: var(--fs-color-disabled-text); | ||
--fs-textarea-disabled-border-width: var(--fs-border-width); | ||
--fs-textarea-disabled-border-color: var(--fs-border-color); | ||
|
||
// -------------------------------------------------------- | ||
// Structural Styles | ||
// -------------------------------------------------------- | ||
|
||
width: 100%; | ||
height: var(--fs-textarea-height); | ||
padding: var(--fs-textarea-padding); | ||
font-size: var(--fs-textarea-text-size); | ||
line-height: var(--fs-textarea-line-height); | ||
color: var(--fs-textarea-text-color); | ||
background-color: var(--fs-textarea-bkg-color); | ||
border: var(--fs-textarea-border-width) solid var(--fs-textarea-border-color); | ||
border-radius: var(--fs-textarea-border-radius); | ||
box-shadow: var(--fs-textarea-box-shadow); | ||
transition: | ||
var(--fs-textarea-transition-property) var(--fs-textarea-transition-timing) | ||
var(--fs-textarea-transition-function), | ||
width 0s, | ||
height 0s; | ||
|
||
@include input-focus-ring; | ||
|
||
&:hover:not(:disabled):not(:focus-visible):not(:focus) { | ||
border-color: var(--fs-textarea-border-color-hover); | ||
box-shadow: var(--fs-textarea-box-shadow-hover); | ||
} | ||
|
||
&:disabled { | ||
cursor: not-allowed; | ||
color: var(--fs-textarea-disabled-text-color); | ||
background-color: var(--fs-textarea-disabled-bkg-color); | ||
border: var(--fs-textarea-disabled-border-width) solid | ||
var(--fs-textarea-disabled-border-color); | ||
} | ||
|
||
// -------------------------------------------------------- | ||
// Variants Styles | ||
// -------------------------------------------------------- | ||
|
||
&[data-fs-textarea-resize='none'] { | ||
resize: none; | ||
} | ||
&[data-fs-textarea-resize='vertical'] { | ||
resize: vertical; | ||
} | ||
&[data-fs-textarea-resize='horizontal'] { | ||
resize: horizontal; | ||
} | ||
&[data-fs-textarea-resize='both'] { | ||
resize: both; | ||
} | ||
} |