Skip to content

Commit

Permalink
Add attribute so Nav Editor can hide justify
Browse files Browse the repository at this point in the history
- Adds an additional attribute to showJustifyControls to navigation
block so the Nav Editor screen can hide the controls, since that screen
is intended to create/edit nav menus and not format/style.

- Use 'showJustifyControls' since the positive is easier to reason and
there is already a 'showSubMenuIcon' attribute that also defaults to
true
  • Loading branch information
mkaz committed Apr 13, 2021
1 parent e842f83 commit a3d2818
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/navigation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"showSubmenuIcon": {
"type": "boolean",
"default": true
},
"showJustifyControls": {
"type": "boolean",
"default": true
}
},
"providesContext": {
Expand All @@ -40,6 +44,7 @@
"fontSize": "fontSize",
"customFontSize": "customFontSize",
"showSubmenuIcon": "showSubmenuIcon",
"showJustifyControls": "showJustifyControls",
"style": "style",
"orientation": "orientation"
},
Expand Down
24 changes: 13 additions & 11 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,19 @@ function Navigation( {
return (
<>
<BlockControls>
<JustifyToolbar
value={ attributes.itemsJustification }
allowedControls={ justifyAllowedControls }
onChange={ ( value ) =>
setAttributes( { itemsJustification: value } )
}
popoverProps={ {
position: 'bottom right',
isAlternate: true,
} }
/>
{ attributes.showJustifyControls && (
<JustifyToolbar
value={ attributes.itemsJustification }
allowedControls={ justifyAllowedControls }
onChange={ ( value ) =>
setAttributes( { itemsJustification: value } )
}
popoverProps={ {
position: 'bottom right',
isAlternate: true,
} }
/>
) }
<ToolbarGroup>{ navigatorToolbarButton }</ToolbarGroup>
</BlockControls>
{ navigatorModal }
Expand Down

0 comments on commit a3d2818

Please sign in to comment.