Skip to content

Commit

Permalink
Add tooltips to split border radius controls (#40983)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored May 11, 2022
1 parent 1d44164 commit 15b211a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* WordPress dependencies
*/
import { __experimentalUnitControl as UnitControl } from '@wordpress/components';
import {
__experimentalUnitControl as UnitControl,
Tooltip,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const CORNERS = {
Expand Down Expand Up @@ -39,16 +42,21 @@ export default function BoxInputControls( {
};

// Controls are wrapped in tooltips as visible labels aren't desired here.
// Tooltip rendering also requires the UnitControl to be wrapped. See:
// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026
return (
<div className="components-border-radius-control__input-controls-wrapper">
{ Object.entries( CORNERS ).map( ( [ key, label ] ) => (
<UnitControl
{ ...props }
key={ key }
aria-label={ label }
value={ values[ key ] }
onChange={ createHandleOnChange( key ) }
/>
<Tooltip text={ label } position="top" key={ key }>
<div className="components-border-radius-control__tooltip-wrapper">
<UnitControl
{ ...props }
aria-label={ label }
value={ values[ key ] }
onChange={ createHandleOnChange( key ) }
/>
</div>
</Tooltip>
) ) }
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
width: 70%;
flex-wrap: wrap;

.components-unit-control-wrapper {
.components-border-radius-control__tooltip-wrapper {
width: calc(50% - #{ $grid-unit-10 });
margin-bottom: $grid-unit-10;
margin-right: $grid-unit-10;
Expand Down

0 comments on commit 15b211a

Please sign in to comment.