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: always show Reset button #69066

Merged
merged 11 commits into from
Feb 15, 2025
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
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Enhancement
- `BorderControlDropdown`, `BorderControl`: Reset button is always visible. ([#69066](https://github.com/WordPress/gutenberg/pull/69066)).

### Internal

- `NumberControl`: Fix invalid HTML attributes for infinite bounds ([#69033](https://github.com/WordPress/gutenberg/pull/69033)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const BorderControlDropdown = (
onStyleChange,
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
resetButtonWrapperClassName,
size,
__unstablePopoverProps,
...otherProps
Expand All @@ -173,7 +173,7 @@ const BorderControlDropdown = (
enableStyle
);

const showResetButton = color || ( style && style !== 'none' );
const enableResetButton = color || ( style && style !== 'none' );
const dropdownPosition = __experimentalIsRenderedInSidebar
? 'bottom left'
: undefined;
Expand All @@ -199,9 +199,7 @@ const BorderControlDropdown = (
</Button>
);

const renderContent: DropdownComponentProps[ 'renderContent' ] = ( {
onClose,
} ) => (
const renderContent: DropdownComponentProps[ 'renderContent' ] = () => (
<>
<DropdownContentWrapper paddingSize="medium">
<VStack className={ popoverControlsClassName } spacing={ 6 }>
Expand All @@ -224,22 +222,20 @@ const BorderControlDropdown = (
/>
) }
</VStack>
</DropdownContentWrapper>
{ showResetButton && (
<DropdownContentWrapper paddingSize="none">
<div className={ resetButtonWrapperClassName }>
<Button
className={ resetButtonClassName }
variant="tertiary"
onClick={ () => {
onReset();
onClose();
} }
disabled={ ! enableResetButton }
accessibleWhenDisabled
__next40pxDefaultSize
>
{ __( 'Reset' ) }
</Button>
</DropdownContentWrapper>
) }
</div>
</DropdownContentWrapper>
</>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export function useBorderControlDropdown(
return cx( styles.borderControlPopoverContent );
}, [ cx ] );

const resetButtonClassName = useMemo( () => {
return cx( styles.resetButton );
const resetButtonWrapperClassName = useMemo( () => {
return cx( styles.resetButtonWrapper );
}, [ cx ] );

return {
Expand All @@ -94,7 +94,7 @@ export function useBorderControlDropdown(
onReset,
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
resetButtonWrapperClassName,
size,
__experimentalIsRenderedInSidebar,
};
Expand Down
14 changes: 4 additions & 10 deletions packages/components/src/border-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,10 @@ export const borderControlPopoverControls = css`
export const borderControlPopoverContent = css``;
export const borderColorIndicator = css``;

export const resetButton = css`
justify-content: center;
width: 100%;

/* Override button component styling */
&& {
border-top: ${ CONFIG.borderWidth } solid ${ COLORS.gray[ 400 ] };
border-top-left-radius: 0;
border-top-right-radius: 0;
}
export const resetButtonWrapper = css`
display: flex;
justify-content: flex-end;
margin-top: 12px;
`;

export const borderSlider = () => css`
Expand Down
Loading