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

103 lines
1.9 KiB
Text

---
export interface Props {
date: string
title: string
link: string
image: string
user?: string
}
const { user, date, image, link, title } = Astro.props
const options_date: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
}
const formatted_date = new Date(date).toLocaleDateString('de-DE', options_date)
const icon: string = `background: url('/ta_icons/${image}.webp')`
let hasuser = ''
if (user !== undefined) {
hasuser = 'hasuser'
}
---
<a href={link} target="_blank" rel="noopener noreferrer" aria-label={title}>
<article>
<div style={icon}>
<h2>{title}</h2>
</div>
<p>
<span class={hasuser}>
By {user}<br /> •
</span>
{formatted_date}
</p>
</article>
</a>
<style>
span {
display: none;
}
.hasuser {
display: flex;
}
a {
text-decoration: none;
}
article {
background-color: var(--c-darkergray);
border-color: var(--c-darkgray);
padding: 10px;
text-align: center;
transition: transform var(--speed) var(--ease);
height: auto;
width: auto;
line-height: 128px;
}
article:hover {
transform: scale(var(--hover-scale));
}
article > div {
width: 128px;
height: 128px;
object-fit: cover;
object-position: 0% 0%;
}
article:hover h2 {
color: white;
background-color: var(--c-darkgray);
font-size: 18px;
display: inline-block;
vertical-align: bottom;
line-height: normal;
width: 90%;
border-radius: 5px;
opacity: 90%;
}
article h2 {
display: none;
}
p {
display: flex;
text-align: center;
justify-content: center;
align-items: center;
line-height: 100%;
text-decoration: none;
color: white;
font-size: 1rem;
font-weight: bold;
padding-top: 0.5rem;
margin: 0.5rem 0px;
flex-wrap: wrap;
flex-direction: column;
}
</style>