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

[RNMobile] Pullquote block #20265

Closed
wants to merge 13 commits into from
Closed
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
export { default as BlockCaption } from './block-caption';
export { default as Caption } from './caption';
export { default as PanelColorSettings } from './panel-color-settings';

export { BottomSheetSettings, BlockSettingsButton } from './block-settings';
export { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';
Expand Down
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;
1 change: 1 addition & 0 deletions packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const registerCoreBlocks = () => {
shortcode,
devOnly( verse ),
cover,
devOnly( pullquote ),
].forEach( registerBlock );

setDefaultBlockName( paragraph.name );
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/pullquote/blockquote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BlockQuote = 'blockquote';
29 changes: 29 additions & 0 deletions packages/block-library/src/pullquote/blockquote.native.js
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>;
};
8 changes: 8 additions & 0 deletions packages/block-library/src/pullquote/blockquote.native.scss
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;
}
18 changes: 14 additions & 4 deletions packages/block-library/src/pullquote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import {
withColors,
PanelColorSettings,
} from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import { Figure } from './figure';
import { BlockQuote } from './blockquote';

/**
* Internal dependencies
Expand Down Expand Up @@ -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"
multiline
value={ value }
onChange={ ( nextValue ) =>
Expand All @@ -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
Expand All @@ -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' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/pullquote/figure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const Figure = 'figure';
23 changes: 23 additions & 0 deletions packages/block-library/src/pullquote/figure.native.js
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>;
} );
16 changes: 16 additions & 0 deletions packages/block-library/src/pullquote/figure.native.scss
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;
}