Skip to content

Commit

Permalink
Move labels to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Aug 20, 2021
1 parent dddb929 commit 364ce8f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,15 @@
* WordPress dependencies
*/
import { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { BLOCK_SUPPORT_GROUPS } from './constants';
import { store as blockEditorStore } from '../../store';
import { cleanEmptyObject } from '../../hooks/utils';

const labels = {
border: {
label: __( 'Border options' ),
header: __( 'Border' ),
},
color: {
label: __( 'Color options' ),
header: __( 'Color' ),
},
dimensions: {
label: __( 'Dimensions options' ),
header: __( 'Dimensions' ),
},
typography: {
label: __( 'Typography options' ),
header: __( 'Typography' ),
},
};

export default function BlockSupportToolsPanel( { group, children } ) {
const { clientId, attributes } = useSelect( ( select ) => {
const { getBlockAttributes, getSelectedBlockClientId } = select(
Expand Down Expand Up @@ -66,8 +47,8 @@ export default function BlockSupportToolsPanel( { group, children } ) {

return (
<ToolsPanel
label={ labels[ group ].label }
header={ labels[ group ].header }
label={ BLOCK_SUPPORT_GROUPS[ group ].label }
header={ BLOCK_SUPPORT_GROUPS[ group ].header }
resetAll={ resetAll }
>
{ children }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

export const BLOCK_SUPPORT_GROUPS = {
border: {
label: __( 'Border options' ),
header: __( 'Border' ),
},
color: {
label: __( 'Color options' ),
header: __( 'Color' ),
},
dimensions: {
label: __( 'Dimensions options' ),
header: __( 'Dimensions' ),
},
typography: {
label: __( 'Typography options' ),
header: __( 'Typography' ),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import warning from '@wordpress/warning';
/**
* Internal dependencies
*/
import { BLOCK_SUPPORT_GROUPS } from './constants';
import BlockSupportToolsPanel from './block-support-tools-panel';
import groups from './groups';

const blockSupportGroups = [ 'border', 'color', 'dimensions', 'typography' ];

export default function InspectorControlsSlot( {
__experimentalGroup: group = 'default',
bubblesVirtually = true,
Expand All @@ -29,7 +28,7 @@ export default function InspectorControlsSlot( {
return null;
}

if ( blockSupportGroups.includes( group ) ) {
if ( BLOCK_SUPPORT_GROUPS[ group ] ) {
return (
<BlockSupportToolsPanel group={ group }>
<Slot { ...props } bubblesVirtually={ bubblesVirtually } />
Expand Down

0 comments on commit 364ce8f

Please sign in to comment.