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

192 lines
4.2 KiB
Text
Raw Normal View History

---
import { Image } from 'astro:assets'
2024-07-19 22:52:15 +02:00
import type { GlobImage } from '../../types/generic'
import { plsLoadImage } from '../../utils/tools'
2024-01-05 01:12:19 +01:00
export interface Props {
date: string
2023-03-09 11:44:18 +01:00
title: string
link: string
targetImageFile: string
2023-03-11 19:59:51 +01:00
user?: string
servantImageFile?: string
turns?: string
}
const { turns, targetImageFile, user, date, servantImageFile, link, title } =
Astro.props
const options_date: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
}
const targetImagePath = `/src/assets/ta_icons/${targetImageFile}`
const servantImagePath = `/src/assets/ta_icons/ta_servants/${servantImageFile}`
const formatted_date = new Date(date).toLocaleDateString('de-DE', options_date)
2024-01-05 01:12:19 +01:00
const target_images = import.meta.glob<GlobImage>(
'/src/assets/ta_icons/*.{png,webp}'
)
2024-01-05 01:12:19 +01:00
const servant_images = import.meta.glob<GlobImage>(
'/src/assets/ta_icons/ta_servants/*.{png,webp}'
)
2023-03-11 19:59:51 +01:00
2024-01-05 01:12:19 +01:00
const loadedServantImage = plsLoadImage(servant_images, servantImagePath)
const loadedTargetImage = plsLoadImage(target_images, targetImagePath)
2024-10-23 17:28:06 +02:00
const hasuser = user !== undefined ? 'display: flex' : 'display: none'
---
2023-03-09 11:44:18 +01:00
2023-01-27 11:16:01 +01:00
<a href={link} target="_blank" rel="noopener noreferrer" aria-label={title}>
2024-10-23 17:28:06 +02:00
<div class="imagecontainer">
<Image src={loadedTargetImage} alt={title} />
<div class="title">
<h2>{title}</h2>
2023-03-09 11:44:18 +01:00
</div>
2024-10-23 17:28:06 +02:00
</div>
<p>
<span style={hasuser}>By {user}<br />•</span>
{formatted_date}
</p>
<div class="expand-on-hover">
<Image src={loadedServantImage} alt="" />
<h2>{turns}</h2>
</div>
</a>
<style>
2024-10-29 22:17:38 +01:00
* {
transition: all var(--a-time-default) var(--a-animation-1);
}
a {
text-decoration: none;
2024-10-23 17:28:06 +02:00
display: flex;
flex-direction: column;
flex-wrap: wrap;
2024-10-24 18:52:33 +02:00
background-color: var(--c-primary-background);
border: 2px var(--c-primary-background) solid;
padding: 10px;
text-align: center;
2024-10-23 17:28:06 +02:00
width: max(30%, 100px);
height: auto;
2023-07-08 14:38:36 +02:00
border-radius: 1.25rem;
justify-content: center;
align-items: center;
2024-10-23 17:28:06 +02:00
z-index: 1;
2023-03-09 11:44:18 +01:00
}
2024-10-23 17:28:06 +02:00
a:hover {
2024-10-21 22:23:25 +02:00
transform: scale(1);
2024-10-24 18:52:33 +02:00
border-color: var(--c-accent-1);
2024-10-23 17:28:06 +02:00
z-index: 10;
2023-03-09 11:44:18 +01:00
}
2024-10-23 17:28:06 +02:00
.imagecontainer {
display: flex;
width: 90%;
height: auto;
position: relative;
}
.imagecontainer > img {
width: 100%;
height: auto;
2023-07-08 14:38:36 +02:00
border-radius: 1.25rem;
2023-03-09 11:44:18 +01:00
}
2024-10-23 17:28:06 +02:00
a:hover .title {
display: flex;
2023-07-08 14:38:36 +02:00
position: absolute;
align-items: center;
justify-content: center;
text-align: center;
2024-10-24 18:52:33 +02:00
background-color: var(--c-primary-background);
2024-10-23 17:28:06 +02:00
width: 100%;
height: 100%;
opacity: 90%;
2024-10-24 18:52:33 +02:00
box-shadow: 0px 0px 0px 1px var(--c-primary-background);
2023-07-08 14:38:36 +02:00
border-radius: 1.25rem;
2023-03-09 11:44:18 +01:00
}
2024-10-23 17:28:06 +02:00
a:hover .title h2 {
margin: 4px;
display: inline-flex;
2024-10-23 17:28:06 +02:00
font-weight: 500;
2024-10-24 18:52:33 +02:00
color: var(--c-primary-text);
2024-10-23 17:28:06 +02:00
font-size: 1rem;
line-height: 150%;
}
2024-10-23 17:28:06 +02:00
a .title {
display: none;
}
p {
display: flex;
2024-10-23 17:28:06 +02:00
flex-wrap: wrap;
flex-direction: column;
text-align: center;
justify-content: center;
2023-03-11 19:59:51 +01:00
align-items: center;
line-height: 100%;
text-decoration: none;
2024-10-24 18:52:33 +02:00
color: var(--c-primary-text);
font-size: 1rem;
2024-10-23 17:28:06 +02:00
font-weight: 400;
2024-10-25 15:26:25 +02:00
margin: 0.5rem 0px 0.625rem 0px;
}
.expand-on-hover {
display: flex;
flex-direction: row;
flex-wrap: wrap;
2024-10-21 22:23:25 +02:00
align-items: top;
justify-content: space-evenly;
2024-10-24 18:52:33 +02:00
background-color: var(--c-primary-background);
2024-10-29 22:17:38 +01:00
border: 2px var(--c-primary-background) solid;
2024-10-21 22:23:25 +02:00
border-top: 0px;
z-index: 99;
transform: scaleY(0);
transform-origin: top;
position: absolute;
2024-10-25 15:26:25 +02:00
top: 87.5%;
2024-10-23 17:28:06 +02:00
padding-top: 0.5rem;
margin-top: 0.2rem;
2024-10-24 18:52:33 +02:00
color: var(--c-primary-text);
2023-07-08 14:38:36 +02:00
border-radius: 0px 0px 1.25rem 1.25rem;
2024-10-21 22:23:25 +02:00
width: 100%;
}
.expand-on-hover img {
2024-10-23 17:28:06 +02:00
width: 2.5rem;
height: auto;
2023-07-08 14:38:36 +02:00
margin-bottom: 0.5rem;
border-radius: 0.5rem;
}
.expand-on-hover h2 {
margin: 0.5rem;
}
2024-10-23 17:28:06 +02:00
a:hover .expand-on-hover {
transform: scaleY(1);
2024-10-29 22:17:38 +01:00
transition: all var(--a-time-default) var(--a-animation-1);
2024-10-24 18:52:33 +02:00
background-color: var(--c-primary-background);
2024-10-29 22:17:38 +01:00
border-color: var(--c-accent-1);
}
2024-10-23 17:28:06 +02:00
@media (min-width: 512px) {
a {
padding: 10px;
width: auto;
height: auto;
}
a > .imagecontainer {
width: 112px;
height: 112px;
}
}
2023-03-09 11:44:18 +01:00
</style>