-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR restores the good stuff from #12301. That is: it allows notices to push down content. Dismissible notices are sticky at the top, non-dismisible notices scroll out of view. This is mostly an exact copy of the other PR, but fresh. The behavior has a number of benefits: - If you have multiple non-dismissible notices, you can still actually use the editor. - Notices no longer cover the scrollbar. - Notices no longer cover the permalink interface. - Notices now only cover content if you do not dismiss the notices.
- Loading branch information
Joen Asmussen
committed
Feb 12, 2019
1 parent
9dc1a33
commit 33ddecf
Showing
7 changed files
with
107 additions
and
24 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
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
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,26 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import TokenList from '@wordpress/token-list'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import NoticeList from '../list'; | ||
|
||
describe( 'NoticeList', () => { | ||
it( 'should merge className', () => { | ||
const renderer = new ShallowRenderer(); | ||
|
||
renderer.render( <NoticeList notices={ [] } className="is-ok" /> ); | ||
|
||
const classes = new TokenList( renderer.getRenderOutput().props.className ); | ||
expect( classes.contains( 'is-ok' ) ).toBe( true ); | ||
expect( classes.contains( 'components-notice-list' ) ).toBe( true ); | ||
} ); | ||
} ); |
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
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
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
35 changes: 35 additions & 0 deletions
35
packages/editor/src/components/editor-notices/test/index.js
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,35 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { shallow } from 'enzyme'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { EditorNotices } from '../'; | ||
|
||
describe( 'EditorNotices', () => { | ||
const notices = [ | ||
{ content: 'Eat your vegetables!', isDismissible: true }, | ||
{ content: 'Brush your teeth!', isDismissible: true }, | ||
{ content: 'Existence is fleeting!', isDismissible: false }, | ||
]; | ||
|
||
it( 'renders all notices', () => { | ||
const wrapper = shallow( <EditorNotices notices={ notices } /> ); | ||
expect( wrapper.prop( 'notices' ) ).toHaveLength( 3 ); | ||
expect( wrapper.children() ).toHaveLength( 1 ); | ||
} ); | ||
|
||
it( 'renders only dismissible notices', () => { | ||
const wrapper = shallow( <EditorNotices notices={ notices } dismissible={ true } /> ); | ||
expect( wrapper.prop( 'notices' ) ).toHaveLength( 2 ); | ||
expect( wrapper.children() ).toHaveLength( 1 ); | ||
} ); | ||
|
||
it( 'renders only non-dismissible notices', () => { | ||
const wrapper = shallow( <EditorNotices notices={ notices } dismissible={ false } /> ); | ||
expect( wrapper.prop( 'notices' ) ).toHaveLength( 1 ); | ||
expect( wrapper.children() ).toHaveLength( 0 ); | ||
} ); | ||
} ); |