-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic 'dirty state' handling (#610)
- Loading branch information
Showing
2 changed files
with
41 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
import classNames from 'classnames'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import Dashicon from '../../components/dashicon'; | ||
|
||
function SavedState() { | ||
function SavedState( { isDirty } ) { | ||
const classes = classNames( 'editor-saved-state', { | ||
'is-dirty': isDirty, | ||
} ); | ||
const icon = isDirty | ||
? 'warning' | ||
: 'saved'; | ||
const text = isDirty | ||
? wp.i18n.__( 'Unsaved changes' ) | ||
: wp.i18n.__( 'Saved' ); | ||
|
||
return ( | ||
<div className="editor-saved-state"> | ||
<Dashicon icon="saved" /> | ||
{ wp.i18n.__( 'Saved' ) } | ||
<div className={ classes }> | ||
<Dashicon icon={ icon } /> | ||
{ text } | ||
</div> | ||
); | ||
} | ||
|
||
export default SavedState; | ||
export default connect( | ||
( state ) => ( { | ||
isDirty: state.blocks.dirty, | ||
} ) | ||
)( SavedState ); |
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