Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BorderControl: Fix focus styling #40951

Merged
merged 5 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `BorderControl` now only displays the reset button in its popover when selections have already been made. [#40917](https://github.com/WordPress/gutenberg/pull/40917)
- `BorderControl` & `BorderBoxControl`: Add `__next36pxDefaultSize` flag for larger default size ([#40920](https://github.com/WordPress/gutenberg/pull/40920)).
- `BorderControl` improved focus and border radius styling for component. [#40951](https://github.com/WordPress/gutenberg/pull/40951)

### Internal

Expand Down
57 changes: 41 additions & 16 deletions packages/components/src/border-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ const labelStyles = css`
font-weight: 500;
`;

const focusBoxShadow = css`
box-shadow: inset 0 0 0 ${ CONFIG.borderWidth } ${ COLORS.ui.borderFocus };
`;

export const borderControl = css`
position: relative;
`;

export const innerWrapper = () => css`
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
border-radius: 2px;
flex: 1 0 40%;

/*
Expand All @@ -47,13 +49,29 @@ export const innerWrapper = () => css`
*/
${ UnitControlWrapper } {
flex: 1;
${ rtl( { marginLeft: 0 } )() }
${ rtl( { marginLeft: -1 } )() }
}

&& ${ UnitSelect } {
/* Prevent default styles forcing heights larger than BorderControl */
min-height: 0;
${ rtl( { marginRight: 0 } )() }
${ rtl(
{
borderRadius: '0 1px 1px 0',
marginRight: 0,
},
{
borderRadius: '1px 0 0 1px',
marginLeft: 0,
}
)() }
transition: box-shadow 0.1s linear, border 0.1s linear;

&:focus {
z-index: 1;
${ focusBoxShadow }
border: 1px solid ${ COLORS.ui.borderFocus };
}
}
`;

Expand All @@ -76,16 +94,6 @@ export const wrapperHeight = ( __next36pxDefaultSize?: boolean ) => {

export const borderControlDropdown = () => css`
background: #fff;
${ rtl(
{
borderRadius: `1px 0 0 1px`,
borderRight: `${ CONFIG.borderWidth } solid ${ COLORS.ui.border }`,
},
{
borderRadius: `0 1px 1px 0`,
borderLeft: `${ CONFIG.borderWidth } solid ${ COLORS.ui.border }`,
}
)() }

&& > button {
/*
Expand All @@ -94,7 +102,20 @@ export const borderControlDropdown = () => css`
*/
height: 100%;
padding: ${ space( 0.75 ) };
border-radius: inherit;
${ rtl(
{ borderRadius: `2px 0 0 2px` },
{ borderRadius: `0 2px 2px 0` }
)() }
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
position: relative;

&:focus,
&:hover:not( :disabled ) {
${ focusBoxShadow }
border-color: ${ COLORS.ui.borderFocus };
z-index: 1;
position: relative;
}
}
`;

Expand Down Expand Up @@ -187,7 +208,11 @@ export const resetButton = css`
export const borderWidthControl = () => css`
/* Target the InputControl's backdrop */
&&& ${ BackdropUI } {
border: none;
${ rtl( {
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
} )() }
transition: box-shadow 0.1s linear;
}

/* Specificity required to overcome UnitControl padding */
Expand Down