Skip to content

Commit

Permalink
Fix missing titles in general areas (#35657)
Browse files Browse the repository at this point in the history
* Fix general areas don't have names

* Switch to the new template part icon
  • Loading branch information
kevin940726 committed Oct 19, 2021
1 parent bb0c047 commit 5562482
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/template-part/variations.js
Expand Up @@ -7,7 +7,7 @@ import {
header as headerIcon,
footer as footerIcon,
sidebar as sidebarIcon,
layout as layoutIcon,
symbolFilled as symbolFilledIcon,
} from '@wordpress/icons';

/**
Expand All @@ -23,7 +23,7 @@ function getTemplatePartIcon( iconName ) {
} else if ( 'sidebar' === iconName ) {
return sidebarIcon;
}
return layoutIcon;
return symbolFilledIcon;
}

export function enhanceTemplatePartVariations( settings, name ) {
Expand Down
Expand Up @@ -10,6 +10,7 @@ import {
TEMPLATE_PART_AREA_HEADER,
TEMPLATE_PART_AREA_FOOTER,
TEMPLATE_PART_AREA_SIDEBAR,
TEMPLATE_PART_AREA_GENERAL,
} from '../../../store/constants';

export const TEMPLATES_PRIMARY = [
Expand Down Expand Up @@ -101,7 +102,7 @@ export const TEMPLATE_PARTS_SUB_MENUS = [
title: __( 'sidebars' ),
},
{
area: 'uncategorized',
area: TEMPLATE_PART_AREA_GENERAL,
menu: MENU_TEMPLATE_PARTS_GENERAL,
title: __( 'general' ),
},
Expand Down
Expand Up @@ -33,14 +33,19 @@ import { store as noticesStore } from '@wordpress/notices';
import { store as editorStore } from '@wordpress/editor';
import { check } from '@wordpress/icons';

/**
* Internal dependencies
*/
import { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';

export default function ConvertToTemplatePart( { clientIds, blocks } ) {
const instanceId = useInstanceId( ConvertToTemplatePart );
const [ isModalOpen, setIsModalOpen ] = useState( false );
const [ title, setTitle ] = useState( '' );
const { replaceBlocks } = useDispatch( blockEditorStore );
const { saveEntityRecord } = useDispatch( coreStore );
const { createSuccessNotice } = useDispatch( noticesStore );
const [ area, setArea ] = useState( 'uncategorized' );
const [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );

const templatePartAreas = useSelect(
( select ) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/edit-site/src/store/constants.js
Expand Up @@ -13,9 +13,11 @@ export const STORE_NAME = 'core/edit-site';
export const TEMPLATE_PART_AREA_HEADER = 'header';
export const TEMPLATE_PART_AREA_FOOTER = 'footer';
export const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
export const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';

export const TEMPLATE_PART_AREA_TO_NAME = {
[ TEMPLATE_PART_AREA_HEADER ]: __( 'Header' ),
[ TEMPLATE_PART_AREA_FOOTER ]: __( 'Footer' ),
[ TEMPLATE_PART_AREA_SIDEBAR ]: __( 'Sidebar' ),
[ TEMPLATE_PART_AREA_GENERAL ]: __( 'General' ),
};
4 changes: 2 additions & 2 deletions packages/editor/src/utils/get-template-part-icon.js
Expand Up @@ -5,7 +5,7 @@ import {
header as headerIcon,
footer as footerIcon,
sidebar as sidebarIcon,
layout as layoutIcon,
symbolFilled as symbolFilledIcon,
} from '@wordpress/icons';
/**
* Helper function to retrieve the corresponding icon by name.
Expand All @@ -22,5 +22,5 @@ export function getTemplatePartIcon( iconName ) {
} else if ( 'sidebar' === iconName ) {
return sidebarIcon;
}
return layoutIcon;
return symbolFilledIcon;
}

0 comments on commit 5562482

Please sign in to comment.