@@ -96,15 +129,26 @@ const { lesson, previousLesson, nextLesson } = Astro.props
function initResizer(resizer: HTMLElement) {
resizer.addEventListener("mousedown", (e) => {
- if (resizer.dataset.direction === "vertical" && window.innerWidth < 1024) return;
+ if (resizer.dataset.direction === "vertical" && window.innerWidth < 1024)
+ return;
+
+ // Check if editor is disabled by looking for collapsed class on right panel
+ const container = resizer.parentElement!;
+ const rightPanel = container.querySelector
(
+ "[data-panel='right']",
+ )!;
+ if (rightPanel.classList.contains("collapsed")) return;
e.preventDefault();
document.body.classList.add("is-resizing");
const isVertical = resizer.dataset.direction === "vertical";
- const container = resizer.parentElement!;
- const leftPanel = container.querySelector(isVertical ? "[data-panel='left']" : "[data-editor-wrapper]")!;
- const rightPanel = container.querySelector(isVertical ? "[data-panel='right']" : "[data-terminal]")!;
+ const leftPanel = container.querySelector(
+ isVertical ? "[data-panel='left']" : "[data-editor-wrapper]",
+ )!;
+ const rightPanelForResize = container.querySelector(
+ isVertical ? "[data-panel='right']" : "[data-terminal]",
+ )!;
const onMove = (ev: MouseEvent) => {
const rect = container.getBoundingClientRect();
@@ -113,21 +157,40 @@ const { lesson, previousLesson, nextLesson } = Astro.props
const resizerSize = isVertical ? 12 : 8;
let leftSize = Math.max(50, Math.min(pos, total - resizerSize - 50));
- if (Math.abs(leftSize - total / 2) < SNAP_THRESHOLD) leftSize = total / 2;
+ if (Math.abs(leftSize - total / 2) < SNAP_THRESHOLD)
+ leftSize = total / 2;
const rightSize = total - leftSize - resizerSize;
if (isVertical) {
- const collapsed = leftSize <= COLLAPSE_THRESHOLD ? "left" : rightSize <= COLLAPSE_THRESHOLD ? "right" : null;
+ const collapsed =
+ leftSize <= COLLAPSE_THRESHOLD
+ ? "left"
+ : rightSize <= COLLAPSE_THRESHOLD
+ ? "right"
+ : null;
const ratio = leftSize / (total - resizerSize);
- leftPanel.style.flex = collapsed === "left" ? "0 0 50px" : collapsed === "right" ? "1 1 0%" : `${ratio} 1 0%`;
- rightPanel.style.flex = collapsed === "left" ? "1 1 0%" : collapsed === "right" ? "0 0 50px" : `${1 - ratio} 1 0%`;
+ leftPanel.style.flex =
+ collapsed === "left"
+ ? "0 0 50px"
+ : collapsed === "right"
+ ? "1 1 0%"
+ : `${ratio} 1 0%`;
+ rightPanelForResize.style.flex =
+ collapsed === "left"
+ ? "1 1 0%"
+ : collapsed === "right"
+ ? "0 0 50px"
+ : `${1 - ratio} 1 0%`;
leftPanel.classList.toggle("collapsed", collapsed === "left");
- rightPanel.classList.toggle("collapsed", collapsed === "right");
+ rightPanelForResize.classList.toggle(
+ "collapsed",
+ collapsed === "right",
+ );
} else {
leftPanel.style.height = `${leftSize}px`;
- rightPanel.style.height = `${rightSize}px`;
+ rightPanelForResize.style.height = `${rightSize}px`;
}
};
@@ -143,15 +206,19 @@ const { lesson, previousLesson, nextLesson } = Astro.props
}
document.addEventListener("astro:page-load", () => {
- document.querySelectorAll("[data-direction]").forEach(initResizer);
+ document
+ .querySelectorAll("[data-direction]")
+ .forEach(initResizer);
});
window.addEventListener("resize", () => {
if (window.innerWidth < 1024) {
- document.querySelectorAll("[data-panel]").forEach(panel => {
- panel.style.flex = "1 1 0%";
- panel.classList.remove("collapsed");
- });
+ document
+ .querySelectorAll("[data-panel]")
+ .forEach((panel) => {
+ panel.style.flex = "1 1 0%";
+ panel.classList.remove("collapsed");
+ });
}
});
diff --git a/src/pages/index.astro b/src/pages/index.astro
index ac46eeb..e7478da 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,5 +1,5 @@
---
-import Footer from "~/components/shared/footer/Footer.astro"
+import Footer from "~/components/footer/Footer.astro"
import Community from "~/features/home/components/Community.astro"
import Hero from "~/features/home/components/Hero.astro"
import Playground from "~/features/home/components/Playground.astro"