Complete rewrite (#1)
A complete rewrite of the gallery plugin: * Using flexbox * Using lightweight JS for lightbox to avoid anchor links, and allow full rotation * Add slideshow as an additional field * Make many more things configurable * Better support for dirs, allow mixed paths * Translatable captions for many files using metadata files * SCSS instead of CSS Reviewed-on: #1 Co-authored-by: Max Mehl <mail@mehl.mx> Co-committed-by: Max Mehl <mail@mehl.mx>
This commit was merged in pull request #1.
This commit is contained in:
255
assets/scss/snap-gallery.scss
Normal file
255
assets/scss/snap-gallery.scss
Normal file
@@ -0,0 +1,255 @@
|
||||
$gap: var(--gap);
|
||||
|
||||
.snap-gallery,
|
||||
.snap-slideshow {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-bottom: 15px;
|
||||
|
||||
/* Create equal columns in flexbox */
|
||||
.snap-image {
|
||||
cursor: var(--cursor);
|
||||
|
||||
/* Column amount and width are configurable by style variables */
|
||||
width: calc(100% / var(--columns) - #{$gap});
|
||||
min-width: var(--min-width);
|
||||
|
||||
img {
|
||||
aspect-ratio: var(--aspectratio);
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.snap-gallery {
|
||||
flex-wrap: wrap;
|
||||
gap: $gap;
|
||||
}
|
||||
|
||||
.snap-slideshow {
|
||||
width: var(--slideshow-width);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
||||
// Hide all contained images except the first
|
||||
.snap-image:not(:first-child) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
// Animation
|
||||
.snap-slideshow .snap-image,
|
||||
.snap-lightbox .snap-lightbox-inner {
|
||||
animation: 1s fade;
|
||||
|
||||
@keyframes fade {
|
||||
from {
|
||||
opacity: .4
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.snap-lightbox {
|
||||
/** Default lightbox to hidden */
|
||||
display: none;
|
||||
|
||||
/** Position and style */
|
||||
position: fixed;
|
||||
z-index: 999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
|
||||
/* keep lightbox in middle. TODO: hacky, and not realibly in middle */
|
||||
&:before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 0;
|
||||
/* adjust for white space between pseudo element and next sibling */
|
||||
margin-right: -.25em;
|
||||
/* stretch line height */
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
// Disable cursor selection in lightbox and on slideshow, especially controls
|
||||
.snap-lightbox,
|
||||
.snap-slideshow {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
// /* Click on the complete background closes the lightbox */
|
||||
// /* Exception: arrow in gallery, they have higher z-index */
|
||||
// a.snap-lightbox-close {
|
||||
// position: fixed;
|
||||
// z-index: 800;
|
||||
// width: 100%;
|
||||
// height: 100%;
|
||||
// text-align: center;
|
||||
// white-space: nowrap;
|
||||
// top: 0;
|
||||
// left: 0;
|
||||
// }
|
||||
|
||||
/* Container for image */
|
||||
.snap-lightbox-inner {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
white-space: normal;
|
||||
max-width: 90%;
|
||||
max-height: 80%;
|
||||
height: 100%;
|
||||
|
||||
img {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
max-width: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Number text (1/3 etc) and captions*/
|
||||
.snap-numbertext {
|
||||
position: absolute;
|
||||
color: #f2f2f2;
|
||||
background-color: #000;
|
||||
font-size: 12px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.snap-caption {
|
||||
bottom: 0;
|
||||
color: #f2f2f2;
|
||||
padding: 8px 0;
|
||||
left: 10%;
|
||||
width: 80%;
|
||||
text-shadow: 1px 1px 10px #000;
|
||||
font-weight: 700;
|
||||
font-size: 1.1em;
|
||||
text-align: center;
|
||||
|
||||
// As slideshow, position on picture on mid-screens and wider
|
||||
.snap-slideshow & {
|
||||
position: absolute;
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
// In lightbox, always show below picture
|
||||
.snap-lightbox & {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
// /* Caption text */
|
||||
// .caption-container {
|
||||
// text-align: center;
|
||||
// background-color: black;
|
||||
// padding: 2px 16px;
|
||||
// color: white;
|
||||
// }
|
||||
|
||||
/* prev/next arrows & close button */
|
||||
.snap-prev,
|
||||
.snap-next {
|
||||
color: #fff;
|
||||
text-decoration: none !important;
|
||||
font-size: 30px;
|
||||
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
z-index: 800;
|
||||
width: 5%;
|
||||
cursor: pointer;
|
||||
|
||||
// Slideshow specifics
|
||||
.snap-slideshow & {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
|
||||
height: 15%;
|
||||
width: 10%;
|
||||
min-height: 50px;
|
||||
min-width: 50px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
}
|
||||
|
||||
// Lightbox-specifics
|
||||
.snap-lightbox & {
|
||||
@media screen and (max-width: 767px) {
|
||||
width: 10%;
|
||||
}
|
||||
}
|
||||
|
||||
// Item containing arrow
|
||||
span {
|
||||
padding: 1%;
|
||||
|
||||
// Lightbox specifics
|
||||
.snap-lightbox & {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Position arrows for left/right
|
||||
.snap-prev {
|
||||
left: 0;
|
||||
|
||||
.snap-lightbox & span {
|
||||
left: 0.5%;
|
||||
}
|
||||
}
|
||||
|
||||
.snap-next {
|
||||
right: 0;
|
||||
|
||||
.snap-lightbox & span {
|
||||
right: 0.5%;
|
||||
}
|
||||
}
|
||||
|
||||
/* The Close Button */
|
||||
.snap-close {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 15px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
color: white;
|
||||
font-size: 50px;
|
||||
font-weight: bold;
|
||||
z-index: 900;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: #999;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user