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

ResizableFrame: Fix styling in Firefox #52700

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export default function Layout() {
const [ fullResizer ] = useResizeObserver();
const [ isResizing ] = useState( false );
const isEditorLoading = useIsSiteEditorLoading();
const [ isResizableFrameOversized, setIsResizableFrameOversized ] =
useState( false );

// This determines which animation variant should apply to the header.
// There is also a `isDistractionFreeHovering` state that gets priority
Expand Down Expand Up @@ -218,6 +220,7 @@ export default function Layout() {
edit: { x: 0 },
} }
ref={ hubRef }
isTransparent={ isResizableFrameOversized }
className="edit-site-layout__hub"
/>

Expand Down Expand Up @@ -315,7 +318,13 @@ export default function Layout() {
}
initial={ false }
layout="position"
className="edit-site-layout__canvas"
className={ classnames(
'edit-site-layout__canvas',
{
'is-right-aligned':
isResizableFrameOversized,
}
) }
transition={ {
type: 'tween',
duration:
Expand All @@ -332,6 +341,12 @@ export default function Layout() {
}
isFullWidth={ isEditing }
oversizedClassName="edit-site-layout__resizable-frame-oversized"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the use of this prop could be removed now and further that the prop itself could be removed from ResizableFrame. Of course I could've missed something.

Suggested change
oversizedClassName="edit-site-layout__resizable-frame-oversized"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! 6ecff49

isOversized={
isResizableFrameOversized
}
setIsOversized={
setIsResizableFrameOversized
}
innerContentStyle={ {
background:
gradientValue ??
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
justify-content: center;
align-items: center;

&:has(.edit-site-layout__resizable-frame-oversized) {
&.is-right-aligned {
justify-content: flex-end;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/resizable-frame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function calculateNewHeight( width, initialAspectRatio ) {

function ResizableFrame( {
isFullWidth,
isOversized,
setIsOversized,
isReady,
children,
oversizedClassName,
Expand All @@ -88,7 +90,6 @@ function ResizableFrame( {
const [ startingWidth, setStartingWidth ] = useState();
const [ isResizing, setIsResizing ] = useState( false );
const [ shouldShowHandle, setShouldShowHandle ] = useState( false );
const [ isOversized, setIsOversized ] = useState( false );
const [ resizeRatio, setResizeRatio ] = useState( 1 );
const canvasMode = useSelect(
( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),
Expand Down
17 changes: 0 additions & 17 deletions packages/edit-site/src/components/resizable-frame/style.scss
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
.edit-site-resizable-frame__inner {
position: relative;

&.edit-site-layout__resizable-frame-oversized {
@at-root {
body:has(&) {
.edit-site-site-hub {
.edit-site-site-hub__site-title,
.edit-site-site-hub_toggle-command-center {
opacity: 0 !important;
}

.edit-site-site-hub__view-mode-toggle-container {
background-color: transparent;
}
}
}
}
}

&.is-resizing {
@at-root {
body:has(&) {
Expand Down
26 changes: 20 additions & 6 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { unlock } from '../../lock-unlock';

const HUB_ANIMATION_DURATION = 0.3;

const SiteHub = forwardRef( ( props, ref ) => {
const SiteHub = forwardRef( ( { isTransparent, ...restProps }, ref ) => {
const { canvasMode, dashboardLink, homeUrl, siteTitle } = useSelect(
( select ) => {
const { getCanvasMode, getSettings } = unlock(
Expand Down Expand Up @@ -84,8 +84,11 @@ const SiteHub = forwardRef( ( props, ref ) => {
return (
<motion.div
ref={ ref }
{ ...props }
className={ classnames( 'edit-site-site-hub', props.className ) }
{ ...restProps }
className={ classnames(
'edit-site-site-hub',
restProps.className
) }
initial={ false }
transition={ {
type: 'tween',
Expand All @@ -104,7 +107,12 @@ const SiteHub = forwardRef( ( props, ref ) => {
spacing="0"
>
<motion.div
className="edit-site-site-hub__view-mode-toggle-container"
className={ classnames(
'edit-site-site-hub__view-mode-toggle-container',
{
'has-transparent-background': isTransparent,
}
) }
layout
transition={ {
type: 'tween',
Expand Down Expand Up @@ -148,7 +156,10 @@ const SiteHub = forwardRef( ( props, ref ) => {
exit={ {
opacity: 0,
} }
className="edit-site-site-hub__site-title"
className={ classnames(
'edit-site-site-hub__site-title',
{ 'is-transparent': isTransparent }
) }
transition={ {
type: 'tween',
duration: disableMotion ? 0 : 0.2,
Expand All @@ -174,7 +185,10 @@ const SiteHub = forwardRef( ( props, ref ) => {
</HStack>
{ canvasMode === 'view' && (
<Button
className="edit-site-site-hub_toggle-command-center"
className={ classnames(
'edit-site-site-hub_toggle-command-center',
{ 'is-transparent': isTransparent }
) }
icon={ search }
onClick={ () => openCommandCenter() }
label={ __( 'Open command palette' ) }
Expand Down
8 changes: 8 additions & 0 deletions packages/edit-site/src/components/site-hub/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
.edit-site-site-hub__site-title,
.edit-site-site-hub_toggle-command-center {
transition: opacity ease 0.1s;

&.is-transparent {
opacity: 0 !important;
}
}

.edit-site-site-hub__site-view-link {
Expand Down Expand Up @@ -44,6 +48,10 @@
width: $header-height;
flex-shrink: 0;
background: $gray-900;

&.has-transparent-background {
background: transparent;
}
}

.edit-site-site-hub__text-content {
Expand Down