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

95 lines
1.8 KiB
Text
Raw Normal View History

---
2024-01-20 16:21:51 +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'
export interface Props {
2023-03-09 11:44:18 +01:00
name: string
origin: string
imageFile: string
link: string
}
const { link, imageFile, origin, name } = Astro.props
const imagePath = `/src/assets/favourites/${imageFile}`
2024-01-20 16:21:51 +01:00
const images = import.meta.glob<GlobImage>(
'/src/assets/favourites/*.{png,webp}'
)
2024-01-05 01:12:19 +01:00
const loadedImage = plsLoadImage(images, imagePath)
---
2024-01-20 16:21:51 +01:00
<a
href={link}
target="_blank"
rel="noopener noreferrer"
aria-label=`${name} - new window`
>
2023-03-11 00:18:33 +01:00
<div class="heading">{name}</div>
2024-07-20 16:34:21 +02:00
<Image src={loadedImage} alt={name} loading={'eager'}/>
2023-03-11 00:18:33 +01:00
<h2 class="subtext">
{origin}
</h2>
</a>
<style>
2023-03-09 11:44:18 +01:00
.heading {
display: flex;
height: 2.5rem;
2023-07-06 19:41:28 +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;
margin: 0px;
justify-content: center;
align-items: center;
}
2023-03-11 00:18:33 +01:00
a {
2023-07-06 19:41:28 +02:00
border-radius: 1rem;
2023-03-09 11:44:18 +01:00
display: flex;
flex-wrap: wrap;
flex-direction: column;
background-color: var(--c-darkergray);
padding: 0em 0.5em;
2024-10-01 22:12:04 +02:00
width: max(40%, 200px);
2023-03-09 11:44:18 +01:00
height: auto;
justify-content: center;
align-items: center;
text-align: center;
transition: transform var(--speed) var(--ease);
2023-03-11 00:18:33 +01:00
text-decoration: none;
border: 2px var(--c-darkgray) solid;
2024-01-20 16:21:51 +01:00
&:hover {
border: 2px var(--c-darkpurple) solid;
2024-01-20 16:21:51 +01:00
}
img {
width: min(90%, 160px);
margin: 0px 0.5rem;
2024-01-20 16:21:51 +01:00
height: auto;
border-radius: 1rem;
2024-01-20 16:21:51 +01:00
}
2023-03-09 11:44:18 +01:00
}
2023-03-09 11:44:18 +01:00
@media (min-width: 512px) {
2023-03-11 00:18:33 +01:00
a {
2023-03-09 11:44:18 +01:00
padding: 10px 10px;
width: auto;
height: auto;
2024-01-20 16:21:51 +01:00
img {
width: 160px;
2024-01-20 16:21:51 +01:00
}
}
2023-03-09 11:44:18 +01:00
}
.subtext {
color: white;
font-size: 16px;
font-weight: 600;
margin: 0.5rem;
2023-03-09 11:44:18 +01:00
line-height: 20px;
}
</style>