-
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.
Merge branch 'main' into steph/ccp-select
- Loading branch information
Showing
16 changed files
with
237 additions
and
365 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,7 @@ | ||
--- | ||
'@lg-chat/message-feedback': minor | ||
--- | ||
|
||
[LG-4144](https://jira.mongodb.org/browse/LG-4144) | ||
|
||
Updates spacing in `InlineMessageFeedback` component due to updated styling in `TextArea` component |
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,31 @@ | ||
--- | ||
'@leafygreen-ui/text-area': major | ||
--- | ||
|
||
[LG-4144](https://jira.mongodb.org/browse/LG-4144) | ||
|
||
1. `FormField` styling changes apply to `TextArea`. [See style changes here](https://github.com/mongodb/leafygreen-ui/blob/main/packages/form-field/CHANGELOG.md#102) | ||
|
||
2. A default `errorMessage` of `'This input needs your attention'` will render below text area when state is invalid. | ||
|
||
3. A default `successMessage` of `'Success'` will render when state is valid. `successMessage` prop accepts a custom string. | ||
|
||
4. Disabled `TextArea` component no longer renders the `disabled` attribute and instead relies on `aria-disabled` and `readonly` attributes. | ||
|
||
The last change is made to ensure that disabled components are still focusable to users using keyboard navigation. | ||
|
||
For more on `aria-disabled` see the [documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled) | ||
|
||
#### Migration guide | ||
|
||
Functionally, migration should be seamless, however there may be unit/integration/e2e tests that relied on this behavior. | ||
|
||
##### Jest/RTL | ||
|
||
Generally, only this repo should need to test that these components have a specific attribute. We recommend updating unit tests to check that some event was or was not called. | ||
|
||
However, there are cases where this may still need to be tested. In cases where a test checks `expect(textArea).toBeDisabled()`, you can replace and use [test harnesses](https://github.com/mongodb/leafygreen-ui/blob/main/packages/text-area/README.md#test-harnesses). | ||
|
||
##### Cypress | ||
|
||
Similar to unit tests, you should generally test functionality and not implementation details. However, to test this in Cypress replace any `cy.get(textArea).should('be.disabled');` checks with `cy.get(textArea).invoke('attr', 'aria-disabled').should('eq', 'true');` |
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
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
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 |
---|---|---|
@@ -1,146 +1,18 @@ | ||
import { css } from '@leafygreen-ui/emotion'; | ||
import { Theme } from '@leafygreen-ui/lib'; | ||
import { palette } from '@leafygreen-ui/palette'; | ||
import { | ||
focusRing, | ||
fontFamilies, | ||
fontWeights, | ||
hoverRing, | ||
spacing, | ||
transitionDuration, | ||
} from '@leafygreen-ui/tokens'; | ||
import { spacing } from '@leafygreen-ui/tokens'; | ||
|
||
export const containerStyles = css` | ||
const TEXT_AREA_MIN_HEIGHT = 64; | ||
|
||
export const textAreaContainerStyles = css` | ||
height: auto; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0; | ||
`; | ||
|
||
export const textAreaStyle = css` | ||
font-family: ${fontFamilies.default}; | ||
export const textAreaStyles = css` | ||
width: 100%; | ||
min-height: ${spacing[6]}px; | ||
resize: none; | ||
margin: 0; | ||
padding: 8px 12px 1px 12px; | ||
font-size: 14px; | ||
font-weight: ${fontWeights.regular}; | ||
line-height: 16px; | ||
border: 1px solid; | ||
border-radius: 6px; | ||
transition: ${transitionDuration.default}ms ease-in-out; | ||
transition-property: border-color, box-shadow; | ||
margin-top: 4px; | ||
&:focus { | ||
outline: none; | ||
border-color: transparent; | ||
box-shadow: ${focusRing[Theme.Light].input}; | ||
} | ||
&:disabled { | ||
cursor: not-allowed; | ||
} | ||
`; | ||
|
||
export const errorContainerStyle = css` | ||
min-height: ${TEXT_AREA_MIN_HEIGHT}px; | ||
display: flex; | ||
height: 20px; | ||
margin-top: 5px; | ||
align-items: center; | ||
font-weight: ${fontWeights.regular}; | ||
`; | ||
|
||
export const errorMessageLabelStyles = css` | ||
line-height: 1; | ||
`; | ||
|
||
export const errorIconStyle = css` | ||
margin-right: 3px; | ||
resize: none; | ||
padding: ${spacing[200]}px ${spacing[300]}px; | ||
`; | ||
|
||
interface ColorSets { | ||
textArea: string; | ||
errorBorder: string; | ||
errorIcon: string; | ||
} | ||
|
||
export const colorSets: Record<Theme, ColorSets> = { | ||
[Theme.Light]: { | ||
textArea: css` | ||
color: ${palette.gray.dark3}; | ||
background-color: ${palette.white}; | ||
border-color: ${palette.gray.base}; | ||
&:hover:not(:disabled):not(:focus) { | ||
border-color: ${palette.gray.base}; | ||
box-shadow: ${hoverRing[Theme.Light].gray}; | ||
} | ||
&:disabled { | ||
color: ${palette.gray.base}; | ||
background-color: ${palette.gray.light2}; | ||
border-color: ${palette.gray.light1}; | ||
&::placeholder { | ||
color: inherit; | ||
} | ||
} | ||
`, | ||
|
||
errorBorder: css` | ||
border-color: ${palette.red.base}; | ||
&:hover:not(:disabled):not(:focus) { | ||
border-color: ${palette.red.base}; | ||
box-shadow: ${hoverRing[Theme.Light].red}; | ||
} | ||
&:disabled { | ||
border-color: ${palette.gray.light1}; | ||
} | ||
`, | ||
|
||
errorIcon: css` | ||
color: ${palette.red.base}; | ||
`, | ||
}, | ||
[Theme.Dark]: { | ||
textArea: css` | ||
color: ${palette.gray.light3}; | ||
background-color: ${palette.gray.dark4}; | ||
border-color: ${palette.gray.base}; | ||
&:hover:not(:disabled):not(:focus) { | ||
border-color: ${palette.gray.base}; | ||
box-shadow: ${hoverRing[Theme.Dark].gray}; | ||
} | ||
&:disabled { | ||
color: ${palette.gray.dark1}; | ||
background-color: ${palette.gray.dark3}; | ||
border-color: ${palette.gray.dark2}; | ||
&::placeholder { | ||
color: inherit; | ||
} | ||
} | ||
`, | ||
|
||
errorBorder: css` | ||
border-color: ${palette.red.light1}; | ||
&:hover:not(:disabled):not(:focus) { | ||
border-color: ${palette.red.light1}; | ||
box-shadow: ${hoverRing[Theme.Dark].red}; | ||
} | ||
&:disabled { | ||
border-color: ${palette.gray.dark2}; | ||
} | ||
`, | ||
|
||
errorIcon: css` | ||
color: ${palette.red.light1}; | ||
`, | ||
}, | ||
}; |
Oops, something went wrong.