Skip to content

Commit

Permalink
Port nextpage block to the ReactNative mobile app (#11192)
Browse files Browse the repository at this point in the history
* Port next page block to native app

* Edit function is extracted from index.js and put into separate files for mobile and web
* New scss is added for mobile

* Fix lint issues

* Fix failing unittest

* Add react-native path to notices package.json

* Make some code review fixes
  • Loading branch information
pinarol authored Oct 30, 2018
1 parent 9e80b0c commit 9d46596
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as heading from './heading';
import * as more from './more';
import * as paragraph from './paragraph';
import * as image from './image';
import * as nextpage from './nextpage';

export const registerCoreBlocks = () => {
[
Expand All @@ -21,6 +22,7 @@ export const registerCoreBlocks = () => {
code,
more,
image,
nextpage,
].forEach( ( { name, settings } ) => {
registerBlockType( name, settings );
} );
Expand Down
12 changes: 12 additions & 0 deletions packages/block-library/src/nextpage/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

export default function NextPageEdit() {
return (
<div className="wp-block-nextpage">
<span>{ __( 'Page break' ) }</span>
</div>
);
}
24 changes: 24 additions & 0 deletions packages/block-library/src/nextpage/edit.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* External dependencies
*/
import { View, Text } from 'react-native';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import styles from './editor.scss';

export default function NextPageEdit( { attributes } ) {
const { customText = __( 'Page break' ) } = attributes;

return (
<View className={ styles[ 'block-library-nextpage__container' ] }>
<Text>{ customText }</Text>
</View>
);
}
6 changes: 6 additions & 0 deletions packages/block-library/src/nextpage/editor.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @format

.block-library-nextpage__container {
align-items: center;
padding: 4px 4px 4px 4px;
}
9 changes: 2 additions & 7 deletions packages/block-library/src/nextpage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { RawHTML } from '@wordpress/element';
import { createBlock } from '@wordpress/blocks';
import { G, Path, SVG } from '@wordpress/components';
import edit from './edit';

export const name = 'core/nextpage';

Expand Down Expand Up @@ -42,13 +43,7 @@ export const settings = {
],
},

edit() {
return (
<div className="wp-block-nextpage">
<span>{ __( 'Page break' ) }</span>
</div>
);
},
edit,

save() {
return (
Expand Down
1 change: 1 addition & 0 deletions packages/notices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build-module"
],
"main": "build/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.0.0",
"@wordpress/a11y": "file:../a11y",
Expand Down

0 comments on commit 9d46596

Please sign in to comment.