website-astro/src/components/CardEditorial.astro

140 lines
2.8 KiB
Plaintext
Raw Normal View History

2022-12-22 11:01:52 +01:00
---
2022-12-28 10:36:15 +01:00
import ListTags from "./ListTags.astro";
2023-04-19 18:24:40 +02:00
import { l, t } from "astro-i18n";
2023-02-03 18:48:01 +01:00
2022-12-22 11:01:52 +01:00
const { item, routeName } = Astro.props;
2023-04-19 18:24:40 +02:00
// no link on references cards
const isReference = routeName === t("references.slug");
2022-12-22 11:01:52 +01:00
---
2023-04-19 18:24:40 +02:00
<div class:list={["card", { "card--link": !isReference }]}>
2022-12-22 11:01:52 +01:00
<div>
<h3>
2023-04-19 18:24:40 +02:00
{
!isReference ? (
<a
class="clean-link card__link"
href={`${l(`/${routeName}`)}/${item.slug}`}
>
{item.data.title}
</a>
) : (
<span>{item.data.title}</span>
)
}
2022-12-22 11:01:52 +01:00
</h3>
2022-12-28 10:36:15 +01:00
<h4>{item.data.subtitle}</h4>
<ListTags list={item.data.tags} />
2023-04-19 18:24:40 +02:00
{
isReference && (
<a href={item.data.url} rel="noopener noreferer">
{t("references.cta")}
<span class="sr-only"> {item.data.title}</span>
</a>
)
}
2022-12-22 11:01:52 +01:00
</div>
</div>
<style scoped>
.card {
2022-12-28 10:36:15 +01:00
padding: var(--space-s-m) var(--space-xs-s);
2022-12-22 11:01:52 +01:00
position: relative;
display: block;
2022-12-28 10:36:15 +01:00
block-size: 100%;
overflow: hidden;
2022-12-22 11:01:52 +01:00
box-shadow: var(--shadow-elevation-medium);
2022-12-28 10:36:15 +01:00
background-color: white;
2022-12-22 11:01:52 +01:00
}
2023-04-19 18:24:40 +02:00
/*
* to be replaced with .card:has(a)
* when firefox supports it
*/
.card--link:hover {
2022-12-22 11:01:52 +01:00
box-shadow: var(--shadow-elevation-high);
}
2023-04-19 18:24:40 +02:00
.card--link:focus-within {
2022-12-22 11:01:52 +01:00
box-shadow: var(--shadow-elevation-high);
}
2023-04-19 18:24:40 +02:00
.card--link::after {
2022-12-28 10:36:15 +01:00
content: "";
position: absolute;
inline-size: 30px;
block-size: 30px;
top: var(--space-m);
right: var(--space-s);
opacity: 0;
background-image: url("/assets/svg/arrow-right.svg");
background-repeat: no-repeat;
background-position: center;
background-size: contain;
transform: translateX(1rem);
}
2023-04-19 18:24:40 +02:00
.card--link:hover::after,
.card--link:focus-within::after {
2022-12-22 11:01:52 +01:00
transform: translateX(0);
opacity: 1;
}
2023-04-19 18:24:40 +02:00
.card--link:hover h3 a {
2022-12-28 10:36:15 +01:00
text-decoration: underline;
}
2023-04-19 18:24:40 +02:00
.card--link:hover h3 a,
.card--link:focus-within h3 a {
2022-12-28 10:36:15 +01:00
color: var(--color-brique);
2022-12-22 11:01:52 +01:00
}
2023-04-19 18:24:40 +02:00
.card--link::before {
2022-12-22 11:01:52 +01:00
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
2022-12-28 10:36:15 +01:00
block-size: 100%;
inline-size: 2px;
2022-12-22 11:01:52 +01:00
transform: scaleY(0);
transform-origin: bottom;
2022-12-28 10:36:15 +01:00
background-color: var(--color-brique);
2022-12-22 11:01:52 +01:00
}
2023-04-19 18:24:40 +02:00
.card--link:hover::before,
.card--link:focus-within::before {
2022-12-22 11:01:52 +01:00
transform: scaleY(1);
transform-origin: top;
}
h3 {
2022-12-28 10:36:15 +01:00
padding-inline-end: var(--space-s-m);
font-size: var(--size-2);
2022-12-22 11:01:52 +01:00
font-weight: bold;
text-transform: none;
}
2022-12-28 10:36:15 +01:00
.card__link {
color: var(--color-blue);
}
.card__link::after {
content: "";
2022-12-22 11:01:52 +01:00
position: absolute;
2022-12-28 10:36:15 +01:00
inset: 0;
2022-12-22 11:01:52 +01:00
}
@media (prefers-reduced-motion: no-preference) {
.card {
transition: box-shadow 0.2s ease;
}
.card::before {
transition: transform 0.2s ease-in-out;
}
2022-12-28 10:36:15 +01:00
.card::after {
2022-12-22 11:01:52 +01:00
transition: opacity ease 0.2s, transform ease 0.2s;
}
2022-12-28 10:36:15 +01:00
h3 a {
transition: color ease 0.2s;
}
2022-12-22 11:01:52 +01:00
}
.card h4 {
2022-12-28 10:36:15 +01:00
margin-block-start: var(--space-2xs);
font-size: var(--size-0);
2022-12-22 11:01:52 +01:00
font-weight: 500;
color: var(--darkBlue);
}
</style>