mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-23 23:53:44 +01:00
Implement a css-only gallery, with descriptions!
It's an absolutely *glorious* series of hacks :D Including, but certainly not limited to: - CSS Grids with only 1 cell - Flexboxes used for positioning text nodes - Element heights set indirectly with the width property - z-index abused to show the current image in the sequence it's undefined which image will be shown initially, but given the amount of effort this took I'm ok with that If anyone knows how to shift the <picture> element 0.25em upwards *without* moving the image so that I can remove the upper and lower borders, I'd lvoe to know. I've tried everything - including settingit's height to zero etc. In the end I've padded out the top to balance it out instead :P
This commit is contained in:
parent
b88080a698
commit
8a500735c0
@ -47,19 +47,16 @@ async function shortcode_image_url(src) {
|
|||||||
return data.url;
|
return data.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function shortcode_cssbox(content, src) {
|
async function shortcode_gallerybox(content, src, idthis, idprev, idnext) {
|
||||||
let idprev = `image-${nextid}`;
|
return `<figure class="gallerybox-item" id="${idthis}">
|
||||||
nextid += 1;
|
<!-- ${await shortcode_image(src, "", "gallerybox-thumb", "300w")} -->
|
||||||
let idthis = `image-${nextid}`;
|
${await shortcode_image(src, "", "", "1920w")}
|
||||||
let idnext = `image-${nextid + 1}`;
|
|
||||||
return `<div class="cssbox">
|
<figcaption>${content}</figcaption>
|
||||||
<a id="${idthis}" href="#${idthis}">${await shortcode_image(src, content, "cssbox_thumb", "300w")}
|
|
||||||
<span class="cssbox_full">${await shortcode_image(src, content, "", "1920w")}</span>
|
<a class="gallerybox-prev" href="#${idprev}">❰</a>
|
||||||
</a>
|
<a class="gallerybox-next" href="#${idnext}">❱</a>
|
||||||
<a class="cssbox_close" href="#void"></a>
|
</figure>`;
|
||||||
<a class="cssbox_prev" href="#${idprev}"><</a>
|
|
||||||
<a class="cssbox_next" href="#${idnext}">></a>
|
|
||||||
</div>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(eleventyConfig) {
|
module.exports = function(eleventyConfig) {
|
||||||
@ -68,5 +65,5 @@ module.exports = function(eleventyConfig) {
|
|||||||
eleventyConfig.addShortcode("image", shortcode_image);
|
eleventyConfig.addShortcode("image", shortcode_image);
|
||||||
eleventyConfig.addJavaScriptFunction("image", shortcode_image);
|
eleventyConfig.addJavaScriptFunction("image", shortcode_image);
|
||||||
eleventyConfig.addShortcode("image-url", shortcode_image_url);
|
eleventyConfig.addShortcode("image-url", shortcode_image_url);
|
||||||
eleventyConfig.addPairedShortcode("cssbox", shortcode_cssbox);
|
eleventyConfig.addPairedShortcode("gallerybox", shortcode_gallerybox);
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
permalink: theme.css
|
permalink: theme.css
|
||||||
---
|
---
|
||||||
{% include "css/theme.css" %}
|
{% include "css/theme.css" %}
|
||||||
{% include "css/CSSBox/cssbox.css" %}
|
{% include "css/gallerybox.css" %}
|
||||||
|
109
.docs/css/gallerybox.css
Normal file
109
.docs/css/gallerybox.css
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
.gallerybox {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
/*
|
||||||
|
The <picture /> element causes a small amount of extra padding at the
|
||||||
|
bottom of the element, so we use this to balance out the look at the top
|
||||||
|
ideally we'd shift the <picture> out of the way, but we can't without also
|
||||||
|
shifting the <img /> inside
|
||||||
|
*/
|
||||||
|
padding-top: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallerybox-gallery {
|
||||||
|
--gallerybox-nextprev-padding: 5vw;
|
||||||
|
--gallerybox-nextprev-move: 0.2em;
|
||||||
|
--gallerybox-nextprev-hover: 0.1em;
|
||||||
|
|
||||||
|
max-width: 80vmax;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto;
|
||||||
|
grid-template-areas: "main";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .gallerybox picture {
|
||||||
|
position: relative;
|
||||||
|
top: -1em;
|
||||||
|
}
|
||||||
|
.gallerybox picture > img {
|
||||||
|
position: relative;
|
||||||
|
top: 1em;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.gallerybox-item {
|
||||||
|
grid-area: main;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallerybox-item > figcaption {
|
||||||
|
background: hsla(0, 0%, 95%, 0.75);
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0.25em; left: 0; right: 0;
|
||||||
|
padding: 0.75em 1em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallerybox-gallery > .gallerybox-item:target {
|
||||||
|
display: block;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
/* .gallerybox-gallery > .gallerybox-item:not(:target) {
|
||||||
|
display: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.gallerybox-item:not(:target) ~ .gallerybox-item:last-child {
|
||||||
|
display: block;
|
||||||
|
z-index: 2;
|
||||||
|
} */
|
||||||
|
|
||||||
|
/*
|
||||||
|
.gallerybox-gallery:target-within > .gallerybox-item:target {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.gallerybox-gallery:target-within > .gallerybox-item:not(:target) {
|
||||||
|
display: none;
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
.gallerybox-item {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.gallerybox-item img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
:where(.gallerybox-prev, .gallerybox-next) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute; top: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 4em;
|
||||||
|
color: hsla(0, 0%, 100%, 0.8) !important;
|
||||||
|
text-decoration: none;
|
||||||
|
transform: none;
|
||||||
|
transition: transform 0.25s;
|
||||||
|
}
|
||||||
|
.gallerybox-item > .gallerybox-prev {
|
||||||
|
padding-left: var(--gallerybox-nextprev-padding);
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.gallerybox-item > .gallerybox-next {
|
||||||
|
padding-right: var(--gallerybox-nextprev-padding);
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
:where(.gallerybox-prev, .gallerybox-next):hover {
|
||||||
|
color: hsla(0, 0%, 100%, 1) !important;
|
||||||
|
}
|
||||||
|
:is(.gallerybox-prev, .gallerybox-next):active {
|
||||||
|
color: hsla(0, 0%, 100%, 1) !important;
|
||||||
|
}
|
||||||
|
.gallerybox-next:hover { transform: translateX(calc(var(--gallerybox-nextprev-hover) * -1)); }
|
||||||
|
.gallerybox-prev:hover { transform: translateX(var(--gallerybox-nextprev-hover)); }
|
||||||
|
|
||||||
|
.gallerybox-prev:active { transform: translateX(calc(var(--gallerybox-nextprev-move) * -1)); }
|
||||||
|
.gallerybox-next:active { transform: translateX(var(--gallerybox-nextprev-move)); }
|
@ -265,3 +265,7 @@ footer {
|
|||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gallerybox {
|
||||||
|
background: var(--bg-transcluscent);
|
||||||
|
}
|
||||||
|
BIN
.docs/images/gallery-c.jpeg
Normal file
BIN
.docs/images/gallery-c.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 827 KiB |
@ -50,11 +50,16 @@ date: 2000-01-01
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- Potentially we might want some inspiration from https://codepen.io/emared/pen/gWGBLR here -->
|
<!-- Potentially we might want some inspiration from https://codepen.io/emared/pen/gWGBLR here -->
|
||||||
<section class="cssbox">
|
<section class="gallerybox">
|
||||||
{% cssbox "images/gallery-a.jpeg" %}
|
<section class="gallerybox-gallery">
|
||||||
|
{% gallerybox "images/gallery-a.jpeg" "image-first" "image-last" "image-b" %}
|
||||||
A scene demonstrating <code>//replacemix</code>, <code>//ellipsoid</code>, <code>//layers</code>, <code>smoothadv</code> (aka <code>convolve</code> and <code>conv</code>), and <code>//floodfill</code> - all of which are provided by WorldEditAdditions.
|
A scene demonstrating <code>//replacemix</code>, <code>//ellipsoid</code>, <code>//layers</code>, <code>smoothadv</code> (aka <code>convolve</code> and <code>conv</code>), and <code>//floodfill</code> - all of which are provided by WorldEditAdditions.
|
||||||
{% endcssbox %}
|
{% endgallerybox %}
|
||||||
{% cssbox "images/gallery-b.jpeg" %}
|
{% gallerybox "images/gallery-b.jpeg" "image-b" "image-first" "image-last" %}
|
||||||
The inside of a 3d maze made with <code>//maze3d</code>. Lighting was placed manually to improve screenshot quality.
|
The inside of a 3d maze made with <code>//maze3d</code>. Lighting was placed manually to improve screenshot quality.
|
||||||
{% endcssbox %}
|
{% endgallerybox %}
|
||||||
|
{% gallerybox "images/gallery-c.jpeg" "image-last" "image-b" "image-first" %}
|
||||||
|
A cliff made with <code>//erode</code> and <code>//layers</code>. A <code>//forest</code> has been applied on top with multiple sapling / tree types.
|
||||||
|
{% endgallerybox %}
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user