diff --git a/html/main.js b/html/main.js index 7c786f7..707509a 100644 --- a/html/main.js +++ b/html/main.js @@ -10,6 +10,12 @@ const toggleView = () => { } } +const toggleMedia = e => { + const img = e.target; + const preview = img.parentNode; + preview.classList.toggle("full"); +} + window.addEventListener("load", function() { const postsSection = document.querySelector(".posts-section"); const commentsSection = document.querySelector(".comments-section"); @@ -20,4 +26,11 @@ if (commentsSection) { toggleButton.addEventListener("click", toggleView); document.body.insertBefore(toggleButton, postsSection); } + +for (let preview of document.querySelectorAll(".preview")) { + const media = preview.querySelector("img") || preview.querySelector("video"); + if (media) { + media.addEventListener("click", toggleMedia); + } +} }) \ No newline at end of file diff --git a/html/style.css b/html/style.css index d49f806..27cc38a 100644 --- a/html/style.css +++ b/html/style.css @@ -19,7 +19,8 @@ body { img, video { max-width: 200px; - max-height: 300px; + max-height: 200px; + cursor: pointer; } a { @@ -139,4 +140,25 @@ button { button:hover { background-color: #1abc9c40; +} + +.preview.full { + width: 100vw; + height: 100vh; + position: fixed; + left: 0; + top: 0; + background-color: #00000080; + display: flex; + justify-content: center; + z-index: 100; + align-items: center; +} + +.preview.full img, .preview.full video { + max-width: 100vw; + max-height: 100vh; + width: 100%; + height: 100%; + object-fit: contain; } \ No newline at end of file diff --git a/utilities.py b/utilities.py index d5973f8..d7e5746 100644 --- a/utilities.py +++ b/utilities.py @@ -175,6 +175,8 @@ def create_post_page_html(post, post_html): html = html.replace("", post.title) html = html.replace("", post_html.replace("h2>", "h1>").replace( '", f"")