Stacked thumbnail appearance for pool list page

This commit is contained in:
Ruin0x11 2021-05-08 16:15:59 -07:00
parent 161a3939c9
commit eee9b70b0e
3 changed files with 43 additions and 7 deletions

View file

@ -3,7 +3,6 @@
.pool-list .pool-list
ul ul
list-style-type: none list-style-type: none
margin: 0
padding: 0 padding: 0
display: flex display: flex
align-content: flex-end align-content: flex-end
@ -13,7 +12,7 @@
li li
position: relative position: relative
flex-grow: 1 flex-grow: 1
margin: 0 0.25em 0.5em 0.25em margin: 2em 1.5em 2em 1.2em;
display: inline-block display: inline-block
text-align: left text-align: left
min-width: 10em min-width: 10em
@ -38,6 +37,23 @@
outline-offset: -3px outline-offset: -3px
&:not(.empty) &:not(.empty)
background-position: 50% 30% background-position: 50% 30%
position: absolute
display: inline-block
.thumbnail-1
right: -0px;
top: -0px;
z-index: 30;
.thumbnail-2
right: -10px;
top: -10px;
z-index: 20;
.thumbnail-3
right: -20px;
top: -20px;
z-index: 10;
.pool-name .pool-name
color: black color: black
@ -80,9 +96,11 @@
li li
min-width: inherit min-width: inherit
width: inherit width: inherit
margin: 0 0.25em 0.5em 0.25em
&:not(.flexbox-dummy) &:not(.flexbox-dummy)
height: 14vw height: 14vw
.thumbnail .thumbnail
position: static
outline-offset: -1px outline-offset: -1px
.thumbnail-wrapper.no-tags .thumbnail-wrapper.no-tags
.thumbnail .thumbnail

View file

@ -4,8 +4,8 @@
<% for (let pool of ctx.response.results) { %> <% for (let pool of ctx.response.results) { %>
<li data-pool-id='<%= pool.id %>'> <li data-pool-id='<%= pool.id %>'>
<a class='thumbnail-wrapper' href='<%= ctx.canViewPools ? ctx.formatClientLink("pool", pool.id) : "" %>'> <a class='thumbnail-wrapper' href='<%= ctx.canViewPools ? ctx.formatClientLink("pool", pool.id) : "" %>'>
<% if (ctx.canViewPosts && pool.posts.length > 0) { %> <% if (ctx.canViewPosts) { %>
<%= ctx.makeThumbnail(pool.posts.at(0).thumbnailUrl) %> <%= ctx.makePoolThumbnails(pool.posts, ctx.postFlow) %>
<% } %> <% } %>
</a> </a>
<div class='pool-name'> <div class='pool-name'>

View file

@ -40,12 +40,12 @@ function makeRelativeTime(time) {
); );
} }
function makeThumbnail(url) { function makeThumbnail(url, klass) {
return makeElement( return makeElement(
"span", "span",
url url
? { ? {
class: "thumbnail", class: klass || "thumbnail",
style: `background-image: url(\'${url}\')`, style: `background-image: url(\'${url}\')`,
} }
: { class: "thumbnail empty" }, : { class: "thumbnail empty" },
@ -53,6 +53,23 @@ function makeThumbnail(url) {
); );
} }
function makePoolThumbnails(posts, postFlow) {
if (posts.length == 0) {
return makeThumbnail(null);
}
if (postFlow) {
return makeThumbnail(posts.at(0).thumbnailUrl);
}
let s = "";
for (let i = 0; i < Math.min(3, posts.length); i++) {
s += makeThumbnail(posts.at(i).thumbnailUrl, "thumbnail thumbnail-" + (i+1));
}
return s;
}
function makeRadio(options) { function makeRadio(options) {
_imbueId(options); _imbueId(options);
return makeElement( return makeElement(
@ -254,7 +271,7 @@ function makePoolLink(id, includeHash, includeCount, pool, name) {
misc.escapeHtml(text) misc.escapeHtml(text)
) )
: makeElement( : makeElement(
"span", "div",
{ class: misc.makeCssName(category, "pool") }, { class: misc.makeCssName(category, "pool") },
misc.escapeHtml(text) misc.escapeHtml(text)
); );
@ -436,6 +453,7 @@ function getTemplate(templatePath) {
makeFileSize: makeFileSize, makeFileSize: makeFileSize,
makeMarkdown: makeMarkdown, makeMarkdown: makeMarkdown,
makeThumbnail: makeThumbnail, makeThumbnail: makeThumbnail,
makePoolThumbnails: makePoolThumbnails,
makeRadio: makeRadio, makeRadio: makeRadio,
makeCheckbox: makeCheckbox, makeCheckbox: makeCheckbox,
makeSelect: makeSelect, makeSelect: makeSelect,