@breathe-ds/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -9
- package/components/Accordion.tsx +6 -4
- package/components/Avatar.tsx +37 -0
- package/components/BottomNav.tsx +1 -1
- package/components/Breadcrumb.tsx +45 -0
- package/components/BreatheMark.tsx +0 -13
- package/components/Byline.tsx +103 -0
- package/components/CaptionBand.tsx +74 -0
- package/components/CtaCard.tsx +52 -0
- package/components/FactStrip.tsx +55 -0
- package/components/Footer.tsx +3 -20
- package/components/Heading.tsx +86 -0
- package/components/InfoCard.tsx +116 -0
- package/components/LanguageSwitcher.tsx +1 -1
- package/components/List.tsx +81 -0
- package/components/Lockup.tsx +0 -18
- package/components/MapCard.tsx +158 -0
- package/components/MediaCard.tsx +266 -0
- package/components/PersonChip.tsx +49 -0
- package/components/Pill.tsx +42 -0
- package/components/PillList.tsx +20 -47
- package/components/ProfessionalCard.tsx +341 -0
- package/components/ProfessionalModal.tsx +243 -0
- package/components/Rows.tsx +131 -0
- package/components/TestimonialCard.tsx +138 -0
- package/components/Text.tsx +31 -0
- package/components/Timeline.tsx +69 -0
- package/components/VideoInviteCard.tsx +168 -0
- package/components/VideoStoryCard.tsx +382 -0
- package/package.json +22 -1
- package/theme.css +66 -0
- package/tokens/creeta.css +5 -2
- package/tokens/neutral.css +10 -4
- package/tokens/ttcab.css +1 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type ComponentType, type ElementType, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
/** lucide-style icon component (the badge sets the size). */
|
|
6
|
+
type IconType = ComponentType<{ size?: number; strokeWidth?: number; className?: string; "aria-hidden"?: boolean | "true" }>;
|
|
7
|
+
|
|
8
|
+
/** Event the card videos listen to when the person pauses/resumes them all
|
|
9
|
+
* (dispatch it on `window` after toggling the attribute below). */
|
|
10
|
+
export const MEDIA_CARD_VIDEO_PAUSE_EVENT = "cg-media-card-videos";
|
|
11
|
+
/** Attribute on <html> while the card videos are paused (WCAG 2.2.2: what
|
|
12
|
+
* moves for more than 5s must be pausable; the button lives outside the
|
|
13
|
+
* card, which is one whole link). */
|
|
14
|
+
export const MEDIA_CARD_VIDEO_PAUSED_ATTR = "data-media-card-videos-paused";
|
|
15
|
+
|
|
16
|
+
export type MediaCardVideo = {
|
|
17
|
+
src: string;
|
|
18
|
+
poster?: string;
|
|
19
|
+
/** `always` (default): loops while the card is on screen (a quarter in view
|
|
20
|
+
* counts). `hover`: only with the mouse over, or keyboard focus on, the
|
|
21
|
+
* card; on touch the photo stays. */
|
|
22
|
+
when?: "always" | "hover";
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
href: string;
|
|
27
|
+
title: ReactNode;
|
|
28
|
+
/** Supporting text. Accepts elements, to break the line where it makes sense. */
|
|
29
|
+
text?: ReactNode;
|
|
30
|
+
/** Top-left corner, over dark glass: a MediaCardBadge (icon, label, address). */
|
|
31
|
+
badge?: ReactNode;
|
|
32
|
+
/** Small line above the title ("Who created the method"), lighter. */
|
|
33
|
+
eyebrow?: ReactNode;
|
|
34
|
+
/** Text link line under the text ("See the team ↗"). The card is already the
|
|
35
|
+
* link, so this is a label with the arrow, not a second anchor. */
|
|
36
|
+
linkLabel?: ReactNode;
|
|
37
|
+
/** The round arrow button top-right. Off for the portrait card, which says
|
|
38
|
+
* where it goes with `linkLabel` instead. */
|
|
39
|
+
arrowButton?: boolean;
|
|
40
|
+
/** h2 on list pages, h3 inside a section that already has an h2. */
|
|
41
|
+
headingLevel?: "h2" | "h3";
|
|
42
|
+
/** Background media rendered to cover the card: an <img>, a video element or
|
|
43
|
+
* the app's next/image (with `fill`, pass it `className="object-cover"`). */
|
|
44
|
+
media?: ReactNode;
|
|
45
|
+
/** Plain image alternative to `media`. Decorative by default (`alt=""`): the
|
|
46
|
+
* card already has title and text. */
|
|
47
|
+
src?: string;
|
|
48
|
+
alt?: string;
|
|
49
|
+
srcSet?: string;
|
|
50
|
+
sizes?: string;
|
|
51
|
+
/** true only when the card is the page's LCP: eager + high fetch priority. */
|
|
52
|
+
priority?: boolean;
|
|
53
|
+
/** Short muted clip that plays over the photo. Without it, or if it does not
|
|
54
|
+
* play, the photo stands. */
|
|
55
|
+
video?: MediaCardVideo;
|
|
56
|
+
/** Aspect-ratio class of the card. Default `aspect-[3/4]`; replaces the
|
|
57
|
+
* default instead of fighting it (e.g. `aspect-[4/5] md:aspect-auto md:min-h-[460px]`). */
|
|
58
|
+
aspect?: string;
|
|
59
|
+
/** Padding class of the card. Default `p-4` (e.g. `p-6 md:p-8`). */
|
|
60
|
+
padding?: string;
|
|
61
|
+
/** Link component of the app (e.g. next-intl Link). Default: <a>. */
|
|
62
|
+
linkComponent?: ElementType;
|
|
63
|
+
className?: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Media card of the Cuidado Global family — the `CartaoFoto` of novo.creeta
|
|
68
|
+
* ("Get to know the clinic", the treatment cards) with the Breathe tokens. A
|
|
69
|
+
* tall card with the photo (or video) bleeding to the edges and the text over
|
|
70
|
+
* it; the whole card is the link. The ink film at the bottom keeps the text
|
|
71
|
+
* readable over any photo. On hover (mouse only) the photo zooms in slowly
|
|
72
|
+
* and steadily, like a Ken Burns: 2.5s to reach 107%; it comes back in half a
|
|
73
|
+
* second and does not move for people who asked for less motion. The round
|
|
74
|
+
* arrow button turns `action` on hover.
|
|
75
|
+
*/
|
|
76
|
+
export function MediaCard({
|
|
77
|
+
href,
|
|
78
|
+
title,
|
|
79
|
+
text,
|
|
80
|
+
badge,
|
|
81
|
+
eyebrow,
|
|
82
|
+
linkLabel,
|
|
83
|
+
arrowButton = true,
|
|
84
|
+
headingLevel: Heading = "h3",
|
|
85
|
+
media,
|
|
86
|
+
src,
|
|
87
|
+
alt = "",
|
|
88
|
+
srcSet,
|
|
89
|
+
sizes,
|
|
90
|
+
priority = false,
|
|
91
|
+
video,
|
|
92
|
+
aspect = "aspect-[3/4]",
|
|
93
|
+
padding = "p-4",
|
|
94
|
+
linkComponent,
|
|
95
|
+
className = "",
|
|
96
|
+
}: Props) {
|
|
97
|
+
const L: ElementType = linkComponent ?? "a";
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<L
|
|
101
|
+
href={href}
|
|
102
|
+
className={`group relative isolate flex ${aspect} flex-col justify-between overflow-hidden rounded-2xl bg-ink ${padding} text-white transition-transform duration-200 ease-out active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:scale-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink ${className}`}
|
|
103
|
+
>
|
|
104
|
+
{/* Zooms in slowly with the mouse over, at a constant pace, like a Ken
|
|
105
|
+
Burns: 2.5s to reach 107%. Only where there is a mouse: on a phone
|
|
106
|
+
the tap would fire a false "hover". Comes back in half a second, and
|
|
107
|
+
stays still for people who asked for less motion. */}
|
|
108
|
+
<div
|
|
109
|
+
className="absolute inset-0 -z-20 transition-transform duration-500 ease-[var(--ease-cg)] motion-reduce:transition-none [@media(hover:hover)_and_(pointer:fine)]:group-hover:scale-[1.07] [@media(hover:hover)_and_(pointer:fine)]:group-hover:duration-[2500ms] [@media(hover:hover)_and_(pointer:fine)]:group-hover:ease-linear motion-reduce:[@media(hover:hover)_and_(pointer:fine)]:group-hover:scale-100 [&>img]:h-full [&>img]:w-full [&>img]:object-cover [&>video]:h-full [&>video]:w-full [&>video]:object-cover"
|
|
110
|
+
>
|
|
111
|
+
{media ??
|
|
112
|
+
(src && (
|
|
113
|
+
<img
|
|
114
|
+
src={src}
|
|
115
|
+
srcSet={srcSet}
|
|
116
|
+
sizes={sizes}
|
|
117
|
+
alt={alt}
|
|
118
|
+
loading={priority ? "eager" : "lazy"}
|
|
119
|
+
decoding="async"
|
|
120
|
+
// React 18 only knows the lowercase attribute (19 accepts fetchPriority too)
|
|
121
|
+
{...({ fetchpriority: priority ? "high" : undefined } as Record<string, unknown>)}
|
|
122
|
+
/>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
{/* between the photo and the film: the text keeps the same contrast */}
|
|
126
|
+
{video && <CardVideo {...video} className="absolute inset-0 -z-20" />}
|
|
127
|
+
<span aria-hidden="true" className="absolute inset-0 -z-10 bg-gradient-to-t from-ink via-ink/75 via-40% to-ink/15" />
|
|
128
|
+
|
|
129
|
+
{(badge || arrowButton) && (
|
|
130
|
+
<div className="flex items-start justify-between gap-3">
|
|
131
|
+
<div>{badge}</div>
|
|
132
|
+
{arrowButton && (
|
|
133
|
+
<span
|
|
134
|
+
aria-hidden="true"
|
|
135
|
+
className="flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-card text-ink transition-colors duration-200 group-hover:bg-action group-hover:text-on-action motion-reduce:transition-none"
|
|
136
|
+
>
|
|
137
|
+
<svg viewBox="0 0 24 24" width={20} height={20} className="cg-arrow-go" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17 17 7M9 7h8v8" /></svg>
|
|
138
|
+
</span>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
<div className={badge || arrowButton ? "" : "mt-auto"}>
|
|
144
|
+
{eyebrow && <span className="block text-sm text-white/75">{eyebrow}</span>}
|
|
145
|
+
<Heading className={`font-heading text-2xl font-medium leading-tight ${eyebrow ? "mt-1" : ""}`}>{title}</Heading>
|
|
146
|
+
{text && <p className="m-0 mt-2 text-sm leading-relaxed text-white/85">{text}</p>}
|
|
147
|
+
{linkLabel && (
|
|
148
|
+
<span className="mt-3 inline-flex items-center gap-1.5 text-sm font-semibold underline underline-offset-4">
|
|
149
|
+
{linkLabel}
|
|
150
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" width={16} height={16} className="cg-arrow-go" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17 17 7M9 7h8v8" /></svg>
|
|
151
|
+
</span>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
</L>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Badge for the corner of the card. Dark glass, not light: over the bright
|
|
160
|
+
* part of a photo, white text on white glass measured 1.59:1. With `Icon`
|
|
161
|
+
* alone (no children) it becomes a 44px round icon badge.
|
|
162
|
+
*/
|
|
163
|
+
export function MediaCardBadge({ Icon, children, className = "" }: { Icon?: IconType; children?: ReactNode; className?: string }) {
|
|
164
|
+
const iconOnly = Boolean(Icon) && children === undefined;
|
|
165
|
+
return (
|
|
166
|
+
<span
|
|
167
|
+
className={`inline-flex items-center gap-1.5 rounded-full border border-white/15 bg-ink/80 px-3 py-2 text-xs font-medium text-white backdrop-blur-md ${iconOnly ? "h-11 w-11 justify-center p-0" : ""} ${className}`}
|
|
168
|
+
>
|
|
169
|
+
{Icon && <Icon aria-hidden="true" size={iconOnly ? 20 : 14} strokeWidth={2} />}
|
|
170
|
+
{children}
|
|
171
|
+
</span>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Short muted clip over the photo of a card (creeta's `VideoDoCartao`).
|
|
177
|
+
*
|
|
178
|
+
* Invisible until it has frames to show, then fades in: without this it would
|
|
179
|
+
* flash black while the file arrives. If it does not play, the card is the
|
|
180
|
+
* usual one, with the photo.
|
|
181
|
+
*
|
|
182
|
+
* Does not play, in either mode: for people who asked for less motion; with
|
|
183
|
+
* data saver on (the video is not even requested: `preload="none"`); while
|
|
184
|
+
* the person has paused the card videos (MEDIA_CARD_VIDEO_PAUSED_ATTR on <html>).
|
|
185
|
+
*
|
|
186
|
+
* In `always`, pauses when the card leaves the screen: three videos running
|
|
187
|
+
* with nobody watching waste battery for nothing.
|
|
188
|
+
*
|
|
189
|
+
* Muted, no controls, out of the screen-reader flow: it is decoration, the
|
|
190
|
+
* card already has title and text. The card is the link (<a>) around it.
|
|
191
|
+
*/
|
|
192
|
+
function CardVideo({ src, poster, when = "always", className = "" }: MediaCardVideo & { className?: string }) {
|
|
193
|
+
const video = useRef<HTMLVideoElement>(null);
|
|
194
|
+
const [playing, setPlaying] = useState(false);
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
const v = video.current;
|
|
198
|
+
const card = v?.closest("a") ?? v?.parentElement;
|
|
199
|
+
if (!v || !card || typeof window.matchMedia !== "function") return;
|
|
200
|
+
|
|
201
|
+
const saveData = (navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData === true;
|
|
202
|
+
const lessMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
203
|
+
const paused = () => document.documentElement.hasAttribute(MEDIA_CARD_VIDEO_PAUSED_ATTR);
|
|
204
|
+
const play = () => {
|
|
205
|
+
if (lessMotion() || saveData || paused()) return;
|
|
206
|
+
v.play()
|
|
207
|
+
.then(() => setPlaying(true))
|
|
208
|
+
.catch(() => {});
|
|
209
|
+
};
|
|
210
|
+
const stop = () => {
|
|
211
|
+
setPlaying(false);
|
|
212
|
+
v.pause();
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
if (when === "hover") {
|
|
216
|
+
const withMouse = () => window.matchMedia("(hover: hover) and (pointer: fine)").matches;
|
|
217
|
+
const enter = () => withMouse() && play();
|
|
218
|
+
card.addEventListener("pointerenter", enter);
|
|
219
|
+
card.addEventListener("pointerleave", stop);
|
|
220
|
+
card.addEventListener("focusin", enter);
|
|
221
|
+
card.addEventListener("focusout", stop);
|
|
222
|
+
return () => {
|
|
223
|
+
card.removeEventListener("pointerenter", enter);
|
|
224
|
+
card.removeEventListener("pointerleave", stop);
|
|
225
|
+
card.removeEventListener("focusin", enter);
|
|
226
|
+
card.removeEventListener("focusout", stop);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (typeof IntersectionObserver !== "function") return;
|
|
231
|
+
let onScreen = false;
|
|
232
|
+
// a quarter of the card in view already counts
|
|
233
|
+
const watcher = new IntersectionObserver(
|
|
234
|
+
([e]) => {
|
|
235
|
+
onScreen = e.isIntersecting;
|
|
236
|
+
if (onScreen) play();
|
|
237
|
+
else stop();
|
|
238
|
+
},
|
|
239
|
+
{ threshold: 0.25 },
|
|
240
|
+
);
|
|
241
|
+
watcher.observe(card);
|
|
242
|
+
// the person paused or resumed the videos
|
|
243
|
+
const onNotice = () => (paused() || !onScreen ? stop() : play());
|
|
244
|
+
window.addEventListener(MEDIA_CARD_VIDEO_PAUSE_EVENT, onNotice);
|
|
245
|
+
return () => {
|
|
246
|
+
watcher.disconnect();
|
|
247
|
+
window.removeEventListener(MEDIA_CARD_VIDEO_PAUSE_EVENT, onNotice);
|
|
248
|
+
};
|
|
249
|
+
}, [when]);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<video
|
|
253
|
+
ref={video}
|
|
254
|
+
src={src}
|
|
255
|
+
poster={poster}
|
|
256
|
+
muted
|
|
257
|
+
loop
|
|
258
|
+
playsInline
|
|
259
|
+
preload="none"
|
|
260
|
+
aria-hidden="true"
|
|
261
|
+
tabIndex={-1}
|
|
262
|
+
data-media-card-video={when}
|
|
263
|
+
className={`pointer-events-none h-full w-full object-cover transition-opacity duration-500 ease-out motion-reduce:transition-none ${playing ? "opacity-100" : "opacity-0"} ${className}`}
|
|
264
|
+
/>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ElementType, ReactNode } from "react";
|
|
2
|
+
import { Avatar } from "./Avatar";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
name: string;
|
|
6
|
+
/** Second line: role · registration ("Physiotherapist · CREFITO-10/…"). The
|
|
7
|
+
* family rule: a health professional always shows the council number. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
photo?: string;
|
|
10
|
+
avatar?: ReactNode;
|
|
11
|
+
/** With an href the chip is a link (to the person's card) and shows the arrow bubble. */
|
|
12
|
+
href?: string;
|
|
13
|
+
linkComponent?: ElementType;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Person chip — the "who signs" of a novo.creeta article: one pill with the
|
|
19
|
+
* portrait, the name and, below, role and registration. With a link it leads
|
|
20
|
+
* to the person's card and the arrow says so, like the site's shortcuts.
|
|
21
|
+
*/
|
|
22
|
+
export function PersonChip({ name, description, photo, avatar, href, linkComponent, className = "" }: Props) {
|
|
23
|
+
const L: ElementType = linkComponent ?? "a";
|
|
24
|
+
const inner = (
|
|
25
|
+
<>
|
|
26
|
+
<Avatar name={name} photo={photo} size={44}>{avatar}</Avatar>
|
|
27
|
+
<span className="leading-snug">
|
|
28
|
+
<span className="block font-semibold text-ink">{name}</span>
|
|
29
|
+
{description && <span className="block text-[0.8125rem] text-ink/80">{description}</span>}
|
|
30
|
+
</span>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
/* The avatar (photo or initials) always sits 6px from the edge, like the
|
|
34
|
+
arrow bubble on the other side; a chip that ends in text gets 20px (Pill). */
|
|
35
|
+
const box = "inline-flex min-h-11 items-center gap-3 rounded-full bg-card py-1.5 pl-1.5";
|
|
36
|
+
if (!href) return <p className={`m-0 ${box} pr-5 ${className}`}>{inner}</p>;
|
|
37
|
+
return (
|
|
38
|
+
<L
|
|
39
|
+
href={href}
|
|
40
|
+
className={`${box} pr-1.5 transition-transform duration-150 ease-out active:scale-[0.98] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink motion-reduce:transition-none motion-reduce:active:scale-100 ${className}`}
|
|
41
|
+
>
|
|
42
|
+
{inner}
|
|
43
|
+
<span aria-hidden="true" className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-ink/[0.12] text-ink">
|
|
44
|
+
<svg viewBox="0 0 24 24" width={15} height={15} className="cg-arrow-go" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17 17 7M9 7h8v8" /></svg>
|
|
45
|
+
</span>
|
|
46
|
+
</L>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ElementType, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
href: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Lighter supporting info after the label, e.g. "4 videos". */
|
|
7
|
+
meta?: ReactNode;
|
|
8
|
+
/** Link component of the app for page links (anchors always use <a>). */
|
|
9
|
+
linkComponent?: ElementType;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pill that leads somewhere — the Atalho of novo.creeta, the site's only white
|
|
15
|
+
* pill (information-only pills are labels, not this).
|
|
16
|
+
*
|
|
17
|
+
* What says "tap me" is not the color, it is the shape: a full pill, 44px
|
|
18
|
+
* tall, with an arrow in a circle. The arrow also says where it goes: down
|
|
19
|
+
* when it is on the same page (an anchor), diagonal when it opens another page.
|
|
20
|
+
*/
|
|
21
|
+
export function Pill({ href, children, meta, linkComponent, className = "" }: Props) {
|
|
22
|
+
const onPage = href.startsWith("#");
|
|
23
|
+
const L: ElementType = onPage ? "a" : linkComponent ?? "a";
|
|
24
|
+
const classes = `group inline-flex min-h-11 items-center gap-2 rounded-full bg-card py-1.5 pl-4 pr-1.5 text-sm font-medium text-ink shadow-[0_1px_2px_rgba(0,0,0,0.12)] transition duration-200 hover:bg-ink hover:text-surface active:scale-[0.98] motion-reduce:active:scale-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink motion-reduce:transition-none ${className}`;
|
|
25
|
+
return (
|
|
26
|
+
<L href={href} className={classes}>
|
|
27
|
+
<span>{children}</span>
|
|
28
|
+
{meta && <span className="font-normal text-ink/80 group-hover:text-surface/85">{meta}</span>}
|
|
29
|
+
<span
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
data-arrow={onPage ? "down" : "other-page"}
|
|
32
|
+
className="ml-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-ink/[0.12] transition-colors duration-200 group-hover:bg-surface/15 motion-reduce:transition-none"
|
|
33
|
+
>
|
|
34
|
+
{onPage ? (
|
|
35
|
+
<svg viewBox="0 0 24 24" width={16} height={16} className="cg-arrow-down" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 5v14M19 12l-7 7-7-7" /></svg>
|
|
36
|
+
) : (
|
|
37
|
+
<svg viewBox="0 0 24 24" width={16} height={16} className="cg-arrow-go" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17 17 7M9 7h8v8" /></svg>
|
|
38
|
+
)}
|
|
39
|
+
</span>
|
|
40
|
+
</L>
|
|
41
|
+
);
|
|
42
|
+
}
|
package/components/PillList.tsx
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { ElementType, ReactNode } from "react";
|
|
2
2
|
import { Button } from "./Button";
|
|
3
|
+
import { Pill } from "./Pill";
|
|
3
4
|
|
|
4
|
-
export type
|
|
5
|
+
export type PillItem = { label: ReactNode; href: string; meta?: ReactNode };
|
|
6
|
+
/** @deprecated use PillItem */
|
|
7
|
+
export type Pill_ = PillItem;
|
|
5
8
|
|
|
6
9
|
type Props = {
|
|
7
10
|
title?: ReactNode;
|
|
8
|
-
|
|
11
|
+
/** Each item is a Pill: `#anchor` hrefs get the down arrow, page links the diagonal one. */
|
|
12
|
+
items: PillItem[];
|
|
9
13
|
/** Optional "See all" link. */
|
|
10
14
|
seeAll?: { label: ReactNode; href?: string };
|
|
15
|
+
linkComponent?: ElementType;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
aria-hidden="true"
|
|
17
|
-
viewBox="0 0 24 24"
|
|
18
|
-
className="h-4 w-4 flex-none"
|
|
19
|
-
fill="none"
|
|
20
|
-
stroke="currentColor"
|
|
21
|
-
strokeWidth="2.25"
|
|
22
|
-
strokeLinecap="round"
|
|
23
|
-
strokeLinejoin="round"
|
|
24
|
-
>
|
|
25
|
-
<path d="M7 17 17 7M9 7h8v8" />
|
|
26
|
-
</svg>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
18
|
+
const ArrowUpRight = () => (
|
|
19
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" className="h-4 w-4 flex-none" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round"><path d="M7 17 17 7M9 7h8v8" /></svg>
|
|
20
|
+
);
|
|
29
21
|
|
|
30
22
|
/**
|
|
31
|
-
* Pill list (
|
|
32
|
-
* a
|
|
33
|
-
* The DS's subtle card style (soft border + shadow), pill radius.
|
|
23
|
+
* Pill list: a wrapping row of Pills ("Conditions we treat", the video groups
|
|
24
|
+
* of a page with "11 videos" as meta), plus an optional "See all" link.
|
|
34
25
|
*/
|
|
35
|
-
export function PillList({ title, items, seeAll }: Props) {
|
|
26
|
+
export function PillList({ title, items, seeAll, linkComponent }: Props) {
|
|
36
27
|
return (
|
|
37
28
|
<div>
|
|
38
29
|
{title && (
|
|
@@ -40,30 +31,12 @@ export function PillList({ title, items, seeAll }: Props) {
|
|
|
40
31
|
{title}
|
|
41
32
|
</h2>
|
|
42
33
|
)}
|
|
43
|
-
<ul className="flex flex-wrap gap-2.5">
|
|
44
|
-
{items.map((p, i) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<ArrowUpRight />
|
|
50
|
-
</span>
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
const cls =
|
|
54
|
-
"group inline-flex items-center gap-3 rounded-pill border border-line bg-surface py-2 pr-2 pl-5 font-heading text-[0.98rem] font-semibold text-ink shadow-[0_2px_10px_rgba(20,71,83,0.05)] transition hover:-translate-y-0.5 hover:shadow-[0_10px_24px_rgba(20,71,83,0.1)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink";
|
|
55
|
-
return (
|
|
56
|
-
<li key={i}>
|
|
57
|
-
{p.href ? (
|
|
58
|
-
<a href={p.href} className={cls}>
|
|
59
|
-
{inner}
|
|
60
|
-
</a>
|
|
61
|
-
) : (
|
|
62
|
-
<span className={cls}>{inner}</span>
|
|
63
|
-
)}
|
|
64
|
-
</li>
|
|
65
|
-
);
|
|
66
|
-
})}
|
|
34
|
+
<ul className="flex list-none flex-wrap gap-2.5">
|
|
35
|
+
{items.map((p, i) => (
|
|
36
|
+
<li key={`${i}-${p.href}`}>
|
|
37
|
+
<Pill href={p.href} meta={p.meta} linkComponent={linkComponent}>{p.label}</Pill>
|
|
38
|
+
</li>
|
|
39
|
+
))}
|
|
67
40
|
</ul>
|
|
68
41
|
{seeAll && (
|
|
69
42
|
<div className="mt-6">
|