Skip to content

Commit

Permalink
Move html element help messages to the block library utils. (#68708)
Browse files Browse the repository at this point in the history
* Move html element help messages to the block library utils.

* Make help message for the div element more generic.

Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
  • Loading branch information
3 people authored Jan 16, 2025
1 parent a89831f commit ba9f079
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import { SelectControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { htmlElementMessages } from '../../utils/messages';

export default function CommentsInspectorControls( {
attributes: { tagName },
setAttributes,
} ) {
const htmlElementMessages = {
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
};
return (
<InspectorControls>
<InspectorControls group="advanced">
Expand Down
22 changes: 1 addition & 21 deletions packages/block-library/src/cover/edit/inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { COVER_MIN_HEIGHT, mediaPosition } from '../shared';
import { unlock } from '../../lock-unlock';
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
import { htmlElementMessages } from '../../utils/messages';

const { cleanEmptyObject, ResolutionTool } = unlock( blockEditorPrivateApis );

Expand Down Expand Up @@ -183,27 +184,6 @@ export default function CoverInspectorControls( {

const colorGradientSettings = useMultipleOriginColorsAndGradients();

const htmlElementMessages = {
header: __(
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
),
main: __(
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
article: __(
'The <article> element should represent a self-contained, syndicatable portion of the document.'
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
footer: __(
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
),
};

const dropdownMenuProps = useToolsPanelDropdownMenuProps();

return (
Expand Down
21 changes: 1 addition & 20 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { View } from '@wordpress/primitives';
* Internal dependencies
*/
import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
import { htmlElementMessages } from '../utils/messages';

/**
* Render inspector controls for the Group block.
Expand All @@ -29,26 +30,6 @@ import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
* @return {JSX.Element} The control group.
*/
function GroupEditControls( { tagName, onSelectTagName } ) {
const htmlElementMessages = {
header: __(
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
),
main: __(
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
article: __(
'The <article> element should represent a self-contained, syndicatable portion of the document.'
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
footer: __(
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
),
};
return (
<InspectorControls group="advanced">
<SelectControl
Expand Down
12 changes: 1 addition & 11 deletions packages/block-library/src/query/edit/query-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import QueryInspectorControls from './inspector-controls';
import EnhancedPaginationModal from './enhanced-pagination-modal';
import { getQueryContextFromTemplate } from '../utils';
import QueryToolbar from './query-toolbar';
import { htmlElementMessages } from '../../utils/messages';

const DEFAULTS_POSTS_PER_PAGE = 3;

Expand Down Expand Up @@ -132,17 +133,6 @@ export default function QueryContent( {
setAttributes( {
displayLayout: { ...displayLayout, ...newDisplayLayout },
} );
const htmlElementMessages = {
main: __(
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
};

return (
<>
Expand Down
7 changes: 1 addition & 6 deletions packages/block-library/src/separator/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import useDeprecatedOpacity from './use-deprecated-opacity';

const htmlElementMessages = {
div: __(
'The <div> element should only be used if the separator is a design element that should not be announced.'
),
};
import { htmlElementMessages } from '../utils/messages';

export default function SeparatorEdit( { attributes, setAttributes } ) {
const { backgroundColor, opacity, style, tagName } = attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,7 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import { TemplatePartImportControls } from './import-controls';

const htmlElementMessages = {
header: __(
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
),
main: __(
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
article: __(
'The <article> element should represent a self-contained, syndicatable portion of the document.'
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
footer: __(
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
),
};
import { htmlElementMessages } from '../../utils/messages';

export function TemplatePartAdvancedControls( {
tagName,
Expand Down
31 changes: 31 additions & 0 deletions packages/block-library/src/utils/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

export const htmlElementMessages = {
article: __(
'The <article> element should represent a self-contained, syndicatable portion of the document.'
),
aside: __(
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
),
div: __(
'The <div> element should only be used if the block is a design element with no semantic meaning.'
),
footer: __(
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
),
header: __(
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
),
main: __(
'The <main> element should be used for the primary content of your document only.'
),
nav: __(
'The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
),
};

0 comments on commit ba9f079

Please sign in to comment.