firq-dev-website/src/components/cards/servantCard.astro

148 lines
3.2 KiB
Text
Raw Normal View History

2023-01-15 17:53:19 +01:00
---
import { Image } from 'astro:assets';
2024-07-19 22:52:15 +02:00
import type { GlobImage } from '../../types/generic'
import { plsLoadImage } from '../../utils/tools'
2023-01-15 17:53:19 +01:00
export interface Props {
2023-03-09 11:44:18 +01:00
name: string
level: string
skills: string
np: string
servantImageFile: string
bondceImageFile: string
2023-03-09 11:44:18 +01:00
ml: string
bond10: boolean
2024-10-22 21:34:18 +02:00
index: number
2023-01-15 17:53:19 +01:00
}
2024-10-22 21:34:18 +02:00
const { bond10, ml, bondceImageFile, servantImageFile, np, skills, level, name, index } = Astro.props
const servantImagePath = `/src/assets/servant/${servantImageFile}`
const bondceImagePath = `/src/assets/ce/bond-ce/${bondceImageFile}`
2024-01-05 01:12:19 +01:00
const images_servants = import.meta.glob<GlobImage>('/src/assets/servant/*.{png,webp}')
const images_bond_ces = import.meta.glob<GlobImage>('/src/assets/ce/bond-ce/*.{png,webp}')
const loadedServantImage = plsLoadImage(images_servants, servantImagePath)
const loadedBondCEImage = plsLoadImage(images_bond_ces, bondceImagePath)
2023-01-15 17:53:19 +01:00
2023-03-09 11:44:18 +01:00
let bondce_css: string = 'bond-ce'
2023-01-15 17:53:19 +01:00
if (bond10 === false) {
2023-03-09 11:44:18 +01:00
bondce_css += ' unobtained'
2023-01-15 17:53:19 +01:00
}
2024-10-22 21:34:18 +02:00
let loading: "eager" | "lazy" = index <= 5 ? "eager" : "lazy";
2023-01-15 17:53:19 +01:00
---
<article>
2024-10-22 21:34:18 +02:00
<Image src={loadedServantImage} width={128} height={128} alt={name} quality={100} loading={loading}/>
2023-03-09 11:44:18 +01:00
<h2 class="subtext">
Level {level}<br />
{skills}<br />
NP {np}
</h2>
<div class="expand-on-hover">
<Image src={loadedBondCEImage} alt="" class={bondce_css}/>
2023-03-09 11:44:18 +01:00
<h2 class="subtext">Mana Loading: {ml === 'Not Unlocked' && <br />}{ml}</h2>
</div>
2023-01-15 17:53:19 +01:00
</article>
<style>
2023-03-09 11:44:18 +01:00
.heading {
display: flex;
height: 4rem;
width: 100%;
align-items: center;
justify-content: center;
2023-07-07 18:32:14 +02:00
font-size: 24px;
2023-03-09 11:44:18 +01:00
color: white;
max-width: 200px;
padding-bottom: 0.3rem;
font-weight: bold;
}
.servants-container {
row-gap: 1em;
column-gap: 1em;
justify-content: center;
align-self: center;
}
article:hover {
transform: scale(1);
border-color: var(--c-darkpurple);
2023-03-09 11:44:18 +01:00
}
article {
display: flex;
flex-wrap: wrap;
flex-direction: column;
background-color: var(--c-darkergray);
border: 2px var(--c-darkgray) solid;
2024-10-21 22:23:25 +02:00
padding: 10px;
width: max(30%, 100px);
2023-03-09 11:44:18 +01:00
height: auto;
justify-content: center;
align-items: center;
text-align: center;
2023-07-07 18:32:14 +02:00
border-radius: 1.25rem;
2023-03-09 11:44:18 +01:00
}
article > img {
2024-10-01 22:12:04 +02:00
width: 90%;
height: auto;
2023-07-07 18:32:14 +02:00
border-radius: 2.5rem;
margin-top: 0.75rem;
2023-03-09 11:44:18 +01:00
}
.subtext {
color: white;
font-size: 16px;
font-weight: 600;
margin: 5;
line-height: 20px;
}
.expand-on-hover {
background-color: var(--c-darkergray);
border: 2px var(--c-darkpurple) solid;
border-top: 0px;
2023-03-09 11:44:18 +01:00
z-index: 99;
transform: scaleY(0);
transform-origin: top;
position: absolute;
2023-07-07 18:37:58 +02:00
top: 92.5%;
2023-07-07 18:32:14 +02:00
border-radius: 0px 0px 1.25rem 1.25rem;
width: 100%;
2023-03-09 11:44:18 +01:00
}
article:hover .expand-on-hover {
transform: scaleY(1);
transition: transform 200ms ease-in-out;
}
.bond-ce {
2024-10-21 22:23:25 +02:00
padding-top: 0.25rem;
2023-12-25 18:58:27 +01:00
width: auto;
2024-10-21 22:23:25 +02:00
height: 3rem;
2023-03-09 11:44:18 +01:00
}
.unobtained {
filter: grayscale(1);
}
2023-03-16 19:30:03 +01:00
@media (min-width: 512px) {
article {
2023-07-07 18:37:58 +02:00
padding: 10px;
2023-03-16 19:30:03 +01:00
width: auto;
height: auto;
}
article > img {
width: 128px;
height: 128px;
2023-03-16 19:30:03 +01:00
}
.bond-ce {
height: 3rem;
2023-07-07 18:37:58 +02:00
}
2023-03-16 19:30:03 +01:00
}
2023-03-09 11:44:18 +01:00
</style>