Skip to content

Commit

Permalink
Components: Simplify MenuGroup component styles (#65561)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: andrewserong <[email protected]>
  • Loading branch information
4 people authored Sep 24, 2024
1 parent 228ab3a commit 8a658c8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- `ToolsPanel`: atomic one-step state update when (un)registering panels ([#65564](https://github.com/WordPress/gutenberg/pull/65564)).
- `Navigator`: fix `isInitial` logic ([#65527](https://github.com/WordPress/gutenberg/pull/65527)).

### Enhancements

- `MenuGroup`: Simplify the MenuGroup styles within dropdown menus. ([#65561](https://github.com/WordPress/gutenberg/pull/65561)).

## 28.8.0 (2024-09-19)

### Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/dropdown-menu/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export const WithChildren: StoryObj< typeof DropdownMenu > = {
icon: more,
children: ( { onClose } ) => (
<>
<MenuItem icon={ arrowUp } onClick={ onClose }>
Standalone Item
</MenuItem>
<MenuGroup>
<MenuItem icon={ arrowUp } onClick={ onClose }>
Move Up
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/dropdown/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const WithMenuItems: StoryObj< typeof Dropdown > = {
...Default.args,
renderContent: () => (
<>
<MenuItem>Standalone Item</MenuItem>
<MenuGroup label="Group 1">
<MenuItem>Item 1</MenuItem>
<MenuItem>Item 2</MenuItem>
Expand Down
23 changes: 10 additions & 13 deletions packages/components/src/dropdown/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
.components-dropdown__content {
.components-popover__content {
padding: $grid-unit-10;

&:has(.components-menu-group) {
padding: 0;

.components-dropdown-menu__menu > .components-menu-item__button,
> .components-menu-item__button {
margin: $grid-unit-10;
width: auto;
}
}
}

[role="menuitem"] {
Expand All @@ -13,22 +23,9 @@

.components-menu-group {
padding: $grid-unit-10;
margin-top: 0;
margin-bottom: 0;
margin-left: -$grid-unit-10;
margin-right: -$grid-unit-10;

&:first-child {
margin-top: -$grid-unit-10;
}

&:last-child {
margin-bottom: -$grid-unit-10;
}
}

.components-menu-group + .components-menu-group {
margin-top: 0;
border-top: $border-width solid $gray-400;
padding: $grid-unit-10;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/menu-group/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.components-menu-group + .components-menu-group {
margin-top: $grid-unit-10;
padding-top: $grid-unit-10;
border-top: $border-width solid $gray-900;

Expand All @@ -10,6 +9,10 @@
}
}

.components-menu-group:has(> div:empty) {
display: none;
}

.components-menu-group__label {
padding: 0 $grid-unit-10;
margin-top: $grid-unit-05;
Expand Down

0 comments on commit 8a658c8

Please sign in to comment.