From cff0cc6dd6e244da9c35f620585598a4e396652b Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 3 Jul 2024 09:26:48 -0700 Subject: Make stairs visible on roof levels --- public/assets/css/style.css | 6 ++++-- public/assets/images/radial.svg | 14 +++++++------- public/index.html | 4 ++++ src/index.js | 6 ++++++ src/radial.js | 18 ++++++++++-------- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/public/assets/css/style.css b/public/assets/css/style.css index f98baca..5960f99 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -490,9 +490,11 @@ input#content-visibility-toggle { } .select-elevation input:checked+label { - border: 1px solid salmon; + border: 1px solid #666; border-radius: 3px; - background-color: #cdd9e9; + background-color: orangered; + color: white; + font-weight: bold; } div#dice { diff --git a/public/assets/images/radial.svg b/public/assets/images/radial.svg index 69390f9..8e9530c 100644 --- a/public/assets/images/radial.svg +++ b/public/assets/images/radial.svg @@ -200,8 +200,8 @@ - + @@ -309,8 +309,8 @@ - + @@ -349,8 +349,8 @@ - + @@ -384,8 +384,8 @@ - + @@ -430,8 +430,8 @@ - + @@ -472,15 +472,14 @@ - + - @@ -518,6 +517,7 @@ + diff --git a/public/index.html b/public/index.html index 570123e..25b0596 100644 --- a/public/index.html +++ b/public/index.html @@ -125,6 +125,10 @@ + + + + diff --git a/src/index.js b/src/index.js index 24e017d..2ab35fa 100644 --- a/src/index.js +++ b/src/index.js @@ -249,6 +249,12 @@ document.querySelectorAll('[name="select-elevation"]').forEach(el => { }); }); +document.querySelector('#toggle-grid-vis input').addEventListener('change', function () { + const svg = document.querySelector('object').contentDocument.querySelector('svg'); + svg.querySelector('.grid').style.display = this.checked ? 'inline' : 'none'; + svg.querySelector('#dots').style.display = this.checked ? 'inline' : 'none'; +}); + contentVisToggleEl.addEventListener('input', toggleContentVis); contentVisToggleEl.checked = (localStorage.getItem('content-visibility') !== 'false'); toggleContentVis(); diff --git a/src/radial.js b/src/radial.js index 046b608..c6e52a6 100644 --- a/src/radial.js +++ b/src/radial.js @@ -413,7 +413,7 @@ function addElevationClass(element) { return el => element.classList.add(elevationClass(el)); } -function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) { +function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, features) { return buildings.reduce((acc, building) => { const buildingContainer = document.createElementNS(xmlns, 'g'); buildingContainer.classList.add(`building`); @@ -465,17 +465,19 @@ function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) if ((use.classList.contains('doors') || use.classList.contains('door-edges')) && !use.classList.contains('exits')) building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - if (use.classList.contains('furniture')) - building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - buildingStructure.appendChild(use); } - const furnitureEl = furniture && furniture.querySelector(`.${building.type} .furniture`); + const featuresEl = features && features.querySelector(`.${building.type}`); + + for (let child of [...featuresEl.children]) { + if (child.classList.contains('furniture')) + building.elevationLevels.slice(0, -1).forEach(addElevationClass(child)); + + if (child.classList.contains('stairs')) + building.elevationLevels.forEach(addElevationClass(child)); - if (furnitureEl) { - building.elevationLevels.slice(0, -1).forEach(addElevationClass(furnitureEl)); - buildingStructure.appendChild(furnitureEl); + buildingStructure.appendChild(child); } return acc; -- cgit v1.2.3