-
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
Add pagination block #1467
Add pagination block #1467
Changes from all commits
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,40 @@ | ||
.editor-visual-editor__block[data-type="core/nextpage"] { | ||
max-width: 100%; | ||
} | ||
|
||
.wp-block-nextpage { | ||
display: block; | ||
text-align: center; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
|
||
.wp-block-nextpage > span { | ||
position: relative; | ||
display: inline-block; | ||
font-size: 12px; | ||
text-transform: uppercase; | ||
font-weight: 600; | ||
font-family: $default-font; | ||
color: $dark-gray-300; | ||
} | ||
|
||
.wp-block-nextpage > span:before, | ||
.wp-block-nextpage > span:after { | ||
content: ''; | ||
position: absolute; | ||
top: 50%; | ||
width: 100vw; | ||
border-top: 3px dashed $light-gray-700; | ||
margin-top: -2px; | ||
} | ||
|
||
.wp-block-nextpage > span:before { | ||
right: 100%; | ||
margin-right: 20px; | ||
} | ||
|
||
.wp-block-nextpage > span:after { | ||
left: 100%; | ||
margin-left: 20px; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { RawHTML } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './editor.scss'; | ||
import { createBlock } from '../../api'; | ||
|
||
export const name = 'core/nextpage'; | ||
|
||
export const settings = { | ||
title: __( 'Page break' ), | ||
|
||
description: __( 'This block allows you to set break points on your post. Visitors of your blog are then presented with content split into multiple pages.' ), | ||
|
||
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. A |
||
icon: 'admin-page', | ||
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.
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. Yep, that icon is solid. |
||
|
||
category: 'layout', | ||
|
||
keywords: [ __( 'next page' ), __( 'pagination' ) ], | ||
|
||
supports: { | ||
customClassName: false, | ||
className: false, | ||
html: false, | ||
}, | ||
|
||
attributes: {}, | ||
|
||
transforms: { | ||
from: [ | ||
{ | ||
type: 'raw', | ||
isMatch: ( node ) => node.dataset && node.dataset.block === 'core/nextpage', | ||
transform() { | ||
return createBlock( 'core/nextpage', {} ); | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
edit() { | ||
return ( | ||
<div className="wp-block-nextpage"> | ||
<span>{ __( 'Page break' ) }</span> | ||
</div> | ||
); | ||
}, | ||
|
||
save() { | ||
return ( | ||
<RawHTML> | ||
{ '<!--nextpage-->' } | ||
</RawHTML> | ||
); | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/nextpage block edit matches snapshot 1`] = ` | ||
<div | ||
class="wp-block-nextpage" | ||
> | ||
<span> | ||
Page break | ||
</span> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { name, settings } from '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/nextpage', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( name, settings ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- wp:core/nextpage --> | ||
<!--nextpage--> | ||
<!-- /wp:core/nextpage --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"uid": "_uid_0", | ||
"name": "core/nextpage", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [], | ||
"originalContent": "<!--nextpage-->" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"blockName": "core/nextpage", | ||
"attrs": null, | ||
"innerBlocks": [], | ||
"innerHTML": "\n<!--nextpage-->\n" | ||
}, | ||
{ | ||
"attrs": {}, | ||
"innerHTML": "\n" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- wp:nextpage --> | ||
<!--nextpage--> | ||
<!-- /wp:nextpage --> |
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.
This file is a lot different from
blocks/library/more/editor.scss
. I prefer the final result for Next Page, and we'd probably want to converge a bit on the two stylesheets. Any advice from @jasmussen is much appreciated, as always.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.
I agree it would be nice to refine the styles of both of these blocks. However this PR has gone on for a while. I think perhaps it'd be good to merge this in as is, and then look at refining/unifying the styles separately. I can take that on as a quick smallish PR.