feat(glossaire): harmonize portal pages and sticky reading ux
This commit is contained in:
87
src/components/GlossaryPortalCta.astro
Normal file
87
src/components/GlossaryPortalCta.astro
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
export interface Props {
|
||||
href: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
href,
|
||||
label,
|
||||
icon = "↗",
|
||||
className,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<a class:list={["glossary-portal-cta", className]} href={href}>
|
||||
<span>{label}</span>
|
||||
<span aria-hidden="true">{icon}</span>
|
||||
</a>
|
||||
|
||||
<style>
|
||||
.glossary-portal-cta{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 40px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid rgba(0,217,255,0.24);
|
||||
border-radius: 999px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0,217,255,0.10), rgba(0,217,255,0.04)),
|
||||
rgba(127,127,127,0.06);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.05),
|
||||
0 0 0 1px rgba(0,217,255,0.04);
|
||||
text-decoration: none;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .01em;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
transform 120ms ease,
|
||||
background 120ms ease,
|
||||
border-color 120ms ease,
|
||||
box-shadow 120ms ease;
|
||||
}
|
||||
|
||||
.glossary-portal-cta:hover{
|
||||
transform: translateY(-1px);
|
||||
border-color: rgba(0,217,255,0.34);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0,217,255,0.14), rgba(0,217,255,0.06)),
|
||||
rgba(127,127,127,0.08);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.06),
|
||||
0 0 0 1px rgba(0,217,255,0.08),
|
||||
0 10px 28px rgba(0,0,0,0.18);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.glossary-portal-cta:focus-visible{
|
||||
outline: 2px solid rgba(0,217,255,0.28);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px){
|
||||
.glossary-portal-cta{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
.glossary-portal-cta{
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0,217,255,0.12), rgba(0,217,255,0.05)),
|
||||
rgba(255,255,255,0.04);
|
||||
}
|
||||
|
||||
.glossary-portal-cta:hover{
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0,217,255,0.16), rgba(0,217,255,0.07)),
|
||||
rgba(255,255,255,0.06);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
96
src/components/GlossaryPortalPanel.astro
Normal file
96
src/components/GlossaryPortalPanel.astro
Normal file
@@ -0,0 +1,96 @@
|
||||
---
|
||||
export interface Props {
|
||||
id?: string;
|
||||
title: string;
|
||||
count?: string;
|
||||
intro?: string;
|
||||
surface?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
id,
|
||||
title,
|
||||
count,
|
||||
intro,
|
||||
surface = false,
|
||||
className,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<div
|
||||
class:list={[
|
||||
"glossary-portal-panel",
|
||||
surface && "glossary-portal-panel--surface",
|
||||
className,
|
||||
]}
|
||||
>
|
||||
<div class="glossary-portal-panel__head">
|
||||
<h3 id={id}>{title}</h3>
|
||||
{count && <span class="glossary-portal-panel__count">{count}</span>}
|
||||
</div>
|
||||
|
||||
{intro && <p class="glossary-portal-panel__intro">{intro}</p>}
|
||||
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.glossary-portal-panel{
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.glossary-portal-panel--surface{
|
||||
padding: 18px 18px 16px;
|
||||
border: 1px solid var(--glossary-border, rgba(127,127,127,0.18));
|
||||
border-radius: 18px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
|
||||
var(--glossary-bg-soft, rgba(127,127,127,0.035));
|
||||
}
|
||||
|
||||
.glossary-portal-panel__head{
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.glossary-portal-panel__head h3{
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
line-height: 1.3;
|
||||
scroll-margin-top: calc(var(--sticky-offset-px, 96px) + 36px);
|
||||
}
|
||||
|
||||
.glossary-portal-panel__count{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid rgba(127,127,127,0.22);
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
opacity: .78;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.glossary-portal-panel__intro{
|
||||
max-width: 78ch;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
opacity: .9;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
.glossary-portal-panel--surface{
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
|
||||
rgba(255,255,255,0.04);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user