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: Add quote blocks style controls #482

Merged
merged 7 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 14 additions & 4 deletions blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ registerBlock( 'core/quote', {
citation: html( 'footer' )
},

controls: [ '1', '2' ].map( ( level ) => ( {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure level applies as well here as it does for a heading. variant, variation, or style might be more accurate.

Copy link
Member

Choose a reason for hiding this comment

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

Minor: Do you think it's any different or better to treat '1' as a string vs. 1 as a number?

Copy link
Contributor Author

@youknowriad youknowriad Apr 21, 2017

Choose a reason for hiding this comment

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

I think a string is better to avoid any confusion while parsing and serializing the attribute back.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, that's a good point. Speaking of... how are we parsing the attribute?

icon: 'format-quote',
title: wp.i18n.sprintf( wp.i18n.__( 'Quote %s' ), level ),
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use %d placeholder, see also #423 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

revert this change because I'm using strings

isActive: ( { style = '1' } ) => style === level,
onClick( attributes, setAttributes ) {
setAttributes( { style: level } );
},
level
} ) ),

edit( { attributes, setAttributes, focus, setFocus } ) {
const { value, citation } = attributes;
const { value, citation, style = '1' } = attributes;

return (
<blockquote className="blocks-quote">
<blockquote className={ `blocks-quote blocks-quote-style-${ style }` }>
<Editable
value={ fromValueToParagraphs( value ) }
onChange={
Expand Down Expand Up @@ -54,10 +64,10 @@ registerBlock( 'core/quote', {
},

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

return (
<blockquote>
<blockquote className={ `blocks-quote-style-${ style }` }>
{ value && value.map( ( paragraph, i ) => (
<p
key={ i }
Expand Down
27 changes: 21 additions & 6 deletions blocks/library/quote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
margin: 0;
box-shadow: inset 0px 0px 0px 0px $light-gray-500;
transition: all .2s ease;
font-size: 20px;
border-left: 4px solid $black;
padding-left: 1em;
font-style: italic;

footer {
color: $dark-gray-100;
font-size: 0.9em;
font-style: normal;
margin-left: 1.3em;
position: relative;

p {
font-size: 0.9em;
font-style: normal;
}

&:before {
content: '— ';
position: absolute;
Expand All @@ -22,3 +21,19 @@
}
}
}

.editor-visual-editor .blocks-quote-style-1 {
border-left: 4px solid $black;
padding-left: 1em;
& > .blocks-editable p {
font-size: 20px;
}
}

.editor-visual-editor .blocks-quote-style-2 {
padding: 0 1em;
& > .blocks-editable p {
font-size: 24px;
font-style: italic;
}
}
4 changes: 4 additions & 0 deletions languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ msgstr ""
msgid "Quote"
msgstr ""

#: blocks/library/quote/index.js:25
msgid "Quote %s"
msgstr ""

#: blocks/library/text/index.js:13
msgid "Text"
msgstr ""
Expand Down