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

Colors: Fix color button border radii #55207

Merged
merged 5 commits into from
Oct 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ $swatch-gap: 12px;
border-right: 1px solid $gray-300;
border-bottom: 1px solid $gray-300;

&.first {
// Identify the first visible instance as placeholder items will not have this class.
&:nth-child(1 of &) {
margin-top: $grid-unit-30;
border-top-left-radius: $radius-block-ui;
border-top-right-radius: $radius-block-ui;
border-top: 1px solid $gray-300;
}

&.last {
// Identify the last visible instance as placeholder items will not have this class.
&:nth-last-child(1 of &) {
border-bottom-left-radius: $radius-block-ui;
border-bottom-right-radius: $radius-block-ui;
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- `Notice`: Remove margins from `Notice` component ([#54800](https://github.com/WordPress/gutenberg/pull/54800)).
- `ToolsPanel`: do not apply the `className` to prop to `ToolsPanelItem` components when rendered as placeholders ([#55207](https://github.com/WordPress/gutenberg/pull/55207)).
- `ColorPalette`/`ToggleGroupControl/ToggleGroupControlOptionBase`: add `type="button"` attribute to native `<button>`s ([#55125](https://github.com/WordPress/gutenberg/pull/55125)).

### Bug Fix
Expand Down
10 changes: 4 additions & 6 deletions packages/components/src/tools-panel/tools-panel-item/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,16 @@ export function useToolsPanelItem(

const cx = useCx();
const classes = useMemo( () => {
const placeholderStyle =
shouldRenderPlaceholder &&
! isShown &&
styles.ToolsPanelItemPlaceholder;
const shouldApplyPlaceholderStyles =
shouldRenderPlaceholder && ! isShown;
const firstItemStyle =
firstDisplayedItem === label && __experimentalFirstVisibleItemClass;
const lastItemStyle =
lastDisplayedItem === label && __experimentalLastVisibleItemClass;
return cx(
styles.ToolsPanelItem,
placeholderStyle,
className,
shouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder,
! shouldApplyPlaceholderStyles && className,
Comment on lines +187 to +188
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice solution! 👍

This was the key I was missing in #55071 to avoid the internal class name.

firstItemStyle,
lastItemStyle
);
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/tools-panel/tools-panel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,8 @@ A function to call when the `Reset all` menu option is selected. As an argument,
Advises the `ToolsPanel` that all of its `ToolsPanelItem` children should render
placeholder content (instead of `null`) when they are toggled off and hidden.

Note that placeholder items won't apply the `className` that would be
normally applied to a visible `ToolsPanelItem` via the `className` prop.

- Required: No
- Default: `false`
2 changes: 2 additions & 0 deletions packages/components/src/tools-panel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export type ToolsPanelProps = {
/**
* Advises the `ToolsPanel` that its child `ToolsPanelItem`s should render
* placeholder content instead of null when they are toggled off and hidden.
* Note that placeholder items won't apply the `className` that would be
* normally applied to a visible `ToolsPanelItem` via the `className` prop.
*
* @default false
*/
Expand Down
Loading