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

Blocks: Use cite instead of footer for the pullquote block's markup #3851

Merged
merged 1 commit into from
Dec 8, 2017
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 blocks/library/pullquote/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

.wp-block-pullquote {
footer .blocks-editable__tinymce[data-is-empty="true"]:before {
cite .blocks-editable__tinymce[data-is-empty="true"]:before {
font-size: 14px;
font-family: $default-font;
}
Expand Down
71 changes: 49 additions & 22 deletions blocks/library/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ const toEditableValue = value => map( value, ( subValue => subValue.children ) )
const fromEditableValue = value => map( value, ( subValue ) => ( {
children: subValue,
} ) );
const blockAttributes = {
value: {
type: 'array',
source: 'query',
selector: 'blockquote > p',
query: {
children: {
source: 'node',
},
},
},
citation: {
type: 'array',
source: 'children',
selector: 'cite',
},
align: {
type: 'string',
default: 'none',
},
};

registerBlockType( 'core/pullquote', {

Expand All @@ -33,27 +54,7 @@ registerBlockType( 'core/pullquote', {

category: 'formatting',

attributes: {
value: {
type: 'array',
source: 'query',
selector: 'blockquote > p',
query: {
children: {
source: 'node',
},
},
},
citation: {
type: 'array',
source: 'children',
selector: 'footer',
},
align: {
type: 'string',
default: 'none',
},
},
attributes: blockAttributes,

getEditWrapperProps( attributes ) {
const { align } = attributes;
Expand Down Expand Up @@ -123,9 +124,35 @@ registerBlockType( 'core/pullquote', {
<p key={ i }>{ paragraph.children && paragraph.children.props.children }</p>
) }
{ citation && citation.length > 0 && (
<footer>{ citation }</footer>
<cite>{ citation }</cite>
) }
</blockquote>
);
},

deprecated: [ {
attributes: {
...blockAttributes,
citation: {
type: 'array',
source: 'children',
selector: 'footer',
},
},

save( { attributes } ) {
const { value, citation, align } = attributes;

return (
<blockquote className={ `align${ align }` }>
{ value && value.map( ( paragraph, i ) =>
<p key={ i }>{ paragraph.children && paragraph.children.props.children }</p>
) }
{ citation && citation.length > 0 && (
<footer>{ citation }</footer>
) }
</blockquote>
);
},
} ],
} );
4 changes: 2 additions & 2 deletions blocks/library/pullquote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
line-height: 1.6;
}

footer {
cite {
color: $dark-gray-600;
position: relative;
font-weight: 900;
text-transform: uppercase;
font-size: 13px;
}

footer p {
cite p {
font-family: $default-font;
}
}
4 changes: 2 additions & 2 deletions blocks/library/quote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
margin: 0 0 16px;
box-shadow: inset 0px 0px 0px 0px $light-gray-500;

footer {
cite {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change caused a visual regression in the editor, since the citation Editable's tagName wasn't updated to cite. Possible fix: #4013

Copy link
Member

Choose a reason for hiding this comment

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

The CSS selector should have been:

cite,
footer {}

... in any case, to not break compat.

Copy link
Member

Choose a reason for hiding this comment

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

@jasmussen @karmatosed does this make sense to you?

Copy link
Member

Choose a reason for hiding this comment

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

To me it does 👍

color: $dark-gray-100;
margin-top: 1em;
position: relative;
Expand All @@ -17,7 +17,7 @@
font-style: italic;
line-height: 1.6;
}
footer {
cite {
font-size: 19px;
text-align: right;
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__pullquote.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:core/pullquote -->
<blockquote class="wp-block-pullquote alignnone">
<p>Testing pullquote block...</p><footer>...with a caption</footer>
<p>Testing pullquote block...</p><cite>...with a caption</cite>
</blockquote>
<!-- /wp:core/pullquote -->
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__pullquote.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
],
"align": "none"
},
"originalContent": "<blockquote class=\"wp-block-pullquote alignnone\">\n<p>Testing pullquote block...</p><footer>...with a caption</footer>\n</blockquote>"
"originalContent": "<blockquote class=\"wp-block-pullquote alignnone\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>"
}
]
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__pullquote.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/pullquote",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-pullquote alignnone\">\n<p>Testing pullquote block...</p><footer>...with a caption</footer>\n</blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-pullquote alignnone\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>\n"
},
{
"attrs": {},
Expand Down
4 changes: 1 addition & 3 deletions blocks/test/fixtures/core__pullquote.serialized.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote alignnone">
<p>Testing pullquote block...</p>
<footer>...with a caption</footer>
</blockquote>
<p>Testing pullquote block...</p><cite>...with a caption</cite></blockquote>
<!-- /wp:pullquote -->
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__pullquote__multi-paragraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<blockquote class="wp-block-pullquote alignnone">
<p>Paragraph <strong>one</strong></p>
<p>Paragraph two</p>
<footer>by whomever</footer>
<cite>by whomever</cite>
</blockquote>
<!-- /wp:core/pullquote -->
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__pullquote__multi-paragraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
],
"align": "none"
},
"originalContent": "<blockquote class=\"wp-block-pullquote alignnone\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <footer>by whomever</footer>\n</blockquote>"
"originalContent": "<blockquote class=\"wp-block-pullquote alignnone\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/pullquote",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-pullquote alignnone\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <footer>by whomever</footer>\n</blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-pullquote alignnone\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote alignnone">
<p>Paragraph <strong>one</strong></p>
<p>Paragraph two</p>
<footer>by whomever</footer>
</blockquote>
<p>Paragraph two</p><cite>by whomever</cite></blockquote>
<!-- /wp:pullquote -->
2 changes: 1 addition & 1 deletion phpunit/fixtures/long-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h2>Media Rich</h2>
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote alignnone">
<p>Code is Poetry</p>
<footer>The WordPress community</footer>
<cite>The WordPress community</cite>
</blockquote>
<!-- /wp:pullquote -->
<!-- wp:paragraph {"align":"center"} -->
Expand Down
2 changes: 1 addition & 1 deletion post-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ window._wpGutenbergPost.content = {
'<!-- /wp:paragraph -->',

'<!-- wp:pullquote -->',
'<blockquote class="wp-block-pullquote alignnone"><p>Code is Poetry</p><footer>The WordPress community</footer></blockquote>',
'<blockquote class="wp-block-pullquote alignnone"><p>Code is Poetry</p><cite>The WordPress community</cite></blockquote>',
'<!-- /wp:pullquote -->',

'<!-- wp:paragraph {"align":"center"} -->',
Expand Down