Skip to content

Commit

Permalink
TextareaControl: Update styles (#64586)
Browse files Browse the repository at this point in the history
* TextareaControl: Refactor styles

* Add 40px size prop

* Tweak typography styles

* Clarify with comment

* Remove opt-in prop

* Improve comment

* Clean up unnecessary prop type

* Add changelog

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: jameskoster <[email protected]>
  • Loading branch information
6 people authored Aug 21, 2024
1 parent 2719bc8 commit d453964
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 96 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- `UnitControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Popover`: allow `style` prop usage ([#64489](https://github.com/WordPress/gutenberg/pull/64489)).
- `ToolsPanel`: sets column-gap to 16px for ToolsPanel grid ([#64497](https://github.com/WordPress/gutenberg/pull/64497)).
- `TextareaControl`: Update styles ([#64586](https://github.com/WordPress/gutenberg/pull/64586)).

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ Default.args = {
__nextHasNoMarginBottom: true,
label: 'Text',
help: 'Enter some text',
placeholder: 'Placeholder',
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,86 @@
* External dependencies
*/
import styled from '@emotion/styled';
import { css } from '@emotion/react';

/**
* Internal dependencies
*/
import { inputControl } from '../../utils/input';
import { font } from '../../utils/font';
import { COLORS } from '../../utils/colors-values';
import { CONFIG } from '../../utils';
import { breakpoint } from '../../utils/breakpoint';

const inputStyleNeutral = css`
box-shadow: 0 0 0 transparent;
border-radius: ${ CONFIG.radiusSmall };
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
@media not ( prefers-reduced-motion ) {
transition: box-shadow 0.1s linear;
}
`;

const inputStyleFocus = css`
border-color: ${ COLORS.theme.accent };
box-shadow: 0 0 0
calc( ${ CONFIG.borderWidthFocus } - ${ CONFIG.borderWidth } )
${ COLORS.theme.accent };
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
`;

export const StyledTextarea = styled.textarea`
width: 100%;
${ inputControl }
display: block;
font-family: ${ font( 'default.fontFamily' ) };
line-height: 20px;
// Vertical padding is to match the standard 40px control height when rows=1,
// in conjunction with the 20px line-height.
// "Standard" metrics are 10px 12px, but subtracts 1px each to account for the border width.
padding: 9px 11px;
${ inputStyleNeutral };
/* Fonts smaller than 16px causes mobile safari to zoom. */
font-size: ${ font( 'mobileTextMinFontSize' ) };
${ breakpoint( 'small' ) } {
font-size: ${ font( 'default.fontSize' ) };
}
&:focus {
${ inputStyleFocus }
}
// Use opacity to work in various editor styles.
&::-webkit-input-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&:-ms-input-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}
.is-dark-theme & {
&::-webkit-input-placeholder {
color: ${ COLORS.ui.lightGrayPlaceholder };
}
&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: ${ COLORS.ui.lightGrayPlaceholder };
}
&:-ms-input-placeholder {
color: ${ COLORS.ui.lightGrayPlaceholder };
}
}
`;
30 changes: 0 additions & 30 deletions packages/components/src/utils/input/base.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/components/src/utils/input/index.js

This file was deleted.

63 changes: 0 additions & 63 deletions packages/components/src/utils/input/input-control.js

This file was deleted.

0 comments on commit d453964

Please sign in to comment.