-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pullquote Block #607
Merged
Merged
Pullquote Block #607
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a3a03be
Pullquote Block - initial block
mkaz 0017e3a
Allow classnames to be specified for icon
mkaz 056cd7c
Merge
mkaz 75df7b6
Pull back the design a little bit ;)
jasmussen 31a51ae
Merge
mkaz ab81b8e
Remove unused attr import
mkaz ff87c9f
Remove additional classnames from control - not needed yet
mkaz f05af0d
Add i18n for placeholders, use ellipsis
mkaz 98197c1
Add inline to Editable component
mkaz 5996a31
Add check for citation length
mkaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ import './list'; | |
import './quote'; | ||
import './separator'; | ||
import './button'; | ||
import './pullquote'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import { registerBlock, query as hpq } from 'api'; | ||
import Editable from 'components/editable'; | ||
|
||
const { children, query } = hpq; | ||
|
||
registerBlock( 'core/pullquote', { | ||
title: wp.i18n.__( 'Pullquote' ), | ||
icon: 'format-quote', | ||
category: 'common', | ||
|
||
attributes: { | ||
value: query( 'blockquote > p', children() ), | ||
citation: children( 'footer' ), | ||
}, | ||
|
||
edit( { attributes, setAttributes, focus, setFocus } ) { | ||
const { value, citation } = attributes; | ||
|
||
return ( | ||
<blockquote className="blocks-pullquote"> | ||
<Editable | ||
value={ value || wp.i18n.__( 'Write Quote…' ) } | ||
onChange={ | ||
( nextValue ) => setAttributes( { | ||
value: nextValue | ||
} ) | ||
} | ||
focus={ focus && focus.editable === 'value' ? focus : null } | ||
onFocus={ () => setFocus( { editable: 'value' } ) } | ||
/> | ||
{ ( citation || !! focus ) && ( | ||
<footer> | ||
<Editable | ||
tagName="footer" | ||
value={ citation || wp.i18n.__( 'Write caption…' ) } | ||
onChange={ | ||
( nextCitation ) => setAttributes( { | ||
citation: nextCitation | ||
} ) | ||
} | ||
focus={ focus && focus.editable === 'citation' ? focus : null } | ||
onFocus={ () => setFocus( { editable: 'citation' } ) } | ||
inline | ||
/> | ||
</footer> | ||
) } | ||
</blockquote> | ||
); | ||
}, | ||
|
||
save( { attributes } ) { | ||
const { value, citation } = attributes; | ||
|
||
return ( | ||
<blockquote className="blocks-pullquote"> | ||
{ value && value.map( ( paragraph, i ) => ( | ||
<p key={ i }>{ paragraph }</p> | ||
) ) } | ||
|
||
{ citation && citation.length > 0 && ( | ||
<footer>{ citation }</footer> | ||
) } | ||
</blockquote> | ||
); | ||
} | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.blocks-pullquote { | ||
color: $light-gray-900; | ||
padding: 2em; | ||
text-align: center; | ||
|
||
footer { | ||
color: $dark-gray-900; | ||
position: relative; | ||
} | ||
|
||
footer p { | ||
font-size: 16px; | ||
font-family: $default-font; | ||
} | ||
} | ||
|
||
.editor-visual-editor .blocks-pullquote { | ||
& > .blocks-editable p { | ||
font-family: $default-font; | ||
font-size: 48px; | ||
font-weight: 900; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
tagName
you no longer need the<footer>
wrapper. Currently this will render as<footer><footer></footer></footer>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, fixed in #687