add banner as image to art list

This commit is contained in:
Daniel Bulant 2022-12-10 00:02:47 +01:00
parent 4eb9ebc38c
commit cd4b73a1c8
2 changed files with 39 additions and 7 deletions

View file

@ -1,9 +1,16 @@
<script> <script lang="ts">
import request, { imageproxy } from "$lib/util/request"; import request, { imageproxy } from "$lib/util/request";
export var mangaId; export var mangaId: string;
export var additionalList: {
alt: string;
src: string;
width?: number;
height?: number;
color?: string;
}[] = [];
let list; let list: any;
$: list = request("cover?manga[]=" + mangaId + "&locales[]=en&locales[]=uk&locales[]=ja"); $: list = request("cover?manga[]=" + mangaId + "&locales[]=en&locales[]=uk&locales[]=ja");
export var selectedImage = null; export var selectedImage = null;
@ -17,6 +24,9 @@
<img on:click={() => selectedImage = `${imageproxy}https://uploads.mangadex.org/covers/${mangaId}/${item.attributes.fileName}.512.jpg`} width=512 height=805 src="{imageproxy}https://uploads.mangadex.org/covers/{mangaId}/{item.attributes.fileName}.512.jpg" alt="" draggable={false}> <img on:click={() => selectedImage = `${imageproxy}https://uploads.mangadex.org/covers/${mangaId}/${item.attributes.fileName}.512.jpg`} width=512 height=805 src="{imageproxy}https://uploads.mangadex.org/covers/{mangaId}/{item.attributes.fileName}.512.jpg" alt="" draggable={false}>
{/each} {/each}
{/await} {/await}
{#each additionalList as item}
<img on:click={() => selectedImage = item.src} style="{item.color ? "--box-shadow-color: " + item.color : ""};" width={item.width} height={item.height} src="{item.src}" alt="{item.alt}" draggable={false}>
{/each}
</div> </div>
<style> <style>
@ -32,10 +42,16 @@
border-radius: 5px; border-radius: 5px;
height: 10rem; height: 10rem;
width: auto; width: auto;
--box-shadow-color: white;
box-shadow: 0 0 0 0 var(--box-shadow-color);
transition: box-shadow 0.2s ease-in-out;
} }
div img:first-child { div img:first-child {
grid-column: 1 / span 2; grid-column: 1 / span 2;
grid-row: 1 / span 2; grid-row: 1 / span 2;
height: 20rem; height: 20rem;
} }
div img:hover, div img:active, div img:focus {
box-shadow: 0 0 0.5rem var(--box-shadow-color);
}
</style> </style>

View file

@ -293,6 +293,19 @@
$: smallScreenMode = width < 700; $: smallScreenMode = width < 700;
var scrollY, innerHeight; var scrollY, innerHeight;
let additionalImages = [];
$: if(anilistData) anilistData.then(data => {
if(data.bannerImage && !additionalImages.find(t => t.src === data.bannerImage)) {
additionalImages.push({
src: data.bannerImage,
alt: "Banner image",
color: data.coverImage.color
});
additionalImages = additionalImages;
}
});
</script> </script>
<svelte:window on:beforeUnload={beforeUnload} bind:innerWidth={width} bind:scrollY bind:innerHeight /> <svelte:window on:beforeUnload={beforeUnload} bind:innerWidth={width} bind:scrollY bind:innerHeight />
@ -442,7 +455,7 @@
</SwiperSlide> </SwiperSlide>
<SwiperSlide> <SwiperSlide>
<div style="min-height: 30rem;"> <div style="min-height: 30rem;">
<ArtList {mangaId} bind:selectedImage /> <ArtList {mangaId} bind:selectedImage additionalList={additionalImages} />
</div> </div>
</SwiperSlide> </SwiperSlide>
<SwiperSlide> <SwiperSlide>
@ -528,8 +541,9 @@
.hidden { .hidden {
display: none; display: none;
} }
.infoflex { .infoflex.flex {
margin: 15px; margin: 15px;
justify-content: start;
} }
.flex-wrapped { .flex-wrapped {
display: flex; display: flex;
@ -555,8 +569,10 @@
} }
.banner { .banner {
width: 100%; width: 100%;
max-height: 100%; max-height: 40vh;
object-fit: cover; object-fit: cover;
object-position: center top;
overflow: hidden;
} }
.banner-container .fader { .banner-container .fader {
position: absolute; position: absolute;
@ -565,7 +581,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 1; z-index: 1;
background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 100%); background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,1) 100%);
} }
.genre { .genre {
border-radius: 5px; border-radius: 5px;