Skip to content

Commit

Permalink
Testing out zoom mode in the revisions view
Browse files Browse the repository at this point in the history
Also making the resizable iframe optional
  • Loading branch information
ramonjd committed May 16, 2023
1 parent b0d2da0 commit 2779610
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
5 changes: 2 additions & 3 deletions packages/edit-site/src/components/block-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default function BlockEditor() {
const [ resizeObserver, sizes ] = useResizeObserver();

const isTemplatePart = templateType === 'wp_template_part';

const hasBlocks = blocks.length !== 0;
const enableResizing =
isTemplatePart &&
Expand All @@ -169,9 +170,7 @@ export default function BlockEditor() {
{ ( [ editorCanvasView ] ) =>
editorCanvasView ? (
<div className="edit-site-visual-editor is-focus-mode">
<ResizableEditor enableResizing>
{ editorCanvasView }
</ResizableEditor>
{ editorCanvasView }
</div>
) : (
<BlockTools
Expand Down
47 changes: 28 additions & 19 deletions packages/edit-site/src/components/editor-canvas-container/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useFocusOnMount, useFocusReturn } from '@wordpress/compose';
*/
import { unlock } from '../../private-apis';
import { store as editSiteStore } from '../../store';
import ResizableEditor from '../block-editor/resizable-editor';

/**
* Returns a translated string for the title of the editor canvas container.
Expand Down Expand Up @@ -46,7 +47,12 @@ const {
Fill: EditorCanvasContainerFill,
} = createPrivateSlotFill( SLOT_FILL_NAME );

function EditorCanvasContainer( { children, closeButtonLabel, onClose } ) {
function EditorCanvasContainer( {
children,
closeButtonLabel,
onClose,
enableResizing = false,
} ) {
const editorCanvasContainerView = useSelect(
( select ) =>
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
Expand All @@ -62,6 +68,7 @@ function EditorCanvasContainer( { children, closeButtonLabel, onClose } ) {
() => getEditorCanvasContainerTitle( editorCanvasContainerView ),
[ editorCanvasContainerView ]
);

function onCloseContainer() {
if ( typeof onClose === 'function' ) {
onClose();
Expand Down Expand Up @@ -97,24 +104,26 @@ function EditorCanvasContainer( { children, closeButtonLabel, onClose } ) {

return (
<EditorCanvasContainerFill>
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
<section
className="edit-site-editor-canvas-container"
ref={ shouldShowCloseButton ? focusOnMountRef : null }
onKeyDown={ closeOnEscape }
aria-label={ title }
>
{ shouldShowCloseButton && (
<Button
className="edit-site-editor-canvas-container__close-button"
icon={ closeSmall }
label={ closeButtonLabel || __( 'Close' ) }
onClick={ onCloseContainer }
showTooltip={ false }
/>
) }
{ childrenWithProps }
</section>
<ResizableEditor enableResizing={ enableResizing }>
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
<section
className="edit-site-editor-canvas-container"
ref={ shouldShowCloseButton ? focusOnMountRef : null }
onKeyDown={ closeOnEscape }
aria-label={ title }
>
{ shouldShowCloseButton && (
<Button
className="edit-site-editor-canvas-container__close-button"
icon={ closeSmall }
label={ closeButtonLabel || __( 'Close' ) }
onClick={ onCloseContainer }
showTooltip={ false }
/>
) }
{ childrenWithProps }
</section>
</ResizableEditor>
</EditorCanvasContainerFill>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.edit-site-editor-canvas-container {
background: $white; // Fallback color, overridden by JavaScript.
border-radius: $radius-block-ui;
bottom: 0;
left: 0;
Expand Down
3 changes: 3 additions & 0 deletions packages/edit-site/src/components/revisions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ function Revisions( { onClose, userConfig, blocks } ) {
className="edit-site-revisions__iframe"
name="revisions"
tabIndex={ 0 }
expand={ true }
scale={ 0.75 }
frameSize={ 100 }
>
<EditorStyles styles={ editorStyles } />
<style>
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ function StyleBook( { isSelected, onSelect } ) {
);

return (
<EditorCanvasContainer closeButtonLabel={ __( 'Close Style Book' ) }>
<EditorCanvasContainer
enableResizing={ true }
closeButtonLabel={ __( 'Close Style Book' ) }
>
<div
className={ classnames( 'edit-site-style-book', {
'is-wide': sizes.width > 600,
Expand Down

0 comments on commit 2779610

Please sign in to comment.