diff --git a/inventory/static/css/components/draw.css b/inventory/static/css/components/draw.css index d40b402..11470be 100644 --- a/inventory/static/css/components/draw.css +++ b/inventory/static/css/components/draw.css @@ -1,8 +1,18 @@ +.grid-widget { + display: flex; + flex-direction: column; + height: 100%; + min-width: 0; + min-height: 0; +} + .grid-widget .grid-wrap { + flex: 1 1 auto; width: 100%; - height: 80vh; + height: clamp(240px, 50vh, 700px); position: relative; overflow: hidden; + min-height: 0; } .grid-widget [data-grid] { @@ -12,12 +22,17 @@ height: 100%; touch-action: none; margin: 0 auto; + max-width: 100%; } .grid-widget [data-toolbar]::-webkit-scrollbar { height: 8px; } +.grid-widget [data-grid-wrap] { + min-width: 0; +} + .grid-widget [data-coords] { bottom: 10px; pointer-events: none; @@ -31,9 +46,11 @@ } .grid-widget [data-toolbar] { + flex: 0 0 auto; width: min(100%, var(--grid-maxw, 100%)); box-sizing: border-box; margin: 0 auto; + max-width: 100%; } .grid-widget [data-dot] { @@ -64,11 +81,11 @@ border-radius: .5rem; } -.grid-widget .dropdown-menu > *:first-child { +.grid-widget .dropdown-menu>*:first-child { margin-top: 0; } -.grid-widget .dropdown-menu > *:last-child { +.grid-widget .dropdown-menu>*:last-child { margin-bottom: 0; } diff --git a/inventory/static/js/components/draw.js b/inventory/static/js/components/draw.js index 7c7bfda..f6cf1c1 100644 --- a/inventory/static/js/components/draw.js +++ b/inventory/static/js/components/draw.js @@ -2,7 +2,6 @@ document.querySelectorAll('[data-grid-widget]').forEach((root, index) => { initGridWidget(root, { storageKey: `gridDoc:${index}` }); }); - let activeGridWidget = null; document.addEventListener('keydown', (e) => { @@ -10,7 +9,6 @@ document.addEventListener('keydown', (e) => { activeGridWidget.handleKeyDown(e); }); - function initGridWidget(root, opts = {}) { const DEFAULT_DOC = { version: 1, cellSize: 25, shapes: [] }; const MAX_HISTORY = 100; @@ -102,6 +100,8 @@ function initGridWidget(root, opts = {}) { }); }); + requestAnimationFrame(() => requestAnimationFrame(scheduleSnappedCellSize)); + const api = { handleKeyDown(e) { const key = e.key.toLowerCase(); diff --git a/inventory/templates/components/draw.html b/inventory/templates/components/draw.html index 88b8cb7..6bf02fc 100644 --- a/inventory/templates/components/draw.html +++ b/inventory/templates/components/draw.html @@ -1,240 +1,235 @@ {% macro drawWidget(uid) %} -
-
-
-
- - - - - - - -
-
- -
-
- -