Skip to content

Commit

Permalink
ResizableFrame: Fix styling in Firefox (#52700)
Browse files Browse the repository at this point in the history
* ResizableFrame: Fix styling in Firefox

* Remove unused class
  • Loading branch information
mirka authored Jul 18, 2023
1 parent 1cdc1ee commit 49174f2
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 29 deletions.
18 changes: 16 additions & 2 deletions 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 @@ -331,7 +340,12 @@ export default function Layout() {
! isEditorLoading
}
isFullWidth={ isEditing }
oversizedClassName="edit-site-layout__resizable-frame-oversized"
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
5 changes: 2 additions & 3 deletions packages/edit-site/src/components/resizable-frame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ function calculateNewHeight( width, initialAspectRatio ) {

function ResizableFrame( {
isFullWidth,
isOversized,
setIsOversized,
isReady,
children,
oversizedClassName,
innerContentStyle,
} ) {
const [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );
// The width of the resizable frame when a new resize gesture starts.
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 Expand Up @@ -314,7 +314,6 @@ function ResizableFrame( {
onResizeStop={ handleResizeStop }
className={ classnames( 'edit-site-resizable-frame__inner', {
'is-resizing': isResizing,
[ oversizedClassName ]: isOversized,
} ) }
>
<motion.div
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

0 comments on commit 49174f2

Please sign in to comment.