Skip to content

Commit 49fe137

Browse files
committed
Fix the popover for larger images.
1 parent cc45ccf commit 49fe137

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

docs/_layouts/section.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ <h3>Table of contents</h3>
138138
{% endif %}
139139
</div>
140140
</div>
141+
142+
<div class="popup" id="popup" onclick="closePopup()">
143+
<div id="content"></div>
144+
</div>
141145
</main>
142146

143147
</body>
@@ -154,5 +158,24 @@ <h3>Table of contents</h3>
154158
section.querySelector('img').src = '/images/icons/nav-chevron-down.png';
155159
}
156160
}
161+
162+
const popover = document.getElementById('content');
163+
const scalable = document.getElementsByClassName('scalable-image');
164+
for (const scalableElement of scalable) {
165+
scalableElement.addEventListener('click', () => {
166+
const image = scalableElement.getElementsByTagName('img')[0];
167+
const title = () => image.alt ? `<h1>${image.alt}</h1>` : ''
168+
169+
popover.innerHTML = `${title()}${image.outerHTML}`
170+
171+
document.getElementById('popup')
172+
.classList.add('open')
173+
})
174+
}
175+
176+
function closePopup() {
177+
document.getElementById('popup')
178+
.classList.remove('open')
179+
}
157180
</script>
158181
</html>

docs/images/css/_popover.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
&.open {
3838
display: flex;
39+
justify-content: center;
3940
}
4041
}
4142

docs/images/css/section.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ body {
6363
@import "section-layout/page-navigation";
6464
}
6565
}
66+
67+
@import "popover";
6668
}
6769
}
6870

0 commit comments

Comments
 (0)