diff --git a/r/card.json b/r/card.json index 3ab2f579..4d7cb82e 100644 --- a/r/card.json +++ b/r/card.json @@ -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" } ] } diff --git a/r/row-link.json b/r/row-link.json index 511e0222..a8e9c9e9 100644 --- a/r/row-link.json +++ b/r/row-link.json @@ -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" } ] } diff --git a/site/src/catalog.json b/site/src/catalog.json index cb603554..65040889 100644 --- a/site/src/catalog.json +++ b/site/src/catalog.json @@ -1884,6 +1884,10 @@ { "title": "Loading, error and attention", "module": "stat-card/states" + }, + { + "title": "Linked, framed and plain", + "module": "stat-card/linked" } ] }, diff --git a/site/src/examples/stat-card/linked.tsx b/site/src/examples/stat-card/linked.tsx new file mode 100644 index 00000000..fc0febfe --- /dev/null +++ b/site/src/examples/stat-card/linked.tsx @@ -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 ( + + + 12 new this week + + } + link={{ href: "#/stat-card-linked/accounts" }} + /> + } + link={{ href: "#/stat-card-linked/licenses" }} + /> + + } + link={{ href: "#/stat-card-linked/grace" }} + /> + + ); +} diff --git a/src/ui/row-link.module.css b/src/ui/row-link.module.css index d144ccc8..1439b4c8 100644 --- a/src/ui/row-link.module.css +++ b/src/ui/row-link.module.css @@ -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, diff --git a/visual/baselines/desktop/stat-card-linked--dark.png b/visual/baselines/desktop/stat-card-linked--dark.png new file mode 100644 index 00000000..2f5e9a58 Binary files /dev/null and b/visual/baselines/desktop/stat-card-linked--dark.png differ diff --git a/visual/baselines/desktop/stat-card-linked--light.png b/visual/baselines/desktop/stat-card-linked--light.png new file mode 100644 index 00000000..b7d0ffd3 Binary files /dev/null and b/visual/baselines/desktop/stat-card-linked--light.png differ diff --git a/visual/baselines/mobile/stat-card-linked--dark.png b/visual/baselines/mobile/stat-card-linked--dark.png new file mode 100644 index 00000000..34a759c1 Binary files /dev/null and b/visual/baselines/mobile/stat-card-linked--dark.png differ diff --git a/visual/baselines/mobile/stat-card-linked--light.png b/visual/baselines/mobile/stat-card-linked--light.png new file mode 100644 index 00000000..7ec9d4fc Binary files /dev/null and b/visual/baselines/mobile/stat-card-linked--light.png differ diff --git a/visual/stat-card-link.spec.ts b/visual/stat-card-link.spec.ts new file mode 100644 index 00000000..e712e4aa --- /dev/null +++ b/visual/stat-card-link.spec.ts @@ -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$/); +});