Skip to content

Commit

Permalink
if only one item in gallery, remove navigation (pytest-dev#705)
Browse files Browse the repository at this point in the history
Co-authored-by: Viktor Gustafsson <[email protected]>
  • Loading branch information
drRedflint and drkieferredflint authored Aug 13, 2023
1 parent a5e92c2 commit 8b7eca5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/layout/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ div.media {
overflow: hidden;
height: 200px;
}
.media-container--fullscreen {
grid-template-columns: 0px auto 0px;
}
.media-container__nav--right,
.media-container__nav--left {
text-align: center;
Expand Down
4 changes: 4 additions & 0 deletions src/pytest_html/resources/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/pytest_html/scripts/mediaviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const setup = (resultBody, assets) => {
}

const mediaViewer = new MediaViewer(assets)
const container = resultBody.querySelector('.media-container')
const leftArrow = resultBody.querySelector('.media-container__nav--left')
const rightArrow = resultBody.querySelector('.media-container__nav--right')
const mediaName = resultBody.querySelector('.media__name')
Expand Down Expand Up @@ -68,9 +69,12 @@ const setup = (resultBody, assets) => {
const openImg = () => {
window.open(mediaViewer.activeFile.path, '_blank')
}

leftArrow.addEventListener('click', moveLeft)
rightArrow.addEventListener('click', doRight)
if (assets.length === 1) {
container.classList.add('media-container--fullscreen')
} else {
leftArrow.addEventListener('click', moveLeft)
rightArrow.addEventListener('click', doRight)
}
imageEl.addEventListener('click', openImg)
}

Expand Down

0 comments on commit 8b7eca5

Please sign in to comment.