Skip to content

Commit

Permalink
BorderControl: Fix button styles (#56730)
Browse files Browse the repository at this point in the history
* `BorderControl`: Fix button styles

* Add __next40pxDefaultSize to Button when BorderControl has large size

* Update changelog

* Remove explicit return leftover from unused changes
  • Loading branch information
brookewp authored Dec 8, 2023
1 parent 67bea2a commit 3ad117e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- `ToggleGroupControl`: react correctly to external controlled updates ([#56678](https://github.com/WordPress/gutenberg/pull/56678)).
- `ToolsPanel`: fix a performance issue ([#56770](https://github.com/WordPress/gutenberg/pull/56770)).
- `BorderControl`: adjust `BorderControlDropdown` Button size to fix misaligned border ([#56730](https://github.com/WordPress/gutenberg/pull/56730)).

## 25.13.0 (2023-11-29)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const BorderControlDropdown = (
popoverControlsClassName,
resetButtonClassName,
showDropdownHeader,
size,
__unstablePopoverProps,
...otherProps
} = useBorderControlDropdown( props );
Expand Down Expand Up @@ -178,6 +179,7 @@ const BorderControlDropdown = (
tooltipPosition={ dropdownPosition }
label={ __( 'Border color and style picker' ) }
showTooltip={ true }
__next40pxDefaultSize={ size === '__unstable-large' ? true : false }
>
<span className={ indicatorWrapperClassName }>
<ColorIndicator
Expand All @@ -198,7 +200,7 @@ const BorderControlDropdown = (
<HStack>
<StyledLabel>{ __( 'Border color' ) }</StyledLabel>
<Button
isSmall
size="small"
label={ __( 'Close border color' ) }
icon={ closeSmall }
onClick={ onClose }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function useBorderControlDropdown(
// Generate class names.
const cx = useCx();
const classes = useMemo( () => {
return cx( styles.borderControlDropdown( size ), className );
}, [ className, cx, size ] );
return cx( styles.borderControlDropdown, className );
}, [ className, cx ] );

const indicatorClassName = useMemo( () => {
return cx( styles.borderColorIndicator );
Expand Down Expand Up @@ -95,6 +95,7 @@ export function useBorderControlDropdown(
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
size,
__experimentalIsRenderedInSidebar,
};
}
11 changes: 2 additions & 9 deletions packages/components/src/border-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,11 @@ export const wrapperHeight = ( size?: 'default' | '__unstable-large' ) => {
`;
};

export const borderControlDropdown = (
size?: 'default' | '__unstable-large'
) => css`
export const borderControlDropdown = css`
background: #fff;
&& > button {
/*
* Override button component styles to fit within BorderControl
* regardless of size.
*/
height: ${ size === '__unstable-large' ? '40px' : '30px' };
width: ${ size === '__unstable-large' ? '40px' : '30px' };
aspect-ratio: 1;
padding: 0;
display: flex;
align-items: center;
Expand Down

1 comment on commit 3ad117e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 3ad117e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7136193628
📝 Reported issues:

Please sign in to comment.