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

Add reusable block icon. #23552

Merged
merged 8 commits into from
Sep 3, 2020
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 @@ -66,7 +66,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
/>
</svg>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
}

.components-menu-group + .components-menu-group {
padding: $grid-unit-10 $grid-unit-15;
margin-left: -$grid-unit-15;
margin-right: -$grid-unit-15;
padding: $grid-unit-10;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
/>
</SVG>
}
Expand All @@ -380,10 +380,10 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
>
<path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
/>
</Path>
</svg>
Expand Down
11 changes: 4 additions & 7 deletions packages/components/src/dropdown-menu/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
.components-menu-item__button.components-button {
min-height: $button-size;
height: auto;
padding-left: $button-size-small + $grid-unit-10 + $grid-unit-10;
text-align: left;
padding-left: $grid-unit-10;
padding-right: $grid-unit-10;

&.has-icon {
padding-left: $grid-unit-10;
.components-menu-item__info-wrapper {
max-width: calc(100% - #{ $button-size-small + $grid-unit-10 });
}
}

Expand Down Expand Up @@ -87,7 +88,3 @@
}
}
}

.components-dropdown-menu__menu.no-icons .components-menu-item__button.components-button {
padding: 0 $grid-unit-15;
}
3 changes: 2 additions & 1 deletion packages/components/src/menu-group/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
}

.components-menu-group__label {
padding: 0;
padding: 0 $grid-unit-10;
margin-top: $grid-unit-05;
margin-bottom: $grid-unit-15;
color: $gray-700;
text-transform: uppercase;
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { cloneElement, forwardRef } from '@wordpress/element';
*/
import Shortcut from '../shortcut';
import Button from '../button';
import Icon from '../icon';

/**
* Renders a generic menu item for use inside the more menu.
Expand Down Expand Up @@ -63,7 +64,6 @@ export function MenuItem(
return (
<Button
ref={ ref }
icon={ icon }
// Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
aria-checked={
role === 'menuitemcheckbox' || role === 'menuitemradio'
Expand All @@ -79,6 +79,7 @@ export function MenuItem(
className="components-menu-item__shortcut"
shortcut={ shortcut }
/>
{ icon && <Icon icon={ icon } /> }
</Button>
);
}
Expand Down
15 changes: 6 additions & 9 deletions packages/components/src/menu-item/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
.components-menu-item__button.components-button {
width: 100%;

// Target plugin icons that can have arbitrary classes by using an aggressive selector.
// @todo: is this still necessary?
.dashicon,
.components-menu-items__item-icon,
svg.components-menu-items__item-icon,
> span > svg {
margin-right: $grid-unit-10;
}

.components-menu-items__item-icon {
margin-right: -2px; // This optically balances the icon.
margin-left: auto;
display: inline-block;
flex: 0 0 auto;
}

.components-menu-item__shortcut + .components-menu-items__item-icon {
margin-left: $grid-unit-10;
}
}

.components-menu-item__info-wrapper {
Expand Down
48 changes: 26 additions & 22 deletions packages/components/src/menu-item/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `
<ForwardRef(Button)
aria-checked={true}
className="components-menu-item__button my-class"
icon={
<SVG
className="components-menu-items__item-icon"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M4 9v1.5h16V9H4zm12 5.5h4V13h-4v1.5zm-6 0h4V13h-4v1.5zm-6 0h4V13H4v1.5z"
/>
</SVG>
}
onClick={[Function]}
role="menuitemcheckbox"
>
Expand All @@ -23,6 +12,19 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `
className="components-menu-item__shortcut"
shortcut="mod+shift+alt+w"
/>
<Icon
icon={
<SVG
className="components-menu-items__item-icon"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M4 9v1.5h16V9H4zm12 5.5h4V13h-4v1.5zm-6 0h4V13h-4v1.5zm-6 0h4V13H4v1.5z"
/>
</SVG>
}
/>
</ForwardRef(Button)>
`;

Expand Down Expand Up @@ -50,17 +52,6 @@ exports[`MenuItem should match snapshot when info is provided 1`] = `
exports[`MenuItem should match snapshot when isSelected and role are optionally provided 1`] = `
<ForwardRef(Button)
className="components-menu-item__button my-class"
icon={
<SVG
className="components-menu-items__item-icon"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M4 9v1.5h16V9H4zm12 5.5h4V13h-4v1.5zm-6 0h4V13h-4v1.5zm-6 0h4V13H4v1.5z"
/>
</SVG>
}
onClick={[Function]}
role="menuitem"
>
Expand All @@ -69,6 +60,19 @@ exports[`MenuItem should match snapshot when isSelected and role are optionally
className="components-menu-item__shortcut"
shortcut="mod+shift+alt+w"
/>
<Icon
icon={
<SVG
className="components-menu-items__item-icon"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M4 9v1.5h16V9H4zm12 5.5h4V13h-4v1.5zm-6 0h4V13h-4v1.5zm-6 0h4V13H4v1.5z"
/>
</SVG>
}
/>
</ForwardRef(Button)>
`;

Expand Down
6 changes: 2 additions & 4 deletions packages/components/src/menu-items-choice/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
.components-menu-items-choice,
.components-menu-items-choice.components-button {
padding-left: $button-size-small + $grid-unit-10 + $grid-unit-10;

svg {
margin-right: $grid-unit-10;
margin-right: $grid-unit-15;
}

&.has-icon {
padding-left: $grid-unit-10;
padding-left: $grid-unit-15;
}
}
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/device-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default function DevicePreview() {
forcePreviewLink={ isSaving ? null : undefined }
textContent={
<>
<Icon icon={ external } />
{ __( 'Preview in new tab' ) }
<Icon icon={ external } />
</>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
justify-content: flex-start;

svg {
margin-right: $grid-unit-10;
margin-left: auto;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox and a confirmation
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
/>
</svg>
</span>
Expand Down Expand Up @@ -90,7 +90,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox when custom fields
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"
d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
/>
</svg>
</span>
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { __ } from '@wordpress/i18n';
import { registerPlugin } from '@wordpress/plugins';
import { addQueryArgs } from '@wordpress/url';
import apiFetch from '@wordpress/api-fetch';
import { download } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -24,7 +25,7 @@ registerPlugin( 'edit-site', {
<ToolsMoreMenuGroup>
<MenuItem
role="menuitem"
icon="download"
icon={ download }
onClick={ () =>
apiFetch( {
path: '/__experimental/edit-site/v1/export',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { hasBlockSupport, isReusableBlock } from '@wordpress/blocks';
import { BlockSettingsMenuControls } from '@wordpress/block-editor';
import { MenuItem } from '@wordpress/components';
import { reusableBlock } from '@wordpress/icons';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -68,6 +69,7 @@ export default function ReusableBlockConvertButton( { clientIds } ) {
<BlockSettingsMenuControls>
{ ( { onClose } ) => (
<MenuItem
icon={ reusableBlock }
onClick={ () => {
convertBlockToReusable( clientIds );
onClose();
Expand Down
4 changes: 3 additions & 1 deletion packages/icons/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { default as audio } from './library/audio';
export { default as backup } from './library/backup';
export { default as blockDefault } from './library/block-default';
export { default as blockTable } from './library/block-table';
export { default as box } from './library/box';
export { default as brush } from './library/brush';
export { default as button } from './library/button';
export { default as calendar } from './library/calendar';
Expand Down Expand Up @@ -50,6 +51,7 @@ export { default as currencyEuro } from './library/currency-euro';
export { default as currencyPound } from './library/currency-pound';
export { default as desktop } from './library/desktop';
export { default as dragHandle } from './library/drag-handle';
export { default as download } from './library/download';
export { default as edit } from './library/edit';
export { default as external } from './library/external';
export { default as file } from './library/file';
Expand Down Expand Up @@ -128,7 +130,6 @@ export { default as postFeaturedImage } from './library/post-featured-image';
export { default as postList } from './library/post-list';
export { default as postTitle } from './library/post-title';
export { default as preformatted } from './library/preformatted';
export { default as box } from './library/box';
export { default as pullLeft } from './library/pull-left';
export { default as pullRight } from './library/pull-right';
export { default as pullquote } from './library/pullquote';
Expand All @@ -137,6 +138,7 @@ export { default as receipt } from './library/receipt';
export { default as redo } from './library/redo';
export { default as replace } from './library/replace';
export { default as resizeCornerNE } from './library/resize-corner-n-e';
export { default as reusableBlock } from './library/reusable-block';
export { default as rotateLeft } from './library/rotate-left';
export { default as rotateRight } from './library/rotate-right';
export { default as rss } from './library/rss';
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/library/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SVG, Path } from '@wordpress/primitives';

const check = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z" />
<Path d="M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z" />
</SVG>
);

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

const download = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" />
</SVG>
);

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

const reusableBlock = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Path d="M7 7.2h8.2L13.5 9l1.1 1.1 3.6-3.6-3.5-4-1.1 1 1.9 2.3H7c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.2-.5zm13.8 4V11h-1.5v.3c0 1.1 0 3.5-1 4.5-.3.3-.7.5-1.3.5H8.8l1.7-1.7-1.1-1.1L5.9 17l3.5 4 1.1-1-1.9-2.3H17c.9 0 1.7-.3 2.3-.9 1.5-1.4 1.5-4.2 1.5-5.6z" />
</SVG>
);

export default reusableBlock;