Weekly Delivery Summary
Weekly project-progress summary with three completion rings, a derived overall percentage, project task counts and the next review.
import {
SplitCard,
SplitCardContent,
SplitCardDescription,
SplitCardHeader,
SplitCardMedia,
SplitCardTitle,
} from "@/components/card/split-card"
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { ArcRing } from "@/components/glow/arc-ring"
import { Section } from "@/components/section/section"
import { StatValue } from "@/components/stats/stats"
import { Text } from "@/components/text/text"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Quillmere / weekly delivery",
title: "This week’s delivery",
description: "A progress check across your active projects.",
review: "Review Friday, Nov 20",
figureLabel: "completed",
} as const
const PROJECTS = [
{
name: "Website refresh",
completed: 12,
total: 16,
color: "oklch(0.81 0.1 165)",
},
{
name: "Component library",
completed: 8,
total: 10,
color: "oklch(0.73 0.09 165)",
},
{
name: "Release notes",
completed: 4,
total: 6,
color: "oklch(0.64 0.07 165)",
},
] as const
const COMPLETED = PROJECTS.reduce((sum, project) => sum + project.completed, 0)
const TOTAL = PROJECTS.reduce((sum, project) => sum + project.total, 0)
const PERCENT = Math.round((COMPLETED / TOTAL) * 100)
const CHART_LABEL = `Weekly delivery: ${COMPLETED} of ${TOTAL} tasks completed, ${PERCENT} percent overall. ${PROJECTS.map((project) => `${project.name}: ${project.completed} of ${project.total} tasks`).join(". ")}.`
/** A weekly delivery summary with project task counts, matching completion rings and a derived overall percentage. */
export default function WeeklyDeliverySummary() {
return (
<Section size="sm">
<SplitCard className="theme-blue relative isolate min-h-105 w-full min-w-0 overflow-hidden rounded-xl border border-border bg-background shadow-none ring-0 [--font-display:var(--font-sans)]">
<SplitCardContent>
<SplitCardHeader>
<Eyebrow variant="mono" className="relative z-2 text-current">
{COPY.eyebrow}
</Eyebrow>
<SplitCardTitle className="font-display font-normal tracking-tight">
{COPY.title}
</SplitCardTitle>
<SplitCardDescription>{COPY.description}</SplitCardDescription>
</SplitCardHeader>
<dl className="grid w-full divide-y divide-border border-y border-border">
{PROJECTS.map((project) => (
<div
key={project.name}
className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-4 py-4"
>
<dt className="flex min-w-0 items-center gap-3 text-sm">
<span
aria-hidden="true"
className="size-1.5 shrink-0 rounded-full"
style={{ backgroundColor: project.color }}
/>
<span>{project.name}</span>
</dt>
<dd className="text-sm text-muted-foreground tabular-nums">
{project.completed} / {project.total}
<span className="sr-only"> tasks completed</span>
</dd>
</div>
))}
</dl>
<Text size="xs" variant="muted">
{TOTAL - COMPLETED} tasks remaining · {COPY.review}
</Text>
</SplitCardContent>
<SplitCardMedia
divider={false}
className="bg-[oklch(0.13_0.015_250)] p-6 text-scene-foreground sm:p-8"
>
<figure
role="img"
aria-label={CHART_LABEL}
className="w-full max-w-80"
>
<div
className="relative aspect-square w-full"
data-slot="delivery-rings"
>
{PROJECTS.map((project, index) => (
<ArcRing
key={project.name}
size={`${100 - index * 18}%`}
sweep={(project.completed / project.total) * 360}
color={project.color}
track="oklch(0.72 0.04 165 / 0.16)"
width={4}
trackWidth={3}
className="[&_stop]:[stop-opacity:1]"
/>
))}
<div className="absolute inset-0 grid place-content-center gap-2 text-center">
<StatValue className="text-5xl/none font-normal tracking-tighter text-scene-foreground tabular-nums md:text-[4rem]/none">
{PERCENT}%
</StatValue>
<Text size="xs" className="text-scene-foreground/70">
{COPY.figureLabel}
</Text>
</div>
</div>
<Text
size="sm"
render={<figcaption />}
className="mt-5 text-center text-scene-foreground/70"
>
{COMPLETED} of {TOTAL} tasks complete
</Text>
</figure>
</SplitCardMedia>
</SplitCard>
</Section>
)
}
import { useId, type ComponentProps, type CSSProperties } from "react"
import { cn } from "cn"
// One turn for every ring, backwards when ccw; reduced motion holds it still.
// Arc ships the same rule under the same href, so React keeps one copy.
const ARC_CSS = `@keyframes arc-turn{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: no-preference){
[data-slot="arc-layer"][data-animate] :is([data-slot="arc"],[data-slot="arc-ring"]),:is([data-slot="arc"],[data-slot="arc-ring"])[data-animate]{animation:arc-turn var(--arc-duration) linear infinite var(--arc-direction)}}`
const finite = (n: number | undefined, fallback: number) =>
n !== undefined && Number.isFinite(n) ? n : fallback
type ArcRingProps = Omit<ComponentProps<"div">, "color"> & {
/** Diameter in px, or any CSS length such as "80cqw". 900 by default. */
size?: number | string
/** The center's distance from the parent's left edge; any CSS length. */
left?: string
/** The center's distance from the parent's top edge; any CSS length. */
top?: string
/** Where the lit stroke starts, in degrees clockwise from 12 o'clock; 0. */
from?: number
/** How far the lit stroke runs, in degrees from 0 to 360; 108. */
sweep?: number
/** The lit stroke's color. */
color?: string
/** The faint full ring's color. */
track?: string
/** The lit stroke's thickness in px; 2.5. */
width?: number
/** The faint full ring's thickness in px; 1.5. */
trackWidth?: number
/** Which way the ring turns when animated: clockwise or counterclockwise. */
turn?: "cw" | "ccw"
/** Turns this ring on its own. Reduced motion holds it still. */
animate?: boolean
/** Seconds per full turn; 26 by default. */
duration?: number
}
/**
* A faint full ring with a bright stroke along part of it that fades toward
* its end, for the background behind a section. Place it like `Arc`: in an
* `ArcLayer` or another positioned parent, with `left` and `top` setting its
* center.
*
* It is hidden from assistive tech and ignores the pointer. When animated it
* makes one full turn per `duration`; reduced motion holds it still.
*/
function ArcRing({
size = 900,
left = "50%",
top = "50%",
from,
sweep,
color = "oklch(0.842 0.061 196)",
track = "oklch(0.842 0.061 196 / 0.14)",
width,
trackWidth = 1.5,
turn = "cw",
animate = false,
duration,
className,
style,
...props
}: ArcRingProps) {
const gradientId = `arc-ring-${useId().replace(/[^\w-]/g, "")}`
const start = finite(from, 0)
const lit = Math.min(360, Math.max(0, finite(sweep, 108)))
const stroke = Math.max(0, finite(width, 2.5))
const seconds =
duration !== undefined && Number.isFinite(duration) && duration > 0
? duration
: 26
const diameter = typeof size === "number" ? `${size}px` : size
// The stroke fades along its own chord, clamped at a half turn.
const end = (Math.min(lit, 180) * Math.PI) / 180
return (
<div
data-slot="arc-ring"
data-turn={turn}
data-animate={animate || undefined}
aria-hidden="true"
className={cn("pointer-events-none absolute rounded-full", className)}
style={
{
left,
top,
width: size,
height: size,
margin: `calc(${diameter} / -2) 0 0 calc(${diameter} / -2)`,
rotate: start ? `${start}deg` : undefined,
"--arc-duration": `${seconds}s`,
"--arc-direction": turn === "ccw" ? "reverse" : "normal",
...style,
} as CSSProperties
}
{...props}
>
<style href="arc" precedence="medium">
{ARC_CSS}
</style>
<svg className="block size-full overflow-visible">
<defs>
<linearGradient
id={gradientId}
x1="0.5"
y1="0"
x2={0.5 + 0.5 * Math.sin(end)}
y2={0.5 - 0.5 * Math.cos(end)}
>
<stop offset="0" stopColor={color} />
<stop offset="0.55" stopColor={color} />
<stop offset="1" stopColor={color} stopOpacity="0" />
</linearGradient>
</defs>
<circle
cx="50%"
cy="50%"
r="50%"
fill="none"
stroke={track}
strokeWidth={trackWidth}
/>
{lit > 0 && (
<circle
cx="50%"
cy="50%"
r="50%"
fill="none"
stroke={`url(#${gradientId})`}
strokeWidth={stroke}
strokeLinecap="round"
pathLength={360}
strokeDasharray={`${lit} ${360 - lit}`}
strokeDashoffset={90}
/>
)}
</svg>
</div>
)
}
export { ArcRing }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` is a 12px/20px label in the mono face, in sentence case like
* the others: the kit sets no label in capitals.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element: a `p` is
* right when the label stands alone as a line of text; pass
* `render={<span />}` or `render={<div />}` when it sits inside a heading,
* link, button or other inline text, where a `p` is not valid HTML.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const sectionVariants = cva(
"relative isolate w-full bg-background wrap-anywhere text-foreground",
{
variants: {
/**
* The padding above and below: `sm` 64px (96px from `lg`), `md` (the
* default) 72px (120px from `lg`), `lg` 80px (144px from `lg`).
*/
size: {
sm: "py-16 lg:py-24",
md: "py-18 lg:py-30",
lg: "py-20 lg:py-36",
},
},
defaultVariants: { size: "md" },
}
)
// The gap between the band's children, by the band's size: 40px, and 64px
// from `sm` for `md`; 64px for `lg`.
const columnVariants = cva(
"mx-auto flex w-full max-w-[90.5rem] min-w-0 flex-col px-4 sm:px-6",
{
variants: {
size: {
sm: "gap-10",
md: "gap-10 sm:gap-16",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
}
)
/**
* A page band: a full-width `<section>` holding a centered column, 1400px
* of content with 16px sides on a phone and 24px from `sm`. `size` sets its
* padding and the gap between its children.
*/
function Section({
className,
size = "md",
children,
...props
}: ComponentProps<"section"> & VariantProps<typeof sectionVariants>) {
return (
<section
data-slot="section"
data-size={size}
className={cn(sectionVariants({ size }), className)}
{...props}
>
<div data-slot="section-column" className={columnVariants({ size })}>
{children}
</div>
</section>
)
}
/** Art behind the whole band, hidden from assistive tech. */
function SectionBackground({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-background"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0 -z-10", className)}
{...props}
/>
)
}
const contentVariants = cva("mx-auto flex w-full min-w-0 flex-col", {
variants: {
/** The gap between children: `sm` 24px, `md` (the default) 32px, `lg` 64px. */
size: {
sm: "gap-6",
md: "gap-8",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
})
/**
* A centered column for the band's content, its children stacked with a
* gap. Give it a `max-w-*` class for a narrower column. Pass `render` to
* use another element.
*/
function SectionContent({
className,
size = "md",
render,
...props
}: useRender.ComponentProps<"div"> & VariantProps<typeof contentVariants>) {
return useRender({
defaultTagName: "div",
render,
state: { slot: "section-content" },
props: mergeProps<"div">(
{ className: cn(contentVariants({ size }), className) },
props
),
})
}
const columnsVariants = cva("grid w-full grid-cols-1 items-start gap-16", {
variants: {
/**
* From `lg`: `equal` (the default) two even columns; `intro` a narrower
* first column, 2:3.
*/
variant: {
equal: "lg:grid-cols-2",
intro: "lg:grid-cols-[2fr_3fr]",
},
},
defaultVariants: { variant: "equal" },
})
/** Two columns from `lg`, stacked below it, 64px apart. */
function SectionColumns({
className,
variant = "equal",
...props
}: ComponentProps<"div"> & VariantProps<typeof columnsVariants>) {
return (
<div
data-slot="section-columns"
data-variant={variant}
className={cn(columnsVariants({ variant }), className)}
{...props}
/>
)
}
const headerVariants = cva("group/section-header grid w-full min-w-0", {
variants: {
/** `start` (the default) or `center`, which centers everything in it. */
align: {
start: "",
center: "justify-items-center text-center",
},
/**
* `stack` (the default) is one column, its children 16px apart.
* `split` puts the second child, such as SectionActions, on the right
* from `sm`, level with the bottom of the first, and 24px under it
* below `sm`.
*/
variant: {
stack: "gap-4",
split: "justify-items-start gap-6 sm:grid-cols-[1fr_auto] sm:items-end",
},
},
defaultVariants: { align: "start", variant: "stack" },
})
/**
* The band's heading area. Its children are an optional Eyebrow, then
* SectionTitle, SectionDescription and SectionActions, 16px apart, with
* 24px above the actions. `variant="split"` takes two children and puts
* the second on the right; when the left side is more than a title, group
* it in a SectionHeader of its own. It has no max width, so a title runs
* the column; the description's width is its own (45rem).
*/
function SectionHeader({
className,
align = "start",
variant = "stack",
...props
}: ComponentProps<"div"> & VariantProps<typeof headerVariants>) {
return (
<div
data-slot="section-header"
data-align={align}
data-variant={variant}
className={cn(headerVariants({ align, variant }), className)}
{...props}
/>
)
}
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const sectionTitleVariants = cva("font-display font-[450] text-pretty", {
variants: {
/**
* `default` keeps the surrounding display face, tracked -0.05em and
* -0.06em from `sm`. `serif` uses the kit's serif face, tracked
* -0.03em.
*/
variant: {
default: "tracking-[-0.05em] sm:tracking-[-0.06em]",
serif: "tracking-[-0.03em] [--font-display:var(--font-serif)]",
},
/**
* `xl` (the default): 32px/40px, 56px/56px from `lg`, the section
* title. `closing`: 40px/48px, 48px/56px from `lg`, for a closing or
* side title. `lg`: 32px/40px, 40px/48px from `sm`,
* 48px/56px from `lg`. `md`: 32px/40px, capped at 40px/44px from `sm`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 lg:text-[3.5rem]/14",
closing: "text-[2.5rem]/12 lg:text-5xl/14",
},
},
defaultVariants: { variant: "default", size: "xl" },
})
/**
* A section's title in the display font, an `<h2>` at weight 450. The
* default `size="xl"` is 32px/40px, then 56px/56px from `lg`. Choose
* `size="closing"` for a closing or side title, 40px/48px then 48px/56px
* at `lg`; `size="lg"` for 32px/40px, 40px/48px at `sm` and 48px/56px at
* `lg`; or `size="md"` for 32px/40px, capped at 40px/44px from `sm`.
* `variant="serif"` uses the kit's serif face with its own, looser
* tracking. Pass `render` to use another heading level. A page's headline
* is `Heading`.
*/
function SectionTitle({
className,
variant = "default",
size = "xl",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof sectionTitleVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "section-title", variant, size },
props: mergeProps<"h2">(
{ className: cn(sectionTitleVariants({ variant, size }), className) },
props
),
})
}
/**
* The text under a section's title, a `<p>` in the muted text color:
* 16px/24px, then 18px/28px from `lg`, with balanced lines. It has no
* width of its own: give it a `max-w-*` class where it's used, or let the
* layout set the measure. A `text-*` color class replaces the color. Pass
* `render` to use another element.
*/
function SectionDescription({
className,
render,
...props
}: useRender.ComponentProps<"p">) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "section-description" },
props: mergeProps<"p">(
{
className: cn(
"w-full min-w-0 text-base/6 text-balance text-muted-foreground lg:text-lg/7",
className
),
},
props
),
})
}
// Stacked in a SectionHeader, the actions sit 24px under the text: the
// header's 16px gap plus 8px of their own.
const sectionActionsVariants = cva(
"flex max-w-full flex-wrap items-center gap-4 group-data-[variant=stack]/section-header:mt-2",
{
variants: {
/** `start` (the default) or `center`. */
align: {
start: "",
center: "justify-center",
},
},
defaultVariants: { align: "start" },
}
)
/**
* The band's buttons or links, in a row that wraps, 16px apart. Put it
* last in a SectionHeader, or anywhere else in the band.
*/
function SectionActions({
className,
align = "start",
...props
}: ComponentProps<"div"> & VariantProps<typeof sectionActionsVariants>) {
return (
<div
data-slot="section-actions"
data-align={align}
className={cn(sectionActionsVariants({ align }), className)}
{...props}
/>
)
}
/**
* A rounded panel inside a Section's column: edge to edge and square on a
* phone, then rounded with 96px of padding from `md`. Give it a theme
* class, such as `dark`, to paint it apart from the page.
*/
function SectionPanel({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-panel"
className={cn(
"relative isolate -mx-4 overflow-hidden border border-transparent bg-background px-4 py-12 text-foreground sm:-mx-6 sm:px-6 md:mx-0 md:rounded-lg md:p-24 dark:border-border",
className
)}
{...props}
/>
)
}
export {
Section,
SectionBackground,
SectionPanel,
SectionContent,
SectionColumns,
SectionHeader,
SectionTitle,
SectionDescription,
SectionActions,
sectionTitleVariants,
}
import type { ComponentProps } from "react"
import { cn } from "cn"
import { textVariants } from "@/components/text/text"
import {
Card,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
/**
* A wide card with copy on one side and a picture or scene on the other.
* Compose it from its parts: a `SplitCardContent` holding a
* `SplitCardHeader` (meta, `SplitCardTitle`, `SplitCardDescription`) and
* `SplitCardActions`, then a `SplitCardMedia`. It is the kit's `Card` and
* its parts, styled. Every part takes `className`.
*
* It responds to the screen: the two halves stack on small screens and sit
* side by side from the `md` breakpoint (48rem), where the padding, title
* size and divider change too; the padding grows again from `lg`. As in the
* stock Card, the header is the `card-header` container.
*/
function SplitCard({
flip = false,
className,
...props
}: ComponentProps<typeof Card> & {
/** Once the halves sit side by side, puts the media on the left. */
flip?: boolean
}) {
return (
<Card
data-slot="split-card"
data-flip={flip || undefined}
className={cn(
"group/split-card grid gap-0 py-0 text-base md:grid-cols-2",
className
)}
{...props}
/>
)
}
/**
* The copy half: centered, holding the header and the actions 24px apart.
* Its padding is 32px, 40px from `md` and 56px from `lg`.
*/
function SplitCardContent({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="split-card-content"
className={cn(
"flex flex-col justify-center gap-6 p-8 md:p-10 group-data-flip/split-card:md:order-2 lg:p-14",
className
)}
{...props}
/>
)
}
/**
* The copy's top block: an optional line of meta, the title and the
* description, 24px apart, capped at 28rem so a line stays readable. The
* stock `card-header` container, without the card's padding, since the
* content half pads.
*/
function SplitCardHeader({
className,
...props
}: ComponentProps<typeof CardHeader>) {
return (
<CardHeader
data-slot="split-card-header"
// w-full, because an inline-size container has no intrinsic width: without
// it the header collapses when its parent does not stretch it.
className={cn("w-full max-w-md gap-6 rounded-none px-0", className)}
{...props}
/>
)
}
/** The card's title, read as a level-3 heading: 24px, 30px from `md`. */
function SplitCardTitle({
className,
...props
}: ComponentProps<typeof CardTitle>) {
return (
<CardTitle
data-slot="split-card-title"
role="heading"
aria-level={3}
className={cn(
"text-2xl/8 font-[450] tracking-[-0.04em] text-balance md:text-3xl/9",
className
)}
{...props}
/>
)
}
/** Muted supporting text under the title, 16px with 28px lines. */
function SplitCardDescription({
className,
...props
}: ComponentProps<typeof CardDescription>) {
return (
<CardDescription
data-slot="split-card-description"
className={cn(textVariants({ variant: "muted", size: "md" }), className)}
{...props}
/>
)
}
/** The card's buttons or links, in a row that wraps when they do not fit. */
function SplitCardActions({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="split-card-actions"
className={cn("flex flex-wrap items-center gap-3", className)}
{...props}
/>
)
}
/**
* The picture half: at least 24rem tall, centered and clipped. A scene fills
* it with `absolute inset-0`; an `img` needs `size-full object-cover`.
* `divider` (on by default) draws the hairline between the halves: along the
* top while they stack, along the inner edge once they sit side by side.
*/
function SplitCardMedia({
divider = true,
className,
...props
}: ComponentProps<"div"> & {
/** The hairline between the copy and the media. `false` removes it at every width. */
divider?: boolean
}) {
return (
<div
data-slot="split-card-media"
className={cn(
"relative grid min-h-96 place-items-center overflow-hidden group-data-flip/split-card:md:order-1",
divider &&
"border-t border-border md:border-t-0 md:before:absolute md:before:inset-y-0 md:before:left-0 md:before:z-1 md:before:w-px md:before:bg-border group-data-flip/split-card:md:before:right-0 group-data-flip/split-card:md:before:left-auto",
className
)}
{...props}
/>
)
}
export {
SplitCard,
SplitCardContent,
SplitCardHeader,
SplitCardTitle,
SplitCardDescription,
SplitCardActions,
SplitCardMedia,
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// Paragraphs in body content and introductions. It has no width of its own:
// the layout sets the measure. The default sets the foreground color; muted
// steps it down. Over art or a colored ground, pass className="text-current"
// to keep the ink around it. The text under a section's title is
// SectionDescription.
const textVariants = cva("w-full min-w-0 text-balance", {
variants: {
/**
* The text color. `default` (the default) is `foreground`; `muted`
* is `muted-foreground`. For the ink of a colored ground or art, pass
* `className="text-current"`.
*/
variant: {
default: "text-foreground",
muted: "text-muted-foreground",
},
/**
* The text size and line height: `xs` 12px/20px for a footnote or fine
* print; `sm` 14px/24px for the line under a card or panel title; `md`
* (the default) 16px/28px for body copy; `lg` 18px/28px at every width;
* `xl` 18px/28px, then 20px/32px from `sm` for a hero introduction.
*/
size: {
xs: "text-xs/5",
sm: "text-sm/6",
md: "text-base/7",
lg: "text-lg/7",
xl: "text-lg/7 sm:text-xl/8",
},
/**
* Tabular figures: every digit takes the same width, so numbers line up
* in a column and a changing count does not shift the text.
*/
tabular: {
true: "tabular-nums",
false: "",
},
},
defaultVariants: { variant: "default", size: "md", tabular: false },
})
/**
* A paragraph in body content or an introduction, a `p` by default. For
* several paragraphs, pass `render={<div />}` and put your own `p` elements
* inside.
*
* The default is the `foreground` color at regular weight (400, inherited
* from the page unless a parent sets one), and the lines are balanced when it
* wraps. `size` sets the text and its line height: `xs` 12px/20px for a
* footnote or fine print; `sm` 14px/24px for the line under a card or panel
* title; `md` (the default) 16px/28px for body copy in cards, lists and rows;
* `lg` 18px/28px; or `xl` 18px/28px and 20px/32px from `sm` for a hero.
* `variant="muted"` uses the muted text color. On art or a colored ground,
* pass `className="text-current"` to keep the ink around it. `tabular` sets
* tabular figures for numbers that line up or change. The layout controls the
* text's width and spacing. The text under a section's title is
* `SectionDescription`.
*/
function Text({
className,
variant = "default",
size = "md",
tabular = false,
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size, tabular },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size, tabular }), className) },
props
),
})
}
export { Text, textVariants }
import type { ComponentProps } from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { Grid, type GridProps } from "@/components/grid/grid"
/**
* A list of `Stat` items laid out by `Grid`, rendered as a `ul`. It defaults
* to 3 columns and the large gap. Like `Grid`, its columns follow the width
* it is given, so size its parent to narrow it. `className` lands on the
* list.
*/
function StatGroup({
cols = 3,
gap = "lg",
...props
}: ComponentProps<"ul"> & {
/**
* The most columns, 3 by default. They step up as the list's space
* widens, the way `Grid`'s do.
*/
cols?: GridProps["cols"]
/**
* Space between stats: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default.
*/
gap?: GridProps["gap"]
}) {
return (
<Grid
data-slot="stat-group"
render={<ul role="list" />}
cols={cols}
gap={gap}
// Grid's props are typed for its default div; this group renders a list.
{...(props as Omit<GridProps, "cols" | "gap">)}
/>
)
}
// card sets the stat on a filled panel; rule sets a line down its left side.
const statVariants = cva("grid content-start gap-2", {
variants: {
/**
* The stat style. `default` (the default) adds nothing. `card` sets it
* on a `rounded-xl` panel with 32px padding, filled with `muted`, or
* with `card` and `card-foreground` text in dark mode. `rule` draws a
* 1px line in `border` down its left side, 24px from the text.
*/
variant: {
default: "",
card: "rounded-xl bg-muted p-8 dark:bg-card dark:text-card-foreground",
rule: "border-l border-border pl-6",
},
},
defaultVariants: { variant: "default" },
})
/**
* One figure and its label, as an `li` inside `StatGroup`. Holds a
* `StatValue` and a `StatLabel`, stacked with 8px gaps.
*
* `card` sets it on a filled, rounded panel with 32px padding. `rule` draws a
* line down its left side.
*/
function Stat({
className,
variant = "default",
...props
}: ComponentProps<"li"> & VariantProps<typeof statVariants>) {
return (
<li
data-slot="stat"
data-variant={variant}
className={cn(statVariants({ variant }), className)}
{...props}
/>
)
}
/** The figure itself, such as a number or a percentage, at 32px in the body font. */
function StatValue({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="stat-value"
className={cn("text-[2rem]/10 tracking-tight", className)}
{...props}
/>
)
}
/**
* The caption under the figure: what it measures, in a few words. Small
* muted text, 14px on a 20px line, so the number carries the weight. Longer
* explanation belongs in the section's lead or a note, not here.
*/
function StatLabel({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="stat-label"
className={cn("text-sm/5 text-pretty text-muted-foreground", className)}
{...props}
/>
)
}
export { StatGroup, Stat, StatValue, StatLabel }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const GRID_DEFAULTS = { cols: 3, gap: "lg" } as const
const containerGridVariants = cva("grid w-full grid-cols-1", {
variants: {
/**
* The most columns. Below 40rem of screen width the grid is one
* column (two for `6`); it steps up at 40rem and 48rem: `2` is two
* columns from 40rem, `3` two then three, `4` two then four, `5` three
* then five, and `6` three, then four, then six from 64rem. The default
* is 3.
*/
cols: {
1: "",
2: "sm:grid-cols-2",
3: "sm:grid-cols-2 md:grid-cols-3",
4: "sm:grid-cols-2 md:grid-cols-4",
5: "sm:grid-cols-3 md:grid-cols-5",
6: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6",
},
/**
* Space between items: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default. The sizes are the `--gap-*` values in globals.css.
*/
gap: {
xs: "gap-(--gap-xs)",
sm: "gap-(--gap-sm)",
md: "gap-(--gap-md)",
lg: "gap-(--gap-lg)",
xl: "gap-(--gap-xl)",
px: "gap-px",
none: "gap-0",
},
},
defaultVariants: GRID_DEFAULTS,
})
type GridState = { slot: "grid" } & VariantProps<typeof containerGridVariants>
type GridProps = useRender.ComponentProps<"div", GridState> &
VariantProps<typeof containerGridVariants>
/**
* Columns follow the screen, stepping at 40rem and 48rem (and 64rem for six).
* Gap sizes read the shared `--gap-*` values in globals.css. The grid fills
* its parent's width: without that, a grid given `mx-auto` or set inside a
* centering parent shrinks to fit its content, and a part built on it that
* is a container collapses to nothing.
*
* className, render and every other prop go to the grid. To narrow a Grid, pass
* a `max-w-*` class or size its parent.
*/
function Grid({
className,
cols = GRID_DEFAULTS.cols,
gap = GRID_DEFAULTS.gap,
render,
...props
}: GridProps) {
const grid = useRender({
defaultTagName: "div",
render,
state: { slot: "grid", cols, gap },
props: mergeProps<"div">(
{ className: cn(containerGridVariants({ cols, gap }), className) },
props
),
})
return grid
}
export { Grid, type GridProps }
Installation
npx shadcn@latest add @01orbital/project-progress-rings-cardMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/metrics/project-progress-rings-card/index.tsx: change them there, not in the markup. PROJECTS,COMPLETED,TOTAL,PERCENTandCHART_LABEL, also at the top of the file, hold its lists and settings.- Its look comes from Arc Ring; each page lists the props that change it.
Built from
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
Last updated on