From 577ac7b99cb0c5136030a07a5dc5ec41584e1687 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:12:05 -0500 Subject: [PATCH 1/5] [not verified] feat: Enable Jetpack collection for native block inserter The native editor now displays collections within the block inserter. Specifically, a collection of Jetpack blocks is displayed with "Jetpack powered" badge within the inserter. --- .../shared/block-category.native.js | 28 +++++++++++++++++++ .../jetpack/extensions/shared/icons.js | 26 +++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 projects/plugins/jetpack/extensions/shared/block-category.native.js diff --git a/projects/plugins/jetpack/extensions/shared/block-category.native.js b/projects/plugins/jetpack/extensions/shared/block-category.native.js new file mode 100644 index 0000000000000..5cc4576477c23 --- /dev/null +++ b/projects/plugins/jetpack/extensions/shared/block-category.native.js @@ -0,0 +1,28 @@ +import { getCategories, setCategories, registerBlockCollection } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; +import { JetpackLogo, JetpackPoweredBadge } from './icons'; + +registerBlockCollection( 'jetpack', { + title: 'Jetpack', + icon: , +} ); + +setCategories( [ + ...getCategories().filter( ( { slug } ) => slug !== 'earn' ), + // Add a Earn block category + { + slug: 'earn', + title: __( 'Earn', 'jetpack' ), + icon: , + }, +] ); + +setCategories( [ + ...getCategories().filter( ( { slug } ) => slug !== 'grow' ), + // Add a Grow block category + { + slug: 'grow', + title: __( 'Grow', 'jetpack' ), + icon: , + }, +] ); diff --git a/projects/plugins/jetpack/extensions/shared/icons.js b/projects/plugins/jetpack/extensions/shared/icons.js index 0426722b046f3..684f361d19902 100644 --- a/projects/plugins/jetpack/extensions/shared/icons.js +++ b/projects/plugins/jetpack/extensions/shared/icons.js @@ -237,6 +237,32 @@ export const JetpackLogo = ( { size = 24, border = 0, className, color = COLOR_J ); }; +export const JetpackPoweredBadge = () => { + return ( + + + + + + + ); +}; + export const LoomIcon = { foreground: getIconColor(), src: ( From e6d5b756860860da652f2464a8c4e5e865fe89d2 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Wed, 13 Jul 2022 10:22:03 -0500 Subject: [PATCH 2/5] [not verified] changelog --- .../changelog/enable-jetpack-collection-for-native-inserter | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/enable-jetpack-collection-for-native-inserter diff --git a/projects/plugins/jetpack/changelog/enable-jetpack-collection-for-native-inserter b/projects/plugins/jetpack/changelog/enable-jetpack-collection-for-native-inserter new file mode 100644 index 0000000000000..8f7f3f3737b76 --- /dev/null +++ b/projects/plugins/jetpack/changelog/enable-jetpack-collection-for-native-inserter @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Enable Jetpack block collection for the native editor block inserter. From ac908012ab35a59587ac4499023056179be9da10 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Thu, 14 Jul 2022 16:13:08 -0500 Subject: [PATCH 3/5] [not verified] chore: Update JetpackPoweredBadge asset Changes green background to white. --- projects/plugins/jetpack/extensions/shared/icons.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/projects/plugins/jetpack/extensions/shared/icons.js b/projects/plugins/jetpack/extensions/shared/icons.js index 684f361d19902..7739fb98dd332 100644 --- a/projects/plugins/jetpack/extensions/shared/icons.js +++ b/projects/plugins/jetpack/extensions/shared/icons.js @@ -246,18 +246,13 @@ export const JetpackPoweredBadge = () => { fill="none" xmlns="http://www.w3.org/2000/svg" > - - ); From fe810ca5e60073b284b12cd2e2f5a3d07674a9f1 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Thu, 14 Jul 2022 20:03:10 -0500 Subject: [PATCH 4/5] chore: Remove badge including text The collection title is now rendered to make dark mode support easier. --- .../shared/block-category.native.js | 6 +++--- .../jetpack/extensions/shared/icons.js | 21 ------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/projects/plugins/jetpack/extensions/shared/block-category.native.js b/projects/plugins/jetpack/extensions/shared/block-category.native.js index 5cc4576477c23..c73930002193c 100644 --- a/projects/plugins/jetpack/extensions/shared/block-category.native.js +++ b/projects/plugins/jetpack/extensions/shared/block-category.native.js @@ -1,10 +1,10 @@ import { getCategories, setCategories, registerBlockCollection } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; -import { JetpackLogo, JetpackPoweredBadge } from './icons'; +import { JetpackLogo } from './icons'; registerBlockCollection( 'jetpack', { - title: 'Jetpack', - icon: , + title: 'Jetpack powered', + icon: , } ); setCategories( [ diff --git a/projects/plugins/jetpack/extensions/shared/icons.js b/projects/plugins/jetpack/extensions/shared/icons.js index 7739fb98dd332..0426722b046f3 100644 --- a/projects/plugins/jetpack/extensions/shared/icons.js +++ b/projects/plugins/jetpack/extensions/shared/icons.js @@ -237,27 +237,6 @@ export const JetpackLogo = ( { size = 24, border = 0, className, color = COLOR_J ); }; -export const JetpackPoweredBadge = () => { - return ( - - - - - ); -}; - export const LoomIcon = { foreground: getIconColor(), src: ( From 607398844f33d7e4f14984811330bdc070fed1cb Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Fri, 15 Jul 2022 10:43:12 -0500 Subject: [PATCH 5/5] fix: Translate Jetpack collection title Co-authored-by: Jeremy Herve --- .../plugins/jetpack/extensions/shared/block-category.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/extensions/shared/block-category.native.js b/projects/plugins/jetpack/extensions/shared/block-category.native.js index c73930002193c..c4b5fa680d22b 100644 --- a/projects/plugins/jetpack/extensions/shared/block-category.native.js +++ b/projects/plugins/jetpack/extensions/shared/block-category.native.js @@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n'; import { JetpackLogo } from './icons'; registerBlockCollection( 'jetpack', { - title: 'Jetpack powered', + title: __( 'Jetpack powered', 'jetpack' ), icon: , } );