Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browse Mode: Add snackbar notices #50794

Merged
merged 6 commits into from May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/components/src/snackbar/list.tsx
Expand Up @@ -73,7 +73,6 @@ export function SnackbarList( {

return (
<motion.div
layout={ ! isReducedMotion } // See https://www.framer.com/docs/animation/#layout-animations
initial={ 'init' }
animate={ 'open' }
exit={ 'exit' }
Expand Down
7 changes: 1 addition & 6 deletions packages/edit-site/src/components/editor/index.js
Expand Up @@ -180,12 +180,7 @@ export default function Editor( { isLoading } ) {
'is-loading': isLoading,
}
) }
notices={
( isEditMode ||
window?.__experimentalEnableThemePreviews ) && (
<EditorSnackbars />
)
}
notices={ <EditorSnackbars /> }
content={
<>
<GlobalStylesRenderer />
Expand Down
17 changes: 11 additions & 6 deletions packages/edit-site/src/components/editor/style.scss
Expand Up @@ -19,11 +19,16 @@
}

// Adjust the position of the notices
.edit-site .components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: 40px;
padding-left: 16px;
padding-right: 16px;
.edit-site {
.components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: 0;
padding: 16px;
}
.is-edit-mode .components-editor-notices__snackbar {
bottom: 24px;
}
}

@include editor-left(".edit-site .components-editor-notices__snackbar")
12 changes: 9 additions & 3 deletions packages/edit-site/src/components/layout/index.js
Expand Up @@ -215,7 +215,7 @@ export default function Layout() {
whileHover={
isEditorPage && canvasMode === 'view'
? {
scale: 1.005,
scale: 1.006,
transition: {
duration:
disableMotion ||
Expand All @@ -227,8 +227,14 @@ export default function Layout() {
}
: {}
}
initial={ false }
layout="position"
// Setting a transform property (in this case scale) on an element makes it act as a containing block for its descendants.
// This means that the snackbar notices inside this component are repositioned to be relative to this element.
// To avoid the snackbars jumping about we need to ensure that a transform property is always set.
// Setting a scale of 1 is interpred by framer as no change, so once the animation completes
// the transform property of this element is set to none, thus removing its role as a container block.
// Instead we set the initial scale of this element to 1.0001 so that there is always a transform property set.
// If we set the initial scale to less than 1.001 then JavaScript rounds it to 1 and the problem reoccurs.
initial={ { scale: 1.001 } }
className="edit-site-layout__canvas"
transition={ {
type: 'tween',
Expand Down