Skip to content

Commit

Permalink
fix: avoid FOUC of side bars on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Mar 27, 2024
1 parent 7c4d440 commit 83be956
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ export function Puck<UserConfig extends Config = Config>({
[loadedOverrides]
);

const [mounted, setMounted] = useState(false);

useEffect(() => {
setMounted(true);
}, []);

return (
<div className="Puck">
<AppProvider
Expand Down Expand Up @@ -446,6 +452,7 @@ export function Puck<UserConfig extends Config = Config>({
className={getClassName({
leftSideBarVisible,
menuOpen,
mounted,
rightSideBarVisible,
})}
>
Expand Down
8 changes: 6 additions & 2 deletions packages/core/components/Puck/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

.Puck {
--puck-frame-width: auto;
--puck-side-bar-width: 186px;
--puck-side-bar-width: 0px;
--puck-space-px: 16px;
bottom: 0;
display: grid;
Expand All @@ -33,6 +33,10 @@
top: 0;
}

.Puck--mounted {
--puck-side-bar-width: 186px;
}

.Puck--leftSideBarVisible {
grid-template-columns:
var(--puck-side-bar-width) var(--puck-frame-width)
Expand All @@ -52,7 +56,7 @@
}

@media (min-width: 458px) {
.Puck {
.Puck-mounted {
--puck-frame-width: minmax(266px, auto);
}
}
Expand Down

0 comments on commit 83be956

Please sign in to comment.