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
2 changes: 1 addition & 1 deletion r/card.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 position: relative;\n cursor: pointer;\n}\n:global([data-slot=\"card\"])[data-stretched-link]:hover {\n background-image: linear-gradient(var(--cipher-action-ghost-hover), var(--cipher-action-ghost-hover));\n}\n/* :where keeps this at zero specificity, so a control that positions itself absolutely keeps its own layout. */\n:where(:global(tr)[data-stretched-link], :global([data-slot=\"card\"])[data-stretched-link])\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}\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"
}
]
}
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 position: relative;\n cursor: pointer;\n}\n:global([data-slot=\"card\"])[data-stretched-link]:hover {\n background-image: linear-gradient(var(--cipher-action-ghost-hover), var(--cipher-action-ghost-hover));\n}\n/* :where keeps this at zero specificity, so a control that positions itself absolutely keeps its own layout. */\n:where(:global(tr)[data-stretched-link], :global([data-slot=\"card\"])[data-stretched-link])\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}\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"
}
]
}
4 changes: 4 additions & 0 deletions site/src/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,10 @@
{
"title": "Loading, error and attention",
"module": "stat-card/states"
},
{
"title": "Linked, framed and plain",
"module": "stat-card/linked"
}
]
},
Expand Down
46 changes: 46 additions & 0 deletions site/src/examples/stat-card/linked.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Button } from "@infisical/cipher/ui/button";
import { Halftone } from "@infisical/cipher/ui/halftone";
import { Grid } from "@infisical/cipher/ui/layout";
import { StatCard } from "@infisical/cipher/ui/stat-card";

export default function Example() {
return (
<Grid data-testid="linked-stat-cards" className="w-full">
<StatCard
label="Total accounts"
value="1,284"
icon="building"
note={
<Button variant="link" size="sm" asChild>
<a href="#/stat-card-linked/new-accounts">12 new this week</a>
</Button>
}
link={{ href: "#/stat-card-linked/accounts" }}
/>
<StatCard
label="Total licenses"
value="3,902"
icon="key"
backdrop={<Halftone seed="licenses" />}
link={{ href: "#/stat-card-linked/licenses" }}
/>
<StatCard
variant="plain"
label="Suspended"
value="7"
icon="lock"
tone="bad"
link={{ href: "#/stat-card-linked/suspended" }}
/>
<StatCard
variant="plain"
label="In grace"
value="12"
icon="clock"
tone="warn"
backdrop={<Halftone seed="grace" />}
link={{ href: "#/stat-card-linked/grace" }}
/>
</Grid>
);
}
14 changes: 11 additions & 3 deletions src/ui/row-link.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,23 @@
outline-offset: calc(-1 * var(--cipher-size-focus-ring));
}
:global(tr)[data-stretched-link],
:global([data-slot="card"])[data-stretched-link] {
:global([data-slot="card"])[data-stretched-link],
:global([data-slot="stat-card"])[data-stretched-link] {
position: relative;
cursor: pointer;
}
:global([data-slot="card"])[data-stretched-link]:hover {
background-image: linear-gradient(var(--cipher-action-ghost-hover), var(--cipher-action-ghost-hover));
background-image: linear-gradient(
var(--cipher-action-ghost-hover),
var(--cipher-action-ghost-hover)
);
}
/* :where keeps this at zero specificity, so a control that positions itself absolutely keeps its own layout. */
:where(:global(tr)[data-stretched-link], :global([data-slot="card"])[data-stretched-link])
:where(
:global(tr)[data-stretched-link],
:global([data-slot="card"])[data-stretched-link],
:global([data-slot="stat-card"])[data-stretched-link]
)
:where(
button:not(.stretched),
input,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions visual/stat-card-link.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from "@playwright/test";

test("a linked StatCard keeps its link inside the card", async ({ page }) => {
await page.goto("visual.html?page=stat-card&theme=light");
const grid = page.getByTestId("linked-stat-cards");
await expect(grid.locator('[data-slot="stat-card"]')).toHaveCount(4);
const start = page.url();

const box = (await grid.boundingBox())!;
await page.mouse.click(box.x + box.width / 2, box.y + box.height + 12);
await page.getByRole("heading", { name: "Linked, framed and plain" }).click();
expect(page.url()).toBe(start);

for (const [value, target] of [
["1,284", "accounts"],
["3,902", "licenses"],
["7", "suspended"],
["12", "grace"]
]) {
const text = grid.getByText(value, { exact: true });
await text.scrollIntoViewIfNeeded();
const cell = (await text.boundingBox())!;
await page.mouse.click(cell.x + cell.width / 2, cell.y + cell.height / 2);
await expect(page).toHaveURL(new RegExp(`#/stat-card-linked/${target}$`));
}

await grid.getByRole("link", { name: "12 new this week" }).click();
await expect(page).toHaveURL(/#\/stat-card-linked\/new-accounts$/);
});
Loading