diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index b11a9c56c9c50c..d0c63a9db5cad6 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -7,8 +7,8 @@ import clsx from 'clsx'; * WordPress dependencies */ import { useDispatch, useSelect } from '@wordpress/data'; -import { Button } from '@wordpress/components'; -import { useInstanceId } from '@wordpress/compose'; +import { Button, __unstableMotion as motion } from '@wordpress/components'; +import { useInstanceId, useReducedMotion } from '@wordpress/compose'; import { EditorKeyboardShortcutsRegister, privateApis as editorPrivateApis, @@ -22,6 +22,7 @@ import { store as noticesStore } from '@wordpress/notices'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { store as preferencesStore } from '@wordpress/preferences'; import { decodeEntities } from '@wordpress/html-entities'; +import { Icon, chevronLeft } from '@wordpress/icons'; /** * Internal dependencies @@ -51,7 +52,32 @@ const { Editor, BackButton } = unlock( editorPrivateApis ); const { useHistory, useLocation } = unlock( routerPrivateApis ); const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis ); +const toggleHomeIconVariants = { + edit: { + opacity: 0, + scale: 0.2, + }, + hover: { + opacity: 1, + scale: 1, + clipPath: 'inset( 22% round 2px )', + }, +}; + +const siteIconVariants = { + edit: { + clipPath: 'inset(0% round 0)', + }, + hover: { + clipPath: 'inset( 22% round 2px )', + }, + tap: { + clipPath: 'inset(0% round 0)', + }, +}; + export default function EditSiteEditor( { isPostsList = false } ) { + const disableMotion = useReducedMotion(); const { params } = useLocation(); const isLoading = useIsSiteEditorLoading(); const { @@ -65,6 +91,7 @@ export default function EditSiteEditor( { isPostsList = false } ) { showIconLabels, editorCanvasView, currentPostIsTrashed, + hasSiteIcon, } = useSelect( ( select ) => { const { getEditorCanvasContainerView, @@ -75,8 +102,9 @@ export default function EditSiteEditor( { isPostsList = false } ) { getEditedPostId, } = unlock( select( editSiteStore ) ); const { get } = select( preferencesStore ); - const { getCurrentTheme } = select( coreDataStore ); + const { getCurrentTheme, getEntityRecord } = select( coreDataStore ); const _context = getEditedPostContext(); + const siteData = getEntityRecord( 'root', '__unstableBase', undefined ); // The currently selected entity to display. // Typically template or template part in the site editor. @@ -93,6 +121,7 @@ export default function EditSiteEditor( { isPostsList = false } ) { currentPostIsTrashed: select( editorStore ).getCurrentPostAttribute( 'status' ) === 'trash', + hasSiteIcon: !! siteData?.site_icon_url, }; }, [] ); useEditorTitle(); @@ -179,6 +208,9 @@ export default function EditSiteEditor( { isPostsList = false } ) { getEditorCanvasContainerTitleAndIcon( editorCanvasView ); const isReady = ! isLoading; + const transition = { + duration: disableMotion ? 0 : 0.2, + }; return ( <> @@ -217,26 +249,52 @@ export default function EditSiteEditor( { isPostsList = false } ) { { ( { length } ) => length <= 1 && ( - + + + + + ) } diff --git a/packages/edit-site/src/components/editor/style.scss b/packages/edit-site/src/components/editor/style.scss index b157057062c9d1..0e2e85ba9f72dd 100644 --- a/packages/edit-site/src/components/editor/style.scss +++ b/packages/edit-site/src/components/editor/style.scss @@ -1,7 +1,7 @@ .edit-site-editor__editor-interface { opacity: 1; transition: opacity 0.1s ease-out; - @include reduce-motion("transition"); + @include reduce-motion( "transition" ); &.is-loading { opacity: 0; @@ -17,3 +17,60 @@ display: flex; justify-content: center; } + +.edit-site-editor__view-mode-toggle { + /* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */ + view-transition-name: toggle; + /* stylelint-enable */ + position: fixed; + top: 0; + left: 0; + height: $header-height; + width: $header-height; + z-index: 100; + + .components-button { + color: $white; + height: 100%; + width: 100%; + border-radius: 0; + overflow: hidden; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + &:hover, + &:active { + color: $white; + } + + &:focus { + box-shadow: none; + } + } + + .edit-site-editor__view-mode-toggle-icon { + svg, + img { + background: $gray-900; + display: block; + } + } +} + +.edit-site-editor__back-icon { + position: absolute; + top: 0; + left: 0; + width: 60px; + height: 60px; + display: flex; + align-items: center; + justify-content: center; + background-color: hsla(0, 0%, 80%); + pointer-events: none; + + &.has-site-icon { + background-color: hsla(0, 0%, 100%, 0.6); + } +} diff --git a/packages/edit-site/src/components/layout/style.scss b/packages/edit-site/src/components/layout/style.scss index 09898a530e445a..e4c95fed8b88b7 100644 --- a/packages/edit-site/src/components/layout/style.scss +++ b/packages/edit-site/src/components/layout/style.scss @@ -148,6 +148,14 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) { animation-delay: 255ms; } + +@media (prefers-reduced-motion) { + ::view-transition-group(*), + ::view-transition-old(*), + ::view-transition-new(*) { + animation: none !important; + } +} /* stylelint-enable */ .edit-site-layout.is-full-canvas .edit-site-layout__sidebar-region .edit-site-layout__view-mode-toggle { diff --git a/packages/edit-site/src/components/site-icon/style.scss b/packages/edit-site/src/components/site-icon/style.scss index a461b43476fe52..a6cc7ad27fe5df 100644 --- a/packages/edit-site/src/components/site-icon/style.scss +++ b/packages/edit-site/src/components/site-icon/style.scss @@ -1,9 +1,11 @@ .edit-site-site-icon__icon { fill: currentColor; + width: 100%; + height: 100%; .edit-site-layout.is-full-canvas & { // Make the WordPress icon not so big in full canvas. - padding: $grid-unit-15 * 0.5; // 6px. + padding: $grid-unit-15; } } @@ -12,6 +14,7 @@ height: 100%; object-fit: cover; background: #333; + aspect-ratio: 1 / 1; .edit-site-layout.is-full-canvas & { border-radius: 0;