Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions r/card.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion r/row-link.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"path": "src/components/cipher/ui/row-link.module.css",
"type": "registry:file",
"target": "src/components/cipher/ui/row-link.module.css",
"content": ".rowLink {\n display: block;\n min-width: 0;\n overflow: hidden;\n color: inherit;\n text-decoration: none;\n text-overflow: ellipsis;\n white-space: nowrap;\n outline: none;\n}\n.rowLink[data-disabled] {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.rowLink[data-chevron] {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: var(--cipher-space-8);\n}\n.label {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.chevron {\n flex: none;\n width: var(--cipher-size-glyph);\n height: var(--cipher-size-glyph);\n stroke-width: var(--cipher-stroke-icon);\n color: var(--cipher-muted);\n transition: color var(--cipher-duration-fast) var(--cipher-ease-fade);\n}\n.rowLink[data-disabled] .chevron {\n color: var(--cipher-faint);\n}\n:is(:global(tr), :global([data-slot=\"card\"])):is(:hover, :focus-within) .stretched .chevron {\n color: var(--cipher-ink);\n}\n/* Static, so the cover is sized by the cell and not by the stretched-row rule that lifts other links. */\n.cellLink {\n position: static;\n}\n.cellLink::after {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 2;\n}\n.cellLink:focus-visible::after {\n outline: var(--cipher-size-focus-ring) solid var(--cipher-ink);\n outline-offset: calc(-1 * var(--cipher-size-focus-ring));\n}\n:where(:global(td)[data-cell-link]) {\n position: relative;\n cursor: pointer;\n}\n:where(:global(td)[data-cell-link]):hover {\n background-image: linear-gradient(var(--cipher-hover), var(--cipher-hover));\n}\n.cardLink {\n color: inherit;\n text-decoration: none;\n outline: none;\n}\n.cardLink[data-disabled] {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.cardChoice {\n display: inline-flex;\n align-items: center;\n gap: var(--cipher-space-8);\n max-width: 100%;\n padding: 0;\n border: 0;\n background: none;\n font: inherit;\n letter-spacing: inherit;\n text-align: start;\n cursor: pointer;\n}\n.cardChoice:disabled {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.cardChoiceLabel {\n min-width: 0;\n}\n.stretched::after {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 1;\n}\n.stretched:focus-visible::after {\n outline: var(--cipher-size-focus-ring) solid var(--cipher-ink);\n outline-offset: calc(-1 * var(--cipher-size-focus-ring));\n}\n:global(tr)[data-stretched-link],\n:global([data-slot=\"card\"])[data-stretched-link],\n:global([data-slot=\"stat-card\"])[data-stretched-link] {\n position: relative;\n cursor: pointer;\n}\n:global([data-slot=\"card\"])[data-stretched-link]:hover {\n background-image: linear-gradient(\n var(--cipher-action-ghost-hover),\n var(--cipher-action-ghost-hover)\n );\n}\n/* :where keeps this at zero specificity, so a control that positions itself absolutely keeps its own layout. */\n:where(\n :global(tr)[data-stretched-link],\n :global([data-slot=\"card\"])[data-stretched-link],\n :global([data-slot=\"stat-card\"])[data-stretched-link]\n )\n :where(\n button:not(.stretched),\n input,\n select,\n textarea,\n label,\n summary,\n a:not(.stretched),\n [role=\"button\"],\n [role=\"checkbox\"]:not(.stretched),\n [role=\"combobox\"],\n [role=\"switch\"],\n [data-slot=\"tooltip-trigger\"],\n [data-row-interactive]\n ) {\n position: relative;\n z-index: 2;\n}\n"
"content": ".rowLink {\n display: block;\n min-width: 0;\n overflow: hidden;\n color: inherit;\n text-decoration: none;\n text-overflow: ellipsis;\n white-space: nowrap;\n outline: none;\n}\n.rowLink[data-disabled] {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.rowLink[data-chevron] {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: var(--cipher-space-8);\n}\n.label {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.chevron {\n flex: none;\n width: var(--cipher-size-glyph);\n height: var(--cipher-size-glyph);\n stroke-width: var(--cipher-stroke-icon);\n color: var(--cipher-muted);\n transition: color var(--cipher-duration-fast) var(--cipher-ease-fade);\n}\n.rowLink[data-disabled] .chevron {\n color: var(--cipher-faint);\n}\n:is(:global(tr), :global([data-slot=\"card\"])):is(:hover, :focus-within) .stretched .chevron {\n color: var(--cipher-ink);\n}\n/* Static, so the cover is sized by the cell and not by the stretched-row rule that lifts other links. */\n.cellLink {\n position: static;\n}\n.cellLink::after {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 2;\n}\n.cellLink:focus-visible::after {\n outline: var(--cipher-size-focus-ring) solid var(--cipher-ink);\n outline-offset: calc(-1 * var(--cipher-size-focus-ring));\n}\n:where(:global(td)[data-cell-link]) {\n position: relative;\n cursor: pointer;\n}\n:where(:global(td)[data-cell-link]):hover {\n background-image: linear-gradient(var(--cipher-hover), var(--cipher-hover));\n}\n.cardLink {\n color: inherit;\n text-decoration: none;\n outline: none;\n}\n.cardLink[data-disabled] {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.cardChoice {\n display: inline-flex;\n align-items: center;\n gap: var(--cipher-space-8);\n max-width: 100%;\n padding: 0;\n border: 0;\n background: none;\n font: inherit;\n letter-spacing: inherit;\n text-align: start;\n cursor: pointer;\n}\n.cardChoice:disabled {\n color: var(--cipher-muted);\n cursor: not-allowed;\n}\n.cardChoiceLabel {\n min-width: 0;\n}\n.stretched::after {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 1;\n pointer-events: auto;\n}\n.stretched:focus-visible::after {\n outline: var(--cipher-size-focus-ring) solid var(--cipher-ink);\n outline-offset: calc(-1 * var(--cipher-size-focus-ring));\n}\n:global(tr)[data-stretched-link],\n:global([data-slot=\"card\"])[data-stretched-link],\n:global([data-slot=\"stat-card\"])[data-stretched-link] {\n position: relative;\n cursor: pointer;\n}\n:global([data-slot=\"card\"])[data-stretched-link]:hover {\n background-image: linear-gradient(\n var(--cipher-action-ghost-hover),\n var(--cipher-action-ghost-hover)\n );\n}\n/* :where keeps this at zero specificity, so a control that positions itself absolutely keeps its own layout. */\n:where(\n :global(tr)[data-stretched-link],\n :global([data-slot=\"card\"])[data-stretched-link],\n :global([data-slot=\"stat-card\"])[data-stretched-link]\n )\n :where(\n button:not(.stretched),\n input,\n select,\n textarea,\n label,\n summary,\n a:not(.stretched),\n [role=\"button\"],\n [role=\"checkbox\"]:not(.stretched),\n [role=\"combobox\"],\n [role=\"switch\"],\n [data-slot=\"tooltip-trigger\"],\n [data-row-interactive]\n ) {\n position: relative;\n z-index: 2;\n pointer-events: auto;\n}\n/* A content panel that paints a backdrop is its own stacking context, so it rises above the link\n overlay and lets clicks through to it, keeping its controls (lifted above) clickable. It stays\n unpositioned (z-index applies to it as a flex item) so the overlay still covers the whole card. */\n:is(:global([data-slot=\"card\"]), :global([data-slot=\"stat-card\"]))[data-stretched-link]\n > :global([data-slot=\"card-content\"][data-backdrop]) {\n z-index: 2;\n pointer-events: none;\n}\n"
}
]
}
2 changes: 1 addition & 1 deletion r/stat-card.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"path": "src/components/cipher/ui/stat-card.tsx",
"type": "registry:file",
"target": "src/components/cipher/ui/stat-card.tsx",
"content": "import * as React from \"react\";\n\nimport type { CipherLinkProps } from \"../lib/link\";\nimport { useInFrame } from \"../lib/frame-context\";\nimport { cn } from \"../lib/utils\";\nimport { Card, CardContent, CardLink } from \"./card\";\nimport { Icon, type IconSource } from \"./icon\";\nimport { Media } from \"./item\";\nimport { Skeleton } from \"./skeleton\";\nimport { StatusText } from \"./text\";\n\nimport styles from \"./stat-card.module.css\";\n\nconst trendIcon = {\n up: \"arrow-up\",\n down: \"arrow-down\",\n flat: \"minus\"\n} as const;\nconst trendTone = { up: \"ok\", down: \"bad\", flat: \"neutral\" } as const;\n\nexport type StatCardProps = Omit<\n React.ComponentProps<typeof Card>,\n \"title\" | \"badges\" | \"description\" | \"hint\" | \"action\" | \"footer\" | \"footerPlacement\" | \"children\"\n> & {\n label: React.ReactNode;\n value: React.ReactNode;\n icon?: IconSource;\n /** Tone of the icon, for a metric that needs attention. */\n tone?: \"ok\" | \"warn\" | \"bad\" | \"info\";\n /** The change since the last period, such as \"+12%\". Its text carries the direction; the arrow is decoration. */\n delta?: React.ReactNode;\n trend?: \"up\" | \"down\" | \"flat\";\n /** Defaults to ok for up, bad for down and neutral for flat; set it for a metric where up is bad. */\n deltaTone?: \"ok\" | \"bad\" | \"neutral\";\n /** A short line under the value: what the number counts, the comparison period, or a link. */\n note?: React.ReactNode;\n /** Makes the whole card a link, named by the label. */\n link?: CipherLinkProps[\"link\"];\n loading?: boolean;\n /** Replaces the value with this message when the metric failed to load. */\n error?: React.ReactNode;\n};\n\nexport function StatCard({\n label,\n value,\n icon,\n tone,\n delta,\n trend = \"flat\",\n deltaTone,\n note,\n link,\n loading = false,\n error,\n variant = \"framed\",\n backdrop,\n className,\n ...props\n}: StatCardProps) {\n const inFrame = useInFrame(\"StatCard\");\n const panelBackdrop = variant === \"framed\" && !inFrame;\n const id = React.useId();\n const labelId = `${id}-label`;\n const valueId = `${id}-value`;\n const failed = error !== undefined && error !== null && error !== false;\n return (\n <Card\n data-slot=\"stat-card\"\n role=\"group\"\n aria-labelledby={labelId}\n aria-busy={loading || undefined}\n variant={variant}\n className={cn(styles.statCard, className)}\n backdrop={panelBackdrop ? undefined : backdrop}\n {...props}\n >\n <CardContent className={styles.body}>\n {panelBackdrop && backdrop}\n <div className={styles.head}>\n <span id={labelId} className={styles.label}>\n {link ? (\n <CardLink link={link} aria-describedby={valueId}>\n {label}\n </CardLink>\n ) : (\n label\n )}\n </span>\n {icon && <Media icon={icon} size=\"sm\" tone={tone} aria-hidden />}\n </div>\n {loading ? (\n <Skeleton className={styles.valueSkeleton} />\n ) : failed ? (\n <StatusText tone=\"bad\" icon=\"alert\" className={styles.error}>\n {error}\n </StatusText>\n ) : (\n <div id={valueId} data-slot=\"stat-card-value\" className={styles.value}>\n {value}\n </div>\n )}\n {!loading && !failed && (delta !== undefined || note !== undefined) && (\n <div className={styles.foot}>\n {delta !== undefined && (\n <span\n data-slot=\"stat-card-delta\"\n data-tone={deltaTone ?? trendTone[trend]}\n className={styles.delta}\n >\n <Icon name={trendIcon[trend]} aria-hidden />\n {delta}\n </span>\n )}\n {note !== undefined && <span className={styles.note}>{note}</span>}\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n"
"content": "import * as React from \"react\";\n\nimport type { CipherLinkProps } from \"../lib/link\";\nimport { cn } from \"../lib/utils\";\nimport { Card, CardContent, CardLink } from \"./card\";\nimport { Icon, type IconSource } from \"./icon\";\nimport { Media } from \"./item\";\nimport { Skeleton } from \"./skeleton\";\nimport { StatusText } from \"./text\";\n\nimport styles from \"./stat-card.module.css\";\n\nconst trendIcon = {\n up: \"arrow-up\",\n down: \"arrow-down\",\n flat: \"minus\"\n} as const;\nconst trendTone = { up: \"ok\", down: \"bad\", flat: \"neutral\" } as const;\n\nexport type StatCardProps = Omit<\n React.ComponentProps<typeof Card>,\n \"title\" | \"badges\" | \"description\" | \"hint\" | \"action\" | \"footer\" | \"footerPlacement\" | \"children\"\n> & {\n label: React.ReactNode;\n value: React.ReactNode;\n icon?: IconSource;\n /** Tone of the icon, for a metric that needs attention. */\n tone?: \"ok\" | \"warn\" | \"bad\" | \"info\";\n /** The change since the last period, such as \"+12%\". Its text carries the direction; the arrow is decoration. */\n delta?: React.ReactNode;\n trend?: \"up\" | \"down\" | \"flat\";\n /** Defaults to ok for up, bad for down and neutral for flat; set it for a metric where up is bad. */\n deltaTone?: \"ok\" | \"bad\" | \"neutral\";\n /** A short line under the value: what the number counts, the comparison period, or a link. */\n note?: React.ReactNode;\n /** Makes the whole card a link, named by the label. */\n link?: CipherLinkProps[\"link\"];\n loading?: boolean;\n /** Replaces the value with this message when the metric failed to load. */\n error?: React.ReactNode;\n};\n\nexport function StatCard({\n label,\n value,\n icon,\n tone,\n delta,\n trend = \"flat\",\n deltaTone,\n note,\n link,\n loading = false,\n error,\n variant = \"framed\",\n className,\n ...props\n}: StatCardProps) {\n const id = React.useId();\n const labelId = `${id}-label`;\n const valueId = `${id}-value`;\n const failed = error !== undefined && error !== null && error !== false;\n return (\n <Card\n data-slot=\"stat-card\"\n role=\"group\"\n aria-labelledby={labelId}\n aria-busy={loading || undefined}\n variant={variant}\n className={cn(styles.statCard, className)}\n {...props}\n >\n <CardContent className={styles.body}>\n <div className={styles.head}>\n <span id={labelId} className={styles.label}>\n {link ? (\n <CardLink link={link} aria-describedby={valueId}>\n {label}\n </CardLink>\n ) : (\n label\n )}\n </span>\n {icon && <Media icon={icon} size=\"sm\" tone={tone} aria-hidden />}\n </div>\n {loading ? (\n <Skeleton className={styles.valueSkeleton} />\n ) : failed ? (\n <StatusText tone=\"bad\" icon=\"alert\" className={styles.error}>\n {error}\n </StatusText>\n ) : (\n <div id={valueId} data-slot=\"stat-card-value\" className={styles.value}>\n {value}\n </div>\n )}\n {!loading && !failed && (delta !== undefined || note !== undefined) && (\n <div className={styles.foot}>\n {delta !== undefined && (\n <span\n data-slot=\"stat-card-delta\"\n data-tone={deltaTone ?? trendTone[trend]}\n className={styles.delta}\n >\n <Icon name={trendIcon[trend]} aria-hidden />\n {delta}\n </span>\n )}\n {note !== undefined && <span className={styles.note}>{note}</span>}\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n"
},
{
"path": "src/components/cipher/ui/stat-card.module.css",
Expand Down
4 changes: 4 additions & 0 deletions site/src/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,10 @@
{
"title": "Bounds, size and reveal (hover a card)",
"module": "halftone/bounds"
},
{
"title": "Framed, without a frame footer",
"module": "halftone/framed"
}
]
},
Expand Down
61 changes: 61 additions & 0 deletions site/src/examples/halftone/framed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Button } from "@infisical/cipher/ui/button";
import { Card, CardContent, CardHeader, CardLink, CardTitle } from "@infisical/cipher/ui/card";
import { Halftone } from "@infisical/cipher/ui/halftone";
import { hueScope } from "@infisical/cipher/lib/hue";

export default function Example() {
return (
<div
{...hueScope(250, "pop")}
className="grid w-full min-w-0 grid-cols-[repeat(auto-fit,minmax(min(100%,20rem),1fr))] items-start gap-x-6 gap-y-8"
>
<figure className="m-0 flex w-full min-w-0 flex-col gap-3">
<Card variant="framed" title="payments-api" backdrop={<Halftone seed="no-footer" />}>
Card checkout and refunds.
</Card>
<figcaption className="text-muted-foreground text-xs">
{"title in the band, no footer"}
</figcaption>
</figure>
<figure className="m-0 flex w-full min-w-0 flex-col gap-3">
<Card
variant="framed"
title="payments-api"
footer="3 environments"
backdrop={<Halftone seed="inset-footer" />}
>
Card checkout and refunds.
</Card>
<figcaption className="text-muted-foreground text-xs">{"inset footer"}</figcaption>
</figure>
<figure className="m-0 flex w-full min-w-0 flex-col gap-3">
<Card variant="framed" backdrop={<Halftone seed="composed" />}>
<CardHeader>
<CardTitle>payments-api</CardTitle>
</CardHeader>
<CardContent>Card checkout and refunds.</CardContent>
</Card>
<figcaption className="text-muted-foreground text-xs">
{"composed from CardHeader and CardContent"}
</figcaption>
</figure>
<figure className="m-0 flex w-full min-w-0 flex-col gap-3">
<Card
variant="framed"
title={<CardLink link={{ href: "#/components/halftone" }}>payments-api</CardLink>}
backdrop={<Halftone seed="linked" />}
>
<div className="flex items-center justify-between gap-3">
Card checkout and refunds.
<Button variant="outline" size="sm">
Rotate
</Button>
</div>
</Card>
<figcaption className="text-muted-foreground text-xs">
{"linked, with a control in the body"}
</figcaption>
</figure>
</div>
);
}
Loading
Loading