Skip to content

Commit

Permalink
DropdownMenuV2: use overloaded naming conventions (WordPress#64654)
Browse files Browse the repository at this point in the history
* Move subcomponents to overloaded syntax, rename to DropdownMenuV2

* Update imports and usage in Storybook

* Update imports and usage in unit tests

* Update README

* Fix private APIs

* Switch to overloaded naming in the rest of the project

* Storybook story name typo

* Try separate files

* CHANGELOG

* CHANGELOG: move to unreleased section

---------

Co-authored-by: ciampo <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored and bph committed Aug 31, 2024
1 parent 9da5da4 commit 59bd78f
Show file tree
Hide file tree
Showing 24 changed files with 909 additions and 813 deletions.
31 changes: 12 additions & 19 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ import InspectorControls from '../components/inspector-controls';
import BlockContext from '../components/block-context';
import { useBlockBindingsUtils } from '../utils/block-bindings';

const {
DropdownMenuV2: DropdownMenu,
DropdownMenuGroupV2: DropdownMenuGroup,
DropdownMenuRadioItemV2: DropdownMenuRadioItem,
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
DropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,
DropdownMenuSeparatorV2: DropdownMenuSeparator,
} = unlock( componentsPrivateApis );
const { DropdownMenuV2 } = unlock( componentsPrivateApis );

const useToolsPanelDropdownMenuProps = () => {
const isMobile = useViewportMatch( 'medium', '<' );
Expand All @@ -60,7 +53,7 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
<>
{ Object.entries( fieldsList ).map( ( [ name, fields ], i ) => (
<Fragment key={ name }>
<DropdownMenuGroup>
<DropdownMenuV2.Group>
{ Object.keys( fieldsList ).length > 1 && (
<Text
className="block-editor-bindings__source-label"
Expand All @@ -72,7 +65,7 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
</Text>
) }
{ Object.entries( fields ).map( ( [ key, value ] ) => (
<DropdownMenuRadioItem
<DropdownMenuV2.RadioItem
key={ key }
onChange={ () =>
updateBlockBindings( {
Expand All @@ -86,17 +79,17 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
value={ key }
checked={ key === currentKey }
>
<DropdownMenuItemLabel>
<DropdownMenuV2.ItemLabel>
{ key }
</DropdownMenuItemLabel>
<DropdownMenuItemHelpText>
</DropdownMenuV2.ItemLabel>
<DropdownMenuV2.ItemHelpText>
{ value }
</DropdownMenuItemHelpText>
</DropdownMenuRadioItem>
</DropdownMenuV2.ItemHelpText>
</DropdownMenuV2.RadioItem>
) ) }
</DropdownMenuGroup>
</DropdownMenuV2.Group>
{ i !== Object.keys( fieldsList ).length - 1 && (
<DropdownMenuSeparator />
<DropdownMenuV2.Separator />
) }
</Fragment>
) ) }
Expand Down Expand Up @@ -162,7 +155,7 @@ function EditableBlockBindingsPanelItems( {
} );
} }
>
<DropdownMenu
<DropdownMenuV2
placement={
isMobile ? 'bottom-start' : 'left-start'
}
Expand All @@ -182,7 +175,7 @@ function EditableBlockBindingsPanelItems( {
attribute={ attribute }
binding={ binding }
/>
</DropdownMenu>
</DropdownMenuV2>
</ToolsPanelItem>
);
} ) }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Internal

- `DropdownMenu` v2: refactor to overloaded naming convention ([#64654](https://github.com/WordPress/gutenberg/pull/64654)).
- `Composite` V2: fix Storybook docgen ([#64682](https://github.com/WordPress/gutenberg/pull/64682)).

## 28.6.0 (2024-08-21)
Expand Down
Loading

0 comments on commit 59bd78f

Please sign in to comment.