Skip to content

Commit 84ba81a

Browse files
committed
Add custom block icon
1 parent b73e694 commit 84ba81a

File tree

6 files changed

+53
-31
lines changed

6 files changed

+53
-31
lines changed

package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@wordpress/env": "^5.2.0",
3838
"@wordpress/hooks": "^3.15.0",
3939
"@wordpress/i18n": "^4.15.0",
40-
"@wordpress/icons": "^9.6.0",
40+
"@wordpress/primitives": "^3.16.0",
4141
"@wordpress/scripts": "^23.7.2",
4242
"@wordpress/wordcount": "^3.15.0",
4343
"lodash": "^4.17.21"

src/blocks/shared-block/edit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import {
1414
PanelBody,
1515
Placeholder,
1616
} from '@wordpress/components';
17-
import { share } from '@wordpress/icons';
1817
import { __, sprintf } from '@wordpress/i18n';
1918

2019
/**
2120
* Internal dependencies
2221
*/
2322
import SharedBlocksSelector from './sharedBlocksSelector';
23+
import { default as BlockIcon } from './icon';
2424

2525
import './editor.scss';
2626

@@ -140,7 +140,7 @@ export default function Edit( { attributes, setAttributes } ) {
140140
</div>
141141
) : (
142142
<Placeholder
143-
icon={ share }
143+
icon={ BlockIcon }
144144
label="Bloc partagé"
145145
instructions={ getPlaceholderLabel( display ) }
146146
className={ 'shared-block-placeholder' }

src/blocks/shared-block/icon.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { SVG, Path } from '@wordpress/primitives';
5+
6+
const MultisiteSharedBlockIcon = (
7+
<SVG
8+
xmlns="http://www.w3.org/2000/svg"
9+
width="24"
10+
height="24"
11+
fill="none"
12+
viewBox="0 0 24 24"
13+
>
14+
<Path
15+
fill="#000"
16+
fill-rule="evenodd"
17+
d="M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z"
18+
clip-rule="evenodd"
19+
/>
20+
</SVG>
21+
);
22+
23+
export default MultisiteSharedBlockIcon;

src/blocks/shared-block/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { registerBlockType } from '@wordpress/blocks';
33
import './style.scss';
44

55
import Edit from './edit';
6+
import { default as BlockIcon } from './icon';
67

78
registerBlockType( 'multisite-shared-blocks/shared-block', {
8-
/**
9-
* @see ./edit.js
10-
*/
9+
icon: BlockIcon,
1110
edit: Edit,
1211
} );

src/hooks/sharedBlockIdControls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { isEmpty } from 'lodash';
99
import { createHigherOrderComponent } from '@wordpress/compose';
1010
import { InspectorControls } from '@wordpress/block-editor';
1111
import { PanelBody, TextControl, ToggleControl } from '@wordpress/components';
12-
import { share } from '@wordpress/icons';
1312
import { count } from '@wordpress/wordcount';
1413
import { __, sprintf } from '@wordpress/i18n';
1514
import { createInterpolateElement } from '@wordpress/element';
@@ -18,6 +17,7 @@ import { createInterpolateElement } from '@wordpress/element';
1817
* Internal dependencies
1918
*/
2019
import { blockSupportSharing } from './helper';
20+
import { default as BlockIcon } from '../blocks/shared-block/icon';
2121

2222
/**
2323
* Custom wrapper component use to render the UI for sharing a block.
@@ -69,7 +69,7 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
6969
'Multisite sharing options',
7070
'multisite-shared-blocks'
7171
) }
72-
icon={ share }
72+
icon={ BlockIcon }
7373
>
7474
<ToggleControl
7575
label={ __(

0 commit comments

Comments
 (0)