-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Pullquote block #20952
[RNMobile] Pullquote block #20952
Changes from 15 commits
c67e14f
fd1ff66
9c09805
f5a340c
1ba878d
5a20f96
df0c1e0
c4aa274
64b938d
fdabf7c
06e1b1c
5ee8ef2
7a3cc2b
e9307bc
5c216a1
153f189
440d528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { PanelBody, UnsupportedFooterControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
const PanelColorSettings = () => { | ||
return ( | ||
<PanelBody> | ||
<UnsupportedFooterControl | ||
label={ __( 'Color settings are coming soon.' ) } | ||
separatorType="none" | ||
/> | ||
</PanelBody> | ||
); | ||
}; | ||
export default PanelColorSettings; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const BlockQuote = 'blockquote'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Children, cloneElement } from '@wordpress/element'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './blockquote.scss'; | ||
|
||
export const BlockQuote = ( props ) => { | ||
const newChildren = Children.map( props.children, ( child ) => { | ||
if ( child && child.props.identifier === 'value' ) { | ||
return cloneElement( child, { | ||
style: styles.quote, | ||
} ); | ||
} | ||
if ( child && child.props.identifier === 'citation' ) { | ||
return cloneElement( child, { | ||
style: styles.citation, | ||
} ); | ||
} | ||
return child; | ||
} ); | ||
return <View>{ newChildren }</View>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.quote { | ||
font-size: 18px; | ||
} | ||
|
||
.citation { | ||
font-size: 14px; | ||
margin-top: 12px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ import { | |
withColors, | ||
PanelColorSettings, | ||
} from '@wordpress/block-editor'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Figure } from './figure'; | ||
import { BlockQuote } from './blockquote'; | ||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -124,12 +129,13 @@ class PullQuoteEdit extends Component { | |
|
||
return ( | ||
<> | ||
<figure style={ figureStyles } className={ figureClasses }> | ||
<blockquote | ||
<Figure style={ figureStyles } className={ figureClasses }> | ||
<BlockQuote | ||
style={ blockquoteStyles } | ||
className={ blockquoteClasses } | ||
> | ||
<RichText | ||
identifier="value" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identifier and textAlign are only used by native code right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True for |
||
multiline | ||
value={ value } | ||
onChange={ ( nextValue ) => | ||
|
@@ -141,9 +147,11 @@ class PullQuoteEdit extends Component { | |
// translators: placeholder text used for the quote | ||
__( 'Write quote…' ) | ||
} | ||
textAlign="center" | ||
/> | ||
{ ( ! RichText.isEmpty( citation ) || isSelected ) && ( | ||
<RichText | ||
identifier="citation" | ||
value={ citation } | ||
placeholder={ | ||
// translators: placeholder text used for the citation | ||
|
@@ -155,10 +163,12 @@ class PullQuoteEdit extends Component { | |
} ) | ||
} | ||
className="wp-block-pullquote__citation" | ||
__unstableMobileNoFocusOnMount | ||
textAlign="center" | ||
/> | ||
) } | ||
</blockquote> | ||
</figure> | ||
</BlockQuote> | ||
</Figure> | ||
<InspectorControls> | ||
<PanelColorSettings | ||
title={ __( 'Color settings' ) } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Figure = 'figure'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withPreferredColorScheme } from '@wordpress/compose'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './figure.scss'; | ||
|
||
export const Figure = withPreferredColorScheme( ( props ) => { | ||
const { children, getStylesFromColorScheme } = props; | ||
|
||
const wpPullquoteFigure = getStylesFromColorScheme( | ||
styles.light, | ||
styles.dark | ||
); | ||
|
||
return <View style={ wpPullquoteFigure }>{ children }</View>; | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%shared { | ||
border-width: 3px 0; | ||
padding: 21px 16px; | ||
} | ||
|
||
.light { | ||
@extend %shared; | ||
border-top-color: $gray-lighten-20; | ||
border-bottom-color: $gray-lighten-20; | ||
} | ||
|
||
.dark { | ||
@extend %shared; | ||
border-top-color: $gray-50; | ||
border-bottom-color: $gray-50; | ||
} |
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.
PanelColorSettings just uses PanelColorGradientSettings, it may be a good idea to add this code to PanelColorGradientSettings so we cover all use cases of colors and gradients.
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.
👍