Skip to content

Commit

Permalink
Fix urls
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Oct 22, 2024
1 parent dc6aefa commit 2766d7f
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { useLocation, useHistory } = unlock( routerPrivateApis );
export default function useEditorIframeProps() {
const { params } = useLocation();
const history = useHistory();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const currentPostIsTrashed = useSelect( ( select ) => {
return (
select( editorStore ).getCurrentPostAttribute( 'status' ) ===
Expand All @@ -33,10 +33,10 @@ export default function useEditorIframeProps() {
const [ isFocused, setIsFocused ] = useState( false );

useEffect( () => {
if ( canvasMode === 'edit' ) {
if ( canvas === 'edit' ) {
setIsFocused( false );
}
}, [ canvasMode ] );
}, [ canvas ] );

// In view mode, make the canvas iframe be perceived and behave as a button
// to switch to edit mode, with a meaningful label and no title attribute.
Expand All @@ -55,13 +55,13 @@ export default function useEditorIframeProps() {
! currentPostIsTrashed
) {
event.preventDefault();
history.push( { ...params, canvasMode: 'edit' }, undefined, {
history.push( { ...params, canvas: 'edit' }, undefined, {
transition: 'canvas-mode-edit-transition',
} );
}
},
onClick: () => {
history.push( { ...params, canvasMode: 'edit' }, undefined, {
history.push( { ...params, canvas: 'edit' }, undefined, {
transition: 'canvas-mode-edit-transition',
} );
},
Expand All @@ -76,8 +76,8 @@ export default function useEditorIframeProps() {

return {
className: clsx( 'edit-site-visual-editor__editor-canvas', {
'is-focused': isFocused && canvasMode === 'view',
'is-focused': isFocused && canvas === 'view',
} ),
...( canvasMode === 'view' ? viewModeIframeProps : {} ),
...( canvas === 'view' ? viewModeIframeProps : {} ),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function useNavigateToPreviousEntityRecord() {

export function useSpecificEditorSettings() {
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const onNavigateToEntityRecord = useNavigateToEntityRecord();
const { settings, shouldUseTemplateAsDefaultRenderingMode } = useSelect(
( select ) => {
Expand Down Expand Up @@ -68,15 +68,15 @@ export function useSpecificEditorSettings() {

richEditingEnabled: true,
supportsTemplateMode: true,
focusMode: canvasMode !== 'view',
focusMode: canvas !== 'view',
defaultRenderingMode,
onNavigateToEntityRecord,
onNavigateToPreviousEntityRecord,
__unstableIsPreviewMode: canvasMode === 'view',
__unstableIsPreviewMode: canvas === 'view',
};
}, [
settings,
canvasMode,
canvas,
defaultRenderingMode,
onNavigateToEntityRecord,
onNavigateToPreviousEntityRecord,
Expand Down
13 changes: 6 additions & 7 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ const siteIconVariants = {
export default function EditSiteEditor( { isPostsList = false } ) {
const disableMotion = useReducedMotion();
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const isLoading = useIsSiteEditorLoading();
useAdaptEditorToCanvas( canvasMode );
useAdaptEditorToCanvas( canvas );
const {
editedPostType,
editedPostId,
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function EditSiteEditor( { isPostsList = false } ) {
const _isPreviewingTheme = isPreviewingTheme();
const hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();
const iframeProps = useEditorIframeProps();
const isEditMode = canvasMode === 'edit';
const isEditMode = canvas === 'edit';
const postWithTemplate = !! contextPostId;
const loadingProgressId = useInstanceId(
CanvasLoader,
Expand All @@ -144,14 +144,14 @@ export default function EditSiteEditor( { isPostsList = false } ) {
// Forming a "block formatting context" to prevent margin collapsing.
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
css:
canvasMode === 'view'
canvas === 'view'
? `body{min-height: 100vh; ${
currentPostIsTrashed ? '' : 'cursor: pointer;'
}}`
: undefined,
},
],
[ settings.styles, canvasMode, currentPostIsTrashed ]
[ settings.styles, canvas, currentPostIsTrashed ]
);
const { __unstableSetEditorMode, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
Expand Down Expand Up @@ -289,8 +289,7 @@ export default function EditSiteEditor( { isPostsList = false } ) {
history.push(
{
...params,
canvasMode:
undefined,
canvas: undefined,
},
undefined,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { store as editorStore } from '@wordpress/editor';
import { useLayoutEffect } from '@wordpress/element';
import { store as preferencesStore } from '@wordpress/preferences';

export function useAdaptEditorToCanvas( canvasMode ) {
export function useAdaptEditorToCanvas( canvas ) {
const { clearSelectedBlock } = useDispatch( blockEditorStore );
const {
setDeviceType,
Expand All @@ -31,7 +31,7 @@ export function useAdaptEditorToCanvas( canvasMode ) {
// This behavior is disabled for small viewports.
if (
isMediumOrBigger &&
canvasMode === 'edit' &&
canvas === 'edit' &&
getPreference( 'core', 'showListViewByDefault' ) &&
! getPreference( 'core', 'distractionFree' )
) {
Expand All @@ -41,7 +41,7 @@ export function useAdaptEditorToCanvas( canvasMode ) {
}
} );
}, [
canvasMode,
canvas,
registry,
clearSelectedBlock,
setDeviceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { useLocation } = unlock( routerPrivateApis );

export default function GlobalStylesSidebar() {
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const {
shouldClearCanvasContainerView,
isStyleBookOpened,
Expand All @@ -45,7 +45,7 @@ export default function GlobalStylesSidebar() {
const canvasContainerView = getEditorCanvasContainerView();
const _isVisualEditorMode =
'visual' === select( editorStore ).getEditorMode();
const _isEditCanvasMode = 'edit' === canvasMode;
const _isEditCanvasMode = 'edit' === canvas;
const _showListViewByDefault = select( preferencesStore ).get(
'core',
'showListViewByDefault'
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function GlobalStylesSidebar() {
'global-styles-revisions' === canvasContainerView,
};
},
[ canvasMode ]
[ canvas ]
);
const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function KeyboardShortcutsGlobal() {
const { hasNonPostEntityChanges } = useSelect( editorStore );
const { setIsSaveViewOpened } = useDispatch( editSiteStore );
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;

useShortcut( 'core/edit-site/save', ( event ) => {
event.preventDefault();
Expand All @@ -32,7 +32,7 @@ function KeyboardShortcutsGlobal() {
isSavingEntityRecord( record.kind, record.name, record.key )
);
const _hasNonPostEntityChanges = hasNonPostEntityChanges();
const isViewMode = canvasMode === 'view';
const isViewMode = canvas === 'view';
if (
( ! hasDirtyEntities || ! _hasNonPostEntityChanges || isSaving ) &&
! isViewMode
Expand Down
20 changes: 9 additions & 11 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ANIMATION_DURATION = 0.3;

export default function Layout( { route } ) {
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
useCommands();
const isMobileViewport = useViewportMatch( 'medium', '<' );
const toggleRef = useRef();
Expand All @@ -64,19 +64,19 @@ export default function Layout( { route } ) {
useState( false );
const { name: routeKey, areas, widths } = route;
const animationRef = useMovingAnimation( {
triggerAnimationOnChange: routeKey + '-' + canvasMode,
triggerAnimationOnChange: routeKey + '-' + canvas,
} );

const [ backgroundColor ] = useGlobalStyle( 'color.background' );
const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
const previousCanvaMode = usePrevious( canvasMode );
const previousCanvaMode = usePrevious( canvas );
useEffect( () => {
if ( previousCanvaMode === 'edit' ) {
toggleRef.current?.focus();
}
// Should not depend on the previous canvas mode value but the next.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ canvasMode ] );
}, [ canvas ] );

return (
<>
Expand All @@ -90,7 +90,7 @@ export default function Layout( { route } ) {
'edit-site-layout',
navigateRegionsProps.className,
{
'is-full-canvas': canvasMode === 'edit',
'is-full-canvas': canvas === 'edit',
}
) }
>
Expand All @@ -105,7 +105,7 @@ export default function Layout( { route } ) {
className="edit-site-layout__sidebar-region"
>
<AnimatePresence>
{ canvasMode === 'view' && (
{ canvas === 'view' && (
<motion.div
initial={ { opacity: 0 } }
animate={ { opacity: 1 } }
Expand Down Expand Up @@ -143,7 +143,7 @@ export default function Layout( { route } ) {

{ isMobileViewport && areas.mobile && (
<div className="edit-site-layout__mobile">
{ canvasMode !== 'edit' && (
{ canvas !== 'edit' && (
<SidebarContent routeKey={ routeKey }>
<SiteHubMobile
ref={ toggleRef }
Expand All @@ -159,7 +159,7 @@ export default function Layout( { route } ) {

{ ! isMobileViewport &&
areas.content &&
canvasMode !== 'edit' && (
canvas !== 'edit' && (
<div
className="edit-site-layout__area"
style={ {
Expand Down Expand Up @@ -198,9 +198,7 @@ export default function Layout( { route } ) {
<ErrorBoundary>
<ResizableFrame
isReady={ ! isEditorLoading }
isFullWidth={
canvasMode === 'edit'
}
isFullWidth={ canvas === 'edit' }
defaultSize={ {
width:
canvasSize.width -
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-site/src/components/resizable-frame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function ResizableFrame( {
} ) {
const history = useHistory();
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const disableMotion = useReducedMotion();
const [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );
// The width of the resizable frame when a new resize gesture starts.
Expand Down Expand Up @@ -161,7 +161,7 @@ function ResizableFrame( {
history.push(
{
...params,
canvasMode: 'edit',
canvas: 'edit',
},
undefined,
{
Expand Down Expand Up @@ -246,7 +246,7 @@ function ResizableFrame( {
}
} }
whileHover={
canvasMode === 'view'
canvas === 'view'
? {
scale: 1.005,
transition: {
Expand Down Expand Up @@ -284,7 +284,7 @@ function ResizableFrame( {
onMouseOver={ () => setShouldShowHandle( true ) }
onMouseOut={ () => setShouldShowHandle( false ) }
handleComponent={ {
[ isRTL() ? 'right' : 'left' ]: canvasMode === 'view' && (
[ isRTL() ? 'right' : 'left' ]: canvas === 'view' && (
<>
<Tooltip text={ __( 'Drag to resize' ) }>
{ /* Disable reason: role="separator" does in fact support aria-valuenow */ }
Expand Down
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/save-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const _EntitiesSavedStates = ( { onClose, renderDialog = undefined } ) => {

export default function SavePanel() {
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const { isSaveViewOpen, isDirty, isSaving } = useSelect( ( select ) => {
const {
__experimentalGetDirtyEntityRecords,
Expand All @@ -117,9 +117,9 @@ export default function SavePanel() {
const onClose = () => setIsSaveViewOpened( false );
useEffect( () => {
setIsSaveViewOpened( false );
}, [ canvasMode, setIsSaveViewOpened ] );
}, [ canvas, setIsSaveViewOpened ] );

if ( canvasMode === 'view' ) {
if ( canvas === 'view' ) {
return isSaveViewOpen ? (
<Modal
className="edit-site-save-panel__modal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function SidebarNavigationItemGlobalStyles( props ) {
history.push(
{
...params,
canvasMode: 'edit',
canvas: 'edit',
},
undefined,
{
Expand All @@ -71,7 +71,7 @@ export function SidebarNavigationItemGlobalStyles( props ) {
export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
const history = useHistory();
const { params } = useLocation();
const { canvasMode = 'view' } = params;
const { canvas = 'view' } = params;
const { revisions, isLoading: isLoadingRevisions } =
useGlobalStylesRevisions();
const { openGeneralSidebar } = useDispatch( editSiteStore );
Expand Down Expand Up @@ -102,7 +102,7 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
history.push(
{
...params,
canvasMode: 'edit',
canvas: 'edit',
},
undefined,
{
Expand Down Expand Up @@ -184,18 +184,16 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
</>
}
/>
{ isStyleBookOpened &&
! isMobileViewport &&
canvasMode === 'view' && (
<StyleBook
enableResizing={ false }
isSelected={ () => false }
onClick={ openStyleBook }
onSelect={ openStyleBook }
showCloseButton={ false }
showTabs={ false }
/>
) }
{ isStyleBookOpened && ! isMobileViewport && canvas === 'view' && (
<StyleBook
enableResizing={ false }
isSelected={ () => false }
onClick={ openStyleBook }
onSelect={ openStyleBook }
showCloseButton={ false }
showTabs={ false }
/>
) }
</>
);
}
Loading

0 comments on commit 2766d7f

Please sign in to comment.