UNPKG

@wordpress/editor

Version:
37 lines (32 loc) 868 B
/** * WordPress dependencies */ import { __experimentalText as WCText } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; import { __, sprintf } from '@wordpress/i18n'; import { humanTimeDiff } from '@wordpress/date'; /** * Internal dependencies */ import { store as editorStore } from '../../store'; import { unlock } from '../../lock-unlock'; export default function RevisionCreatedPanel() { const date = useSelect( ( select ) => { const { getCurrentRevision } = unlock( select( editorStore ) ); return getCurrentRevision()?.date; }, [] ); if ( ! date ) { return null; } return ( <div className="editor-post-last-edited-panel"> <WCText> { sprintf( // translators: %s: Human-readable time difference, e.g. "2 days ago". __( 'Created %s.' ), humanTimeDiff( date ) ) } </WCText> </div> ); }