refactor(glossaire): componentize glossary home sections
This commit is contained in:
83
src/components/GlossaryCardGrid.astro
Normal file
83
src/components/GlossaryCardGrid.astro
Normal file
@@ -0,0 +1,83 @@
|
||||
---
|
||||
import { hrefOfGlossaryEntry, type GlossaryEntry } from "../lib/glossary";
|
||||
|
||||
export interface Props {
|
||||
entries?: GlossaryEntry[];
|
||||
wide?: boolean;
|
||||
}
|
||||
|
||||
const {
|
||||
entries = [],
|
||||
wide = false,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<div class="glossary-cards">
|
||||
{entries.map((entry) => (
|
||||
<a
|
||||
class:list={[
|
||||
"glossary-card",
|
||||
wide && "glossary-card--wide",
|
||||
]}
|
||||
href={hrefOfGlossaryEntry(entry)}
|
||||
>
|
||||
<strong>{entry.data.term}</strong>
|
||||
<span>{entry.data.definitionShort}</span>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.glossary-cards{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.glossary-card{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--glossary-border);
|
||||
border-radius: 18px;
|
||||
background: var(--glossary-bg-soft);
|
||||
text-decoration: none;
|
||||
transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
|
||||
}
|
||||
|
||||
.glossary-card:hover{
|
||||
transform: translateY(-1px);
|
||||
background: var(--glossary-bg-soft-strong);
|
||||
border-color: rgba(0,217,255,0.16);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.glossary-card--wide{
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.glossary-card strong{
|
||||
color: var(--glossary-accent);
|
||||
font-size: 1.04rem;
|
||||
line-height: 1.28;
|
||||
}
|
||||
|
||||
.glossary-card span{
|
||||
color: inherit;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
opacity: .94;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
.glossary-card{
|
||||
background: rgba(255,255,255,0.04);
|
||||
}
|
||||
|
||||
.glossary-card:hover{
|
||||
background: rgba(255,255,255,0.07);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
103
src/components/GlossaryHomeHero.astro
Normal file
103
src/components/GlossaryHomeHero.astro
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
export interface Props {
|
||||
kicker?: string;
|
||||
title?: string;
|
||||
intro?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
kicker = "Référentiel terminologique",
|
||||
title = "Glossaire archicratique",
|
||||
intro = "Ce glossaire n’est pas seulement un index de définitions. Il constitue une porte d’entrée dans la pensée archicratique : une cartographie raisonnée des concepts fondamentaux, des scènes, des dynamiques et des méta-régimes à partir desquels une société peut être décrite comme organisation de tensions et recherche de co-viabilité.",
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<header class="glossary-hero" id="glossary-hero">
|
||||
<p class="glossary-kicker">{kicker}</p>
|
||||
<h1>{title}</h1>
|
||||
<p class="glossary-intro">{intro}</p>
|
||||
<h2
|
||||
class="glossary-hero-follow"
|
||||
id="glossary-hero-follow"
|
||||
aria-hidden="true"
|
||||
></h2>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.glossary-hero{
|
||||
position: sticky;
|
||||
top: var(--glossary-sticky-top);
|
||||
z-index: 12;
|
||||
margin-bottom: 28px;
|
||||
padding: 14px 16px 18px;
|
||||
border: 1px solid rgba(127,127,127,0.18);
|
||||
border-radius: 28px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0,0,0,0.60), rgba(0,0,0,0.90)),
|
||||
radial-gradient(900px 240px at 20% 0%, rgba(0,217,255,0.08), transparent 60%);
|
||||
transition:
|
||||
background 300ms cubic-bezier(.22,.8,.22,1),
|
||||
border-color 300ms cubic-bezier(.22,.8,.22,1),
|
||||
box-shadow 300ms cubic-bezier(.22,.8,.22,1);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
display: grid;
|
||||
row-gap: 12px;
|
||||
}
|
||||
|
||||
.glossary-kicker{
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
letter-spacing: .12em;
|
||||
text-transform: uppercase;
|
||||
opacity: .72;
|
||||
}
|
||||
|
||||
.glossary-hero h1{
|
||||
margin: 0;
|
||||
font-size: clamp(2.2rem, 4vw, 3.15rem);
|
||||
line-height: 1.02;
|
||||
letter-spacing: -.04em;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.glossary-intro{
|
||||
margin: 0;
|
||||
max-width: 72ch;
|
||||
font-size: 1.05rem;
|
||||
line-height: 1.55;
|
||||
opacity: .94;
|
||||
}
|
||||
|
||||
.glossary-hero-follow{
|
||||
margin: 2px 0 0;
|
||||
min-height: var(--glossary-follow-height);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
opacity: 0;
|
||||
transform: translateY(10px) scale(.985);
|
||||
filter: blur(6px);
|
||||
transition:
|
||||
opacity 220ms cubic-bezier(.22,1,.36,1),
|
||||
transform 320ms cubic-bezier(.22,1,.36,1),
|
||||
filter 320ms cubic-bezier(.22,1,.36,1);
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
will-change: opacity, transform, filter;
|
||||
}
|
||||
|
||||
.glossary-hero-follow.is-visible{
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
filter: blur(0);
|
||||
}
|
||||
|
||||
@media (max-width: 760px){
|
||||
.glossary-hero{
|
||||
top: calc(var(--glossary-sticky-top) - 2px);
|
||||
padding: 12px 14px 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
109
src/components/GlossaryHomeSection.astro
Normal file
109
src/components/GlossaryHomeSection.astro
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
export interface Props {
|
||||
id?: string;
|
||||
title: string;
|
||||
intro?: string;
|
||||
followSection?: string;
|
||||
ctaHref?: string;
|
||||
ctaLabel?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
id,
|
||||
title,
|
||||
intro,
|
||||
followSection,
|
||||
ctaHref,
|
||||
ctaLabel,
|
||||
} = Astro.props;
|
||||
|
||||
const resolvedFollowSection = (followSection || title || "").trim();
|
||||
const showCta = Boolean(ctaHref && ctaLabel);
|
||||
---
|
||||
|
||||
<section id={id} class="glossary-section">
|
||||
<div class="glossary-section__head">
|
||||
<div>
|
||||
<h2 data-follow-section={resolvedFollowSection}>{title}</h2>
|
||||
|
||||
{intro && (
|
||||
<p class="glossary-intro">{intro}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{showCta && (
|
||||
<a class="glossary-cta" href={ctaHref}>
|
||||
{ctaLabel}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<slot />
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.glossary-section{
|
||||
margin-top: 42px;
|
||||
scroll-margin-top: calc(var(--glossary-sticky-top) + 190px);
|
||||
}
|
||||
|
||||
.glossary-section__head{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: start;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.glossary-section h2{
|
||||
margin: 0;
|
||||
font-size: clamp(2rem, 3vw, 2.55rem);
|
||||
line-height: 1.06;
|
||||
letter-spacing: -.03em;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.glossary-intro{
|
||||
margin: 0;
|
||||
max-width: 72ch;
|
||||
font-size: 1.05rem;
|
||||
line-height: 1.55;
|
||||
opacity: .94;
|
||||
}
|
||||
|
||||
.glossary-section__head .glossary-intro{
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.glossary-cta{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 40px;
|
||||
border: 1px solid var(--glossary-border-strong);
|
||||
border-radius: 999px;
|
||||
padding: 7px 14px;
|
||||
color: var(--glossary-accent);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
transition: transform 120ms ease, background 120ms ease;
|
||||
}
|
||||
|
||||
.glossary-cta:hover{
|
||||
background: var(--glossary-bg-soft-strong);
|
||||
text-decoration: none;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
@media (max-width: 760px){
|
||||
.glossary-section__head{
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.glossary-cta{
|
||||
width: fit-content;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
91
src/components/GlossaryPortalGrid.astro
Normal file
91
src/components/GlossaryPortalGrid.astro
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
export type GlossaryPortalGridItem = {
|
||||
href: string;
|
||||
title: string;
|
||||
description: string;
|
||||
meta: string;
|
||||
};
|
||||
|
||||
export interface Props {
|
||||
items?: GlossaryPortalGridItem[];
|
||||
secondary?: boolean;
|
||||
}
|
||||
|
||||
const {
|
||||
items = [],
|
||||
secondary = false,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<div
|
||||
class:list={[
|
||||
"glossary-portals",
|
||||
secondary && "glossary-portals--secondary",
|
||||
]}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<a class="glossary-portal-card" href={item.href}>
|
||||
<strong>{item.title}</strong>
|
||||
<span>{item.description}</span>
|
||||
<small>{item.meta}</small>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.glossary-portals{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.glossary-portal-card{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 16px 18px;
|
||||
border: 1px solid var(--glossary-border);
|
||||
border-radius: 18px;
|
||||
background: var(--glossary-bg-soft);
|
||||
text-decoration: none;
|
||||
transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
|
||||
}
|
||||
|
||||
.glossary-portal-card:hover{
|
||||
transform: translateY(-1px);
|
||||
background: var(--glossary-bg-soft-strong);
|
||||
border-color: rgba(0,217,255,0.16);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.glossary-portal-card strong{
|
||||
color: var(--glossary-accent);
|
||||
font-size: 1.08rem;
|
||||
line-height: 1.28;
|
||||
}
|
||||
|
||||
.glossary-portal-card span{
|
||||
color: inherit;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
opacity: .94;
|
||||
}
|
||||
|
||||
.glossary-portal-card small{
|
||||
color: var(--glossary-accent);
|
||||
font-size: .94rem;
|
||||
line-height: 1.35;
|
||||
opacity: .9;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
.glossary-portal-card{
|
||||
background: rgba(255,255,255,0.04);
|
||||
}
|
||||
|
||||
.glossary-portal-card:hover{
|
||||
background: rgba(255,255,255,0.07);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user