Region list: a closed row previews its featured cards, faded, with a Show featured button
The preview is the top of the cards fading out (a mask, so it works over the backdrop in both modes); it's inert and hidden from screen readers, and the button opens the row, moving focus to its toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2977168af5
commit
910aef78b5
2 changed files with 43 additions and 2 deletions
|
|
@ -630,6 +630,16 @@ iframe[src*="churchcenter"] {
|
|||
transition: transform 200ms ease;
|
||||
}
|
||||
|
||||
/* A closed region row's featured cards: the top of them, fading out
|
||||
into whatever is behind (a mask, not a painted gradient, so it
|
||||
works over the page backdrop in both modes). */
|
||||
.ol-peek {
|
||||
max-height: 9rem;
|
||||
overflow: hidden;
|
||||
opacity: 0.85;
|
||||
mask-image: linear-gradient(to bottom, black 20%, transparent);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ol-panel,
|
||||
.ol-chevron {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ArrowUpRight, CaretRight } from '@phosphor-icons/react';
|
||||
import { useId, useState } from "react";
|
||||
import { ArrowUpRight, CaretDown, CaretRight } from '@phosphor-icons/react';
|
||||
import { useId, useRef, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import ArrowLink from "../../components/ArrowLink.tsx";
|
||||
import FeaturedCards from "../../components/FeaturedCards.tsx";
|
||||
|
|
@ -84,6 +84,7 @@ function OrgMark({ org, color }) {
|
|||
function OrgRow({ org, pageLabel, siteLabel, titled }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const panelId = useId();
|
||||
const toggleRef = useRef<HTMLButtonElement>(null);
|
||||
const reading = useReadingMode();
|
||||
// Under a block title the names are a level below it.
|
||||
const Name = titled ? "h4" : "h3";
|
||||
|
|
@ -120,6 +121,7 @@ function OrgRow({ org, pageLabel, siteLabel, titled }) {
|
|||
</div>
|
||||
) : (
|
||||
<button
|
||||
ref={toggleRef}
|
||||
onClick={() => setOpen(v => !v)}
|
||||
aria-expanded={open}
|
||||
aria-controls={panelId}
|
||||
|
|
@ -167,6 +169,35 @@ function OrgRow({ org, pageLabel, siteLabel, titled }) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* Closed, a region with featured cards shows their top half
|
||||
fading out, and a button that opens the row to them. The
|
||||
peek is a picture of the cards, not a second set of links:
|
||||
inert, so it takes no clicks or tab stops, and hidden from
|
||||
screen readers, which get the button. */}
|
||||
{featured.length > 0 && !open && !reading && (
|
||||
<div className="pl-10 pr-2 pt-2">
|
||||
<div className="ol-peek" inert aria-hidden="true">
|
||||
<FeaturedCards cards={featured} level={titled ? 5 : 4} />
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
// The button goes as the row opens, so focus moves to the
|
||||
// row's own toggle rather than falling back to the page.
|
||||
onClick={() => {
|
||||
setOpen(true);
|
||||
toggleRef.current?.focus();
|
||||
}}
|
||||
aria-controls={panelId}
|
||||
aria-expanded={false}
|
||||
className="btn -mt-4 relative inline-flex items-center gap-2 py-2 px-4 text-sm"
|
||||
style={{ border: `1px solid ${color}`, color: accentText(color) }}
|
||||
>
|
||||
Show featured ({featured.length})
|
||||
<CaretDown size="1em" weight="bold" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 0fr → 1fr animates to the panel's real height, so nobody
|
||||
has to guess a max-height that's wrong the moment a
|
||||
description grows. */}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue