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

Try: Allow space between on menu items. #28169

Merged
merged 8 commits into from
Jan 14, 2021
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 @@ -3,29 +3,21 @@
*/
import { DropdownMenu } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import {
contentJustificationCenterIcon,
contentJustificationLeftIcon,
contentJustificationRightIcon,
} from './icons';
import { justifyLeft, justifyCenter, justifyRight } from '@wordpress/icons';

const DEFAULT_ALLOWED_VALUES = [ 'left', 'center', 'right' ];

const CONTROLS = {
left: {
icon: contentJustificationLeftIcon,
icon: justifyLeft,
title: __( 'Justify content left' ),
},
center: {
icon: contentJustificationCenterIcon,
icon: justifyCenter,
title: __( 'Justify content center' ),
},
right: {
icon: contentJustificationRightIcon,
icon: justifyRight,
title: __( 'Justify content right' ),
},
};
Expand Down
37 changes: 0 additions & 37 deletions packages/block-library/src/buttons/icons.js

This file was deleted.

41 changes: 29 additions & 12 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { upperFirst } from 'lodash';
import classnames from 'classnames';

/**
Expand All @@ -24,7 +23,12 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import useBlockNavigator from './use-block-navigator';
import * as navIcons from './icons';
import {
justifyLeft,
justifyCenter,
justifyRight,
justifySpaceBetween,
} from '@wordpress/icons';
import NavigationPlaceholder from './placeholder';

function Navigation( {
Expand All @@ -38,9 +42,16 @@ function Navigation( {
updateInnerBlocks,
className,
hasSubmenuIndicatorSetting = true,
hasItemJustificationControls = true,
hasItemJustificationControls = attributes.orientation === 'horizontal',
hasListViewModal = true,
} ) {
const navIcons = {
left: justifyLeft,
center: justifyCenter,
right: justifyRight,
'space-between': justifySpaceBetween,
};

const [ isPlaceholderShown, setIsPlaceholderShown ] = useState(
! hasExistingNavItems
);
Expand Down Expand Up @@ -117,37 +128,43 @@ function Navigation( {
<ToolbarGroup
icon={
attributes.itemsJustification
? navIcons[
`justify${ upperFirst(
attributes.itemsJustification
) }Icon`
]
: navIcons.justifyLeftIcon
? navIcons[ attributes.itemsJustification ]
: navIcons.left
}
label={ __( 'Change items justification' ) }
isCollapsed
controls={ [
{
icon: navIcons.justifyLeftIcon,
icon: justifyLeft,
title: __( 'Justify items left' ),
isActive:
'left' === attributes.itemsJustification,
onClick: handleItemsAlignment( 'left' ),
},
{
icon: navIcons.justifyCenterIcon,
icon: justifyCenter,
title: __( 'Justify items center' ),
isActive:
'center' === attributes.itemsJustification,
onClick: handleItemsAlignment( 'center' ),
},
{
icon: navIcons.justifyRightIcon,
icon: justifyRight,
title: __( 'Justify items right' ),
isActive:
'right' === attributes.itemsJustification,
onClick: handleItemsAlignment( 'right' ),
},
{
icon: justifySpaceBetween,
title: __( 'Space between items' ),
isActive:
'space-between' ===
attributes.itemsJustification,
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
onClick: handleItemsAlignment(
'space-between'
),
},
] }
/>
) }
Expand Down
37 changes: 0 additions & 37 deletions packages/block-library/src/navigation/icons.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/block-library/src/navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
.items-justified-right > ul {
justify-content: flex-end;
}

.items-justified-space-between > ul {
justify-content: space-between;
}
3 changes: 2 additions & 1 deletion packages/components/src/dropdown-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { flatMap, isEmpty, isFunction } from 'lodash';
*/
import { DOWN } from '@wordpress/keycodes';
import deprecated from '@wordpress/deprecated';
import { menu } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -37,7 +38,7 @@ function DropdownMenu( {
children,
className,
controls,
icon = 'menu',
icon = menu,
label,
popoverProps,
toggleProps,
Expand Down
4 changes: 4 additions & 0 deletions packages/icons/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export { default as image } from './library/image';
export { default as info } from './library/info';
export { default as insertAfter } from './library/insert-after';
export { default as insertBefore } from './library/insert-before';
export { default as justifyLeft } from './library/justify-left';
export { default as justifyCenter } from './library/justify-center';
export { default as justifyRight } from './library/justify-right';
export { default as justifySpaceBetween } from './library/justify-space-between';
export { default as keyboardClose } from './library/keyboard-close';
export { default as keyboardReturn } from './library/keyboard-return';
export { default as layout } from './library/layout';
Expand Down
12 changes: 12 additions & 0 deletions packages/icons/src/library/justify-center.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { SVG, Path } from '@wordpress/primitives';

const justifyCenter = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z" />
</SVG>
);

export default justifyCenter;
12 changes: 12 additions & 0 deletions packages/icons/src/library/justify-left.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { SVG, Path } from '@wordpress/primitives';

const justifyLeft = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M9 9v6h11V9H9zM4 20h1.5V4H4v16z" />
</SVG>
);

export default justifyLeft;
12 changes: 12 additions & 0 deletions packages/icons/src/library/justify-right.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { SVG, Path } from '@wordpress/primitives';

const justifyRight = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z" />
</SVG>
);

export default justifyRight;
12 changes: 12 additions & 0 deletions packages/icons/src/library/justify-space-between.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { SVG, Path } from '@wordpress/primitives';

const justifySpaceBetween = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z" />
</SVG>
);

export default justifySpaceBetween;
4 changes: 2 additions & 2 deletions packages/icons/src/library/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { SVG, Path } from '@wordpress/primitives';

const menu = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24">
<Path d="M17 7V5H3v2h14zm0 4V9H3v2h14zm0 4v-2H3v2h14z" />
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M5 5.5V7h14V5.5H5zM5 13h14v-1.5H5V13zm0 6h14v-1.5H5V19z" />
</SVG>
);

Expand Down