mdaines / grammophone

A tool for analyzing and transforming context-free grammars.
https://mdaines.github.io/grammophone
MIT License
206 stars 24 forks source link

Resizable master panel #24

Open primozpadar opened 1 year ago

primozpadar commented 1 year ago

Example how this can be achieved with css variables:

  function handleMouseDown() {
    document.addEventListener("mousemove", handleMouseMove);
    document.addEventListener("mouseup", handleMouseUp, { once: true });
  }

  function handleMouseMove(e) {
    const width = Math.max(MIN_WIDTH, e.screenX);
    document.documentElement.style.setProperty("--editor-width", `${width}px`);
  }

  function handleMouseUp() {
    document.removeEventListener("mousemove", handleMouseMove);
  }

And add --editor-width to the css root

:root {
    --editor-width: 300px;
}