Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Site Tagline placeholder attribute, move example to block.json #48383

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ Describe in a few words what the site is about. The tagline can be used in searc
- **Name:** core/site-tagline
- **Category:** theme
- **Supports:** align (full, wide), anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** placeholder, textAlign
- **Attributes:** textAlign

## Site Title

Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/site-tagline/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
"keywords": [ "description" ],
"textdomain": "default",
"attributes": {
"placeholder": {
"type": "string"
},
"textAlign": {
"type": "string"
}
},
"example": {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this the new canonical way to set block examples or are they only added to block.json for certain cases? All the ones I can see in trunk seem to be dynamic blocks.

Copy link
Contributor Author

@andrewserong andrewserong Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! I wasn't too sure what's the preferred approach, they both seem to work, and I was mostly copying from the example over in #48326. However, the reason I'd included example in index.js originally is that we can wrap any strings in translation calls, so that might be a reason why many of them use index.js instead (e.g. Buttons block's example has strings for the text attribute, etc)

@ntsekouras do you have a preference for where example goes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is better to have properties in block.json, when we can. There have been a lot of work from @gziolo in this area.

Copy link
Member

@gziolo gziolo Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't express everything in block.json with the example field, e.g. translatable strings. I don't know whether I have a preference here.

"supports": {
"anchor": true,
"align": [ "wide", "full" ],
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/site-tagline/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function SiteTaglineEdit( {
setAttributes,
insertBlocksAfter,
} ) {
const { placeholder, textAlign } = attributes;
const { textAlign } = attributes;
const { canUserEdit, tagline } = useSelect( ( select ) => {
const { canUser, getEntityRecord, getEditedEntityRecord } =
select( coreStore );
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function SiteTaglineEdit( {
allowedFormats={ [] }
onChange={ setTagline }
aria-label={ __( 'Site tagline text' ) }
placeholder={ placeholder || __( 'Write site tagline…' ) }
placeholder={ __( 'Write site tagline…' ) }
tagName="p"
value={ tagline }
disableLineBreaks
Expand Down
10 changes: 0 additions & 10 deletions packages/block-library/src/site-tagline/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
Expand All @@ -18,11 +13,6 @@ export { metadata, name };
export const settings = {
icon,
edit,
example: {
attributes: {
placeholder: __( 'A site tagline.' ),
},
},
deprecated,
};

Expand Down