Skip to content

Commit d81ca97

Browse files
committed
Try again?
1 parent 671ab73 commit d81ca97

2 files changed

Lines changed: 5 additions & 72 deletions

File tree

src/app/exercise/[id]/ExercisePageClient.tsx

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ export default function ExercisePageClient({ params }: { params: Promise<{ id: s
150150
const pathname = usePathname();
151151
const [isMobile, setIsMobile] = useState(false);
152152
const [activeMobileTab, setActiveMobileTab] = useState<'source' | 'viz' | 'log' | 'misc'>('source');
153-
const mobileShellRef = useRef<HTMLDivElement | null>(null);
154-
const mobileWorkspacePanelRef = useRef<HTMLDivElement | null>(null);
155-
const mobileDirectionsRef = useRef<HTMLDivElement | null>(null);
156-
const mobileBottomDockRef = useRef<HTMLDivElement | null>(null);
157153

158154
useEffect(() => {
159155
if (typeof window === 'undefined') return;
@@ -209,67 +205,6 @@ export default function ExercisePageClient({ params }: { params: Promise<{ id: s
209205
setActiveMobileTab('source');
210206
}, [id]);
211207

212-
useEffect(() => {
213-
if (!isMobile) {
214-
mobileShellRef.current?.style.removeProperty('--mobile-workspace-panel-height');
215-
return;
216-
}
217-
218-
const shellElement = mobileShellRef.current;
219-
const panelElement = mobileWorkspacePanelRef.current;
220-
const directionsElement = mobileDirectionsRef.current;
221-
const bottomDockElement = mobileBottomDockRef.current;
222-
223-
if (!shellElement || !panelElement || !directionsElement || !bottomDockElement) {
224-
return;
225-
}
226-
227-
let frameId = 0;
228-
229-
const syncPanelHeight = () => {
230-
frameId = 0;
231-
const shellRect = shellElement.getBoundingClientRect();
232-
const panelRect = panelElement.getBoundingClientRect();
233-
const bottomDockRect = bottomDockElement.getBoundingClientRect();
234-
const shellStyles = window.getComputedStyle(shellElement);
235-
const shellGap = parseFloat(shellStyles.rowGap || shellStyles.gap || '0') || 0;
236-
const availableHeight = Math.floor(bottomDockRect.top - panelRect.top - shellGap);
237-
const maxAvailableHeight = Math.floor(shellRect.bottom - panelRect.top);
238-
const nextHeight = Math.max(0, Math.min(availableHeight, maxAvailableHeight));
239-
shellElement.style.setProperty('--mobile-workspace-panel-height', `${nextHeight}px`);
240-
};
241-
242-
const queueSyncPanelHeight = () => {
243-
if (frameId !== 0) return;
244-
frameId = window.requestAnimationFrame(syncPanelHeight);
245-
};
246-
247-
queueSyncPanelHeight();
248-
249-
const observer = new ResizeObserver(() => {
250-
queueSyncPanelHeight();
251-
});
252-
253-
observer.observe(shellElement);
254-
observer.observe(directionsElement);
255-
observer.observe(bottomDockElement);
256-
257-
window.addEventListener('resize', queueSyncPanelHeight);
258-
window.visualViewport?.addEventListener('resize', queueSyncPanelHeight);
259-
window.visualViewport?.addEventListener('scroll', queueSyncPanelHeight);
260-
261-
return () => {
262-
observer.disconnect();
263-
window.removeEventListener('resize', queueSyncPanelHeight);
264-
window.visualViewport?.removeEventListener('resize', queueSyncPanelHeight);
265-
window.visualViewport?.removeEventListener('scroll', queueSyncPanelHeight);
266-
if (frameId !== 0) {
267-
window.cancelAnimationFrame(frameId);
268-
}
269-
shellElement.style.removeProperty('--mobile-workspace-panel-height');
270-
};
271-
}, [activeMobileTab, isMobile]);
272-
273208
useEffect(() => {
274209
const mainElement = document.querySelector('#app-body > main');
275210
const appElement = document.getElementById('app');
@@ -512,8 +447,8 @@ export default function ExercisePageClient({ params }: { params: Promise<{ id: s
512447

513448
if (isMobile) {
514449
return (
515-
<div className="mobile-exercise-shell" ref={mobileShellRef}>
516-
<div ref={mobileDirectionsRef}>
450+
<div className="mobile-exercise-shell">
451+
<div>
517452
<ExerciseDirectionsPanel />
518453
</div>
519454

@@ -557,7 +492,7 @@ export default function ExercisePageClient({ params }: { params: Promise<{ id: s
557492
</button>
558493
</div>
559494

560-
<div className="mobile-workspace-panel" ref={mobileWorkspacePanelRef}>
495+
<div className="mobile-workspace-panel">
561496
{activeMobileTab === 'source' && <SourcePanel showDescription={false} />}
562497
{activeMobileTab === 'viz' && (
563498
<ErrorBoundary>
@@ -576,7 +511,7 @@ export default function ExercisePageClient({ params }: { params: Promise<{ id: s
576511
</div>
577512
</section>
578513

579-
<div className="mobile-bottom-dock" ref={mobileBottomDockRef}>
514+
<div className="mobile-bottom-dock">
580515
<ErrorBoundary>
581516
<InputPanel showToolkit={false} />
582517
</ErrorBoundary>

src/app/globals.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,8 @@ button.link-button:focus-visible,
10211021

10221022
.mobile-workspace-panel {
10231023
display: flex;
1024-
flex: 0 0 auto;
1024+
flex: 1 1 0%;
10251025
flex-direction: column;
1026-
height: var(--mobile-workspace-panel-height, auto);
1027-
max-height: var(--mobile-workspace-panel-height, none);
10281026
min-height: 0;
10291027
overflow: hidden;
10301028
}

0 commit comments

Comments
 (0)