Adds SVG Icon to Tainacan category on gutenberg blocks menu.

This commit is contained in:
mateuswetah 2020-04-29 17:54:16 -03:00
parent b08ea80ccf
commit abde800658
3 changed files with 66 additions and 1 deletions

View File

@ -30,6 +30,7 @@ function tainacan_blocks_add_gutenberg_blocks_actions() {
add_action('init', 'tainacan_blocks_add_plugin_settings');
add_filter('block_categories', 'tainacan_blocks_register_categories', 10, 2);
add_action('init', 'tainacan_blocks_register_category_icon');
}
function tainacan_blocks_register_categories($categories, $post){
@ -367,3 +368,13 @@ function tainacan_blocks_get_common_styles() {
array('wp-edit-blocks')
);
}
function tainacan_blocks_register_category_icon() {
global $TAINACAN_BASE_URL;
wp_enqueue_script(
'tainacan-blocks-register-category-icon',
$TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_category_icon.js',
array('wp-blocks')
);
}

View File

@ -0,0 +1,53 @@
( function() {
var el = wp.element.createElement;
var SVG = wp.primitives.SVG;
var path4 = el( 'path', {
d: 'm 11.27478,8.73457 c 1.688519,0.44936 3.333166,1.08401 4.86423,1.92899 C 17.304261,9.35093 18.355283,7.77611 18.494128,5.97784 18.606604,4.68205 18.01681,3.38652 17.0326,2.55334 16.089243,1.69008 14.73247,1.35339 13.487742,1.61188 11.913591,1.91741 10.544771,2.85442 9.3686674,3.90688 10.203337,5.42539 10.830349,7.06078 11.27478,8.73457 Z',
fill: '#a5cdd7',
'stroke-width': '0.10421441'
} );
var path6 = el( 'path', {
d: 'm 3.5149247,13.04091 c -0.5624592,1.90814 -0.6353706,3.39919 -0.6353706,4.12908 0.7186979,0 2.2185893,-0.073 4.1351172,-0.63604 C 6.4105484,16.06473 5.7855936,15.5121 5.1606389,14.86563 4.5148523,14.24001 3.9732249,13.62482 3.5149247,13.04091 Z',
fill: '#7eb8c5',
'stroke-width': '0.10421441'
} );
var path8 = el( 'path', {
d: 'M 5.8168414,8.09852 C 6.8215597,6.56512 8.0188478,5.1569 9.3686674,3.91731 8.5297232,2.4271 7.4026813,0.96168 5.7810893,0.28584 4.58159,-0.22797 3.1675523,-0.04964 2.0663954,0.62209 0.92867872,1.26113 0.19971131,2.4895 0.06863414,3.77612 -0.13858888,5.62222 0.46606606,7.44579 1.23384,9.09951 1.0651187,8.75778 1.7833517,8.82097 2.0003231,8.67455 3.2414236,8.32179 4.5283868,8.14061 5.8168414,8.09852 Z',
fill: '#a5cdd7',
'stroke-width': '0.10421441'
} );
var path10 = el( 'path', {
d: 'm 16.13901,10.66356 c -1.249149,1.3653 -2.67355,2.5697 -4.218445,3.58688 -0.06202,1.5577 -0.310603,3.11914 -0.843688,4.58787 -0.37182,-0.15288 0.329219,0.15846 0.448759,0.20875 1.660074,0.69791 3.525206,1.21087 5.323239,0.78852 1.262782,-0.28388 2.330378,-1.22057 2.820096,-2.41411 0.535186,-1.16136 0.465064,-2.56242 -0.169187,-3.67073 -0.750803,-1.35882 -2.035466,-2.33364 -3.360774,-3.08718 z',
fill: '#a5cdd7',
'stroke-width': '0.10421441'
} );
var path12 = el( 'path', {
d: 'm 1.1817604,8.94311 c 0.5559379,1.47805 1.3636245,2.85447 2.3331643,4.0978 0.5011915,-1.75438 1.3032057,-3.41792 2.3019167,-4.94239 -1.5733879,0.0545 -3.1521005,0.3044 -4.635081,0.84459 z',
fill: '#7eb8c5',
'stroke-width': '0.10421441'
} );
var path14 = el( 'path', {
d: 'M 11.27478,8.73457 C 9.4936359,8.26776 7.6479688,8.03766 5.8064254,8.0881 4.8150842,9.6169 4.0070258,11.27568 3.5045088,13.03048 c 0.884194,1.1273 1.9090682,2.14007 2.990078,3.07711 0.2863716,0.30027 0.6037275,0.52578 1.000007,0.26756 1.5571457,-0.50924 3.0386822,-1.23846 4.4155572,-2.12471 0.07412,-1.8572 -0.162523,-3.72061 -0.635371,-5.51587 z',
fill: '#57a2b1',
'stroke-width': '0.10421441'
} );
var path16 = el( 'path', {
d: 'M 11.27478,8.73457 C 10.962303,7.53547 10.514417,6.26338 9.8894631,4.9183 9.7228085,4.56378 9.545738,4.21969 9.3686674,3.90688 9.1603492,4.09457 8.9624469,4.29268 8.7541286,4.49079 7.5458828,5.70032 6.577203,6.92028 5.8168414,8.0881 7.3583964,8.0464 9.2020128,8.19237 11.27478,8.73457 Z',
fill: '#7eb8c5',
'stroke-width': '0.10421441'
} );
var path18 = el( 'path', {
d: 'm 11.920565,14.25044 c -1.514496,0.987 -3.1645362,1.78138 -4.9058937,2.27308 1.2327086,0.96216 2.5971002,1.76354 4.0622057,2.31479 0.522219,-1.47166 0.784125,-3.02968 0.843688,-4.58787 z',
fill: '#7eb8c5',
'stroke-width': '0.10421441'
} );
var path20 = el( 'path', {
d: 'm 15.545303,11.28918 c 0.17414,-0.20567 0.492354,-0.44146 0.562428,-0.64318 -1.504933,-0.82786 -3.118912,-1.45272 -4.776742,-1.89667 -0.114463,0.006 0.05623,0.30009 0.05428,0.4239 0.398631,1.65875 0.593032,3.37096 0.524879,5.07721 1.318664,-0.84526 2.528852,-1.85373 3.635153,-2.96126 z',
fill: '#7eb8c5',
'stroke-width': '0.10421441'
} );
var g1 = el('g', { transform: 'translate(-85.490815,-209.14412)' });
var g2 = el('g', { transform: 'translate(-85.490815,-209.14412)' });
var svgIcon = el( SVG, { width: 20, height: 20, viewBox: '0 0 20 20'}, path4, path6, path8, path10, path12, path14, path16, path18, path20, g1, g2);
wp.blocks.updateCategory( 'tainacan-blocks', { icon: svgIcon } );
} )();

View File

@ -33,8 +33,9 @@ module.exports = {
block_faceted_search: './src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js',
block_carousel_terms_list: './src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/index.js',
block_carousel_terms_list_theme: './src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-list-theme.js'
block_carousel_terms_list_theme: './src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-list-theme.js',
tainacan_blocks_category_icon: './src/views/gutenberg-blocks/tainacan-blocks-category-icon.js'
},
output: {
path: path.resolve(__dirname, './src/assets/js/'),