Skip to content

Commit

Permalink
Add aside wrapper to pullquote (#9599)
Browse files Browse the repository at this point in the history
* Add aside wrapper to pullquote

This is an alternative, per discussion, to #8821.

It adds some semantic value to the pullquote, indicating that it is intended to be separate content.

Note that we should consider doing a few other enhancements to the pullquote, if we intend to keep it:

- Let's add a transformation from Quote to Pullquote and back
- For some reason, the alignment values are not output in the markup in the editor, only on the frontend, which means the max-width we apply does not affect the content.

I could use help with both of these. I also imagine the deprecation handler needs a little extra now. @gziolo do you have bandwidth?

* Figure.

* Fix for frontend.

* Added deprecation artifacts

* Updated test fixtures
  • Loading branch information
jasmussen authored Sep 12, 2018
1 parent 41d4223 commit 4883a7e
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 69 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/pullquote/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
transform: translateX(-50%);
}

& > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
& > .editor-rich-text p {
& blockquote > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
& blockquote > .editor-rich-text p {
font-size: 24px;
line-height: 1.6;
}
Expand Down
69 changes: 43 additions & 26 deletions packages/block-library/src/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,48 +55,65 @@ export const settings = {
const { value, citation } = attributes;

return (
<blockquote className={ className }>
<RichText
multiline="p"
value={ toRichTextValue( value ) }
onChange={
( nextValue ) => setAttributes( {
value: fromRichTextValue( nextValue ),
} )
}
/* translators: the text of the quotation */
placeholder={ __( 'Write quote…' ) }
wrapperClassName="block-library-pullquote__content"
/>
{ ( ! RichText.isEmpty( citation ) || isSelected ) && (
<figure className={ className }>
<blockquote>
<RichText
value={ citation }
/* translators: the individual or entity quoted */
placeholder={ __( 'Write citation…' ) }
multiline="p"
value={ toRichTextValue( value ) }
onChange={
( nextCitation ) => setAttributes( {
citation: nextCitation,
( nextValue ) => setAttributes( {
value: fromRichTextValue( nextValue ),
} )
}
className="wp-block-pullquote__citation"
/* translators: the text of the quotation */
placeholder={ __( 'Write quote…' ) }
wrapperClassName="block-library-pullquote__content"
/>
) }
</blockquote>
{ ( ! RichText.isEmpty( citation ) || isSelected ) && (
<RichText
value={ citation }
/* translators: the individual or entity quoted */
placeholder={ __( 'Write citation…' ) }
onChange={
( nextCitation ) => setAttributes( {
citation: nextCitation,
} )
}
className="wp-block-pullquote__citation"
/>
) }
</blockquote>
</figure>
);
},

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

return (
<blockquote>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
</blockquote>
<figure>
<blockquote>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
</blockquote>
</figure>
);
},

deprecated: [ {
attributes: {
...blockAttributes,
},
save( { attributes } ) {
const { value, citation } = attributes;
return (
<blockquote>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
</blockquote>
);
},
}, {
attributes: {
...blockAttributes,
citation: {
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/pullquote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

&.alignleft,
&.alignright {
max-width: 400px;
max-width: $content-width / 2;

> p {
p {
font-size: 20px;
}
}

> p {
p {
font-size: 24px;
line-height: 1.6;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`core/pullquote block edit matches snapshot 1`] = `
<blockquote
<figure
class="wp-block-pullquote"
>
<div
class="block-library-pullquote__content editor-rich-text"
>
<div>
<blockquote>
<div
class="block-library-pullquote__content editor-rich-text"
>
<div>
<div
class="components-autocomplete"
>
<div>
<div
aria-autocomplete="list"
aria-expanded="false"
aria-label="Write quote…"
aria-multiline="true"
class="editor-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<div
class="editor-rich-text__tinymce"
class="components-autocomplete"
>
<p>
Write quote…
</p>
<div
aria-autocomplete="list"
aria-expanded="false"
aria-label="Write quote…"
aria-multiline="true"
class="editor-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<div
class="editor-rich-text__tinymce"
>
<p>
Write quote…
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</blockquote>
</figure>
`;
8 changes: 5 additions & 3 deletions test/integration/full-content/fixtures/core__pullquote.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!-- wp:core/pullquote -->
<blockquote class="wp-block-pullquote">
<p>Testing pullquote block...</p><cite>...with a caption</cite>
</blockquote>
<figure class="wp-block-pullquote">
<blockquote>
<p>Testing pullquote block...</p><cite>...with a caption</cite>
</blockquote>
</figure>
<!-- /wp:core/pullquote -->
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
]
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>"
"originalContent": "<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Testing pullquote block...</p><cite>...with a caption</cite>\n </blockquote>\n</figure>"
}
]
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\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>\n"
"innerHTML": "\n<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Testing pullquote block...</p><cite>...with a caption</cite>\n </blockquote>\n</figure>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote"><p>Testing pullquote block...</p><cite>...with a caption</cite></blockquote>
<figure class="wp-block-pullquote"><blockquote><p>Testing pullquote block...</p><cite>...with a caption</cite></blockquote></figure>
<!-- /wp:pullquote -->
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- wp:core/pullquote -->
<blockquote class="wp-block-pullquote">
<p>Paragraph <strong>one</strong></p>
<p>Paragraph two</p>
<cite>by whomever</cite>
</blockquote>
<figure class="wp-block-pullquote">
<blockquote>
<p>Paragraph <strong>one</strong></p>
<p>Paragraph two</p>
<cite>by whomever</cite>
</blockquote>
</figure>
<!-- /wp:core/pullquote -->
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
]
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>"
"originalContent": "<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n\t</blockquote>\n</figure>"
}
]
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\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>\n"
"innerHTML": "\n<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n\t</blockquote>\n</figure>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote"><p>Paragraph <strong>one</strong></p><p>Paragraph two</p><cite>by whomever</cite></blockquote>
<figure class="wp-block-pullquote"><blockquote><p>Paragraph <strong>one</strong></p><p>Paragraph two</p><cite>by whomever</cite></blockquote></figure>
<!-- /wp:pullquote -->

0 comments on commit 4883a7e

Please sign in to comment.