-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
413e853
commit 3e1e031
Showing
4 changed files
with
79 additions
and
0 deletions.
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ import './freeform'; | |
import './image'; | ||
import './text'; | ||
import './list'; | ||
import './quote'; |
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,50 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import { registerBlock, query as hpq } from 'api'; | ||
import Editable from 'components/editable'; | ||
|
||
const { html, query } = hpq; | ||
|
||
registerBlock( 'core/quote', { | ||
title: wp.i18n.__( 'Quote' ), | ||
icon: 'format-quote', | ||
category: 'common', | ||
|
||
attributes: { | ||
value: ( node ) => query( 'blockquote > p', html() )( node ).join(), | ||
citation: html( 'footer' ) | ||
}, | ||
|
||
edit( { attributes, setAttributes } ) { | ||
const { value, citation } = attributes; | ||
|
||
return ( | ||
<blockquote className="blocks-quote"> | ||
<Editable | ||
value={ value } | ||
onChange={ ( newValue ) => setAttributes( { value: newValue } ) } /> | ||
<footer> | ||
<Editable | ||
value={ citation } | ||
onChange={ ( newValue ) => setAttributes( { citation: newValue } ) } /> | ||
</footer> | ||
</blockquote> | ||
); | ||
}, | ||
|
||
save( attributes ) { | ||
const { value, citation } = attributes; | ||
return ( | ||
<blockquote> | ||
{ value } | ||
{ !! citation && | ||
<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,24 @@ | ||
.blocks-quote { | ||
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; | ||
|
||
&:after { | ||
content: '— '; | ||
position: absolute; | ||
left: -1.3em; | ||
top: 0; | ||
} | ||
} | ||
} |
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