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
6 changes: 3 additions & 3 deletions r/cipher-base.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion r/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"path": "src/components/cipher/ui/panes.module.css",
"type": "registry:file",
"target": "src/components/cipher/ui/panes.module.css",
"content": ".root {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n}\n.columns {\n display: grid;\n flex: 1 1 auto;\n grid-template-columns: var(--cipher-size-pane-aside) minmax(0, 1fr);\n grid-template-rows: minmax(0, 1fr);\n min-height: 0;\n}\n.aside {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-content-group);\n min-width: 0;\n min-height: 0;\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n overflow-y: auto;\n overscroll-behavior: contain;\n overflow-wrap: anywhere;\n scroll-padding-block: var(--cipher-focus-clearance);\n border-inline-end: var(--cipher-size-control-border) solid var(--cipher-line-soft);\n}\n.aside :global([data-slot=\"data-list\"]) > * {\n flex-direction: column;\n align-items: flex-start;\n gap: var(--cipher-space-2);\n}\n.aside :global([data-slot=\"data-list\"][data-density=\"compact\"]) > * {\n grid-template-columns: minmax(0, 1fr);\n}\n.aside :global([data-slot=\"data-list\"]) dt {\n max-width: none;\n}\n.aside :global([data-slot=\"data-list\"]) dd {\n text-align: start;\n}\n.identity {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-8);\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.identityText {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-4);\n min-width: 0;\n}\n.badges {\n display: flex;\n flex-wrap: wrap;\n gap: var(--cipher-space-6);\n min-width: 0;\n}\n.main {\n --cipher-size-measure-field: 100%;\n display: flex;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n}\n.root[data-narrow] > .columns {\n display: flex;\n flex-direction: column;\n}\n.root[data-narrow] > .columns > .identity {\n flex: 0 1 auto;\n max-height: 40%;\n overflow-y: auto;\n overscroll-behavior: contain;\n flex-direction: row;\n align-items: flex-start;\n gap: var(--cipher-space-12);\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n padding-inline-end: var(--cipher-pane-head-end, var(--cipher-pane-pad, var(--cipher-space-overlay-inset)));\n border-bottom: var(--cipher-size-control-border) solid var(--cipher-line-soft);\n}\n.root[data-narrow] > .columns > .main {\n flex: 1 1 auto;\n}\n.page {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: var(--cipher-space-content-group);\n min-height: 0;\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n overflow-y: auto;\n overscroll-behavior: contain;\n overflow-wrap: anywhere;\n}\n.tabs {\n flex: none;\n padding-inline: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n}\n.scroll {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n}\n.hidden {\n display: none;\n}\n"
"content": ".root {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n}\n.columns {\n display: grid;\n flex: 1 1 auto;\n grid-template-columns: var(--cipher-size-pane-aside) minmax(0, 1fr);\n grid-template-rows: minmax(0, 1fr);\n min-height: 0;\n}\n.aside {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-content-group);\n min-width: 0;\n min-height: 0;\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n overflow-y: auto;\n overscroll-behavior: contain;\n overflow-wrap: anywhere;\n scroll-padding-block: var(--cipher-focus-clearance);\n border-inline-end: var(--cipher-size-control-border) solid var(--cipher-line-soft);\n}\n.aside :global([data-slot=\"data-list\"]) > * {\n flex-direction: column;\n align-items: stretch;\n gap: var(--cipher-space-2);\n}\n.aside :global([data-slot=\"data-list\"][data-density=\"compact\"]) > * {\n grid-template-columns: minmax(0, 1fr);\n}\n.aside :global([data-slot=\"data-list\"]) dt {\n max-width: none;\n}\n.aside :global([data-slot=\"data-list\"]) dd {\n text-align: start;\n}\n.identity {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-8);\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.identityText {\n display: flex;\n flex-direction: column;\n gap: var(--cipher-space-4);\n min-width: 0;\n}\n.badges {\n display: flex;\n flex-wrap: wrap;\n gap: var(--cipher-space-6);\n min-width: 0;\n}\n.main {\n --cipher-size-measure-field: 100%;\n display: flex;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n}\n.root[data-narrow] > .columns {\n display: flex;\n flex-direction: column;\n}\n.root[data-narrow] > .columns > .identity {\n flex: none;\n max-height: 40%;\n overflow-y: auto;\n overscroll-behavior: contain;\n flex-direction: row;\n align-items: flex-start;\n gap: var(--cipher-space-12);\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n padding-inline-end: var(\n --cipher-pane-head-end,\n var(--cipher-pane-pad, var(--cipher-space-overlay-inset))\n );\n border-bottom: var(--cipher-size-control-border) solid var(--cipher-line-soft);\n}\n.root[data-narrow] > .columns > .main {\n flex: 1 1 auto;\n}\n.page {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: var(--cipher-space-content-group);\n min-height: 0;\n padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n overflow-y: auto;\n overscroll-behavior: contain;\n overflow-wrap: anywhere;\n}\n.tabs {\n flex: none;\n padding-inline: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));\n}\n.scroll {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n}\n.hidden {\n display: none;\n}\n"
},
{
"path": "src/components/cipher/ui/text.module.css",
Expand Down
2 changes: 1 addition & 1 deletion r/sheet.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions site/src/examples/sheet/two-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Input } from "@infisical/cipher/ui/input";
import { Media } from "@infisical/cipher/ui/item";
import { Stack } from "@infisical/cipher/ui/layout";
import { DataList } from "@infisical/cipher/ui/list";
import { MiddleTruncate } from "@infisical/cipher/ui/middle-truncate";
import * as UI from "@infisical/cipher/ui/sheet";
import { Switch } from "@infisical/cipher/ui/switch";
import { Tabs, TabsList, TabsTrigger } from "@infisical/cipher/ui/tabs";
Expand Down Expand Up @@ -60,8 +61,13 @@ const AccountSheet = ({
variant="props"
items={[
["Description", "Writer endpoint for the orders service"],
["Template", "production-postgres"],
["Host", mono(account.host)],
[
"Template",
<Button key="template" variant="link" size="sm" asChild>
<a href="#/components/sheet">production-postgres</a>
</Button>
],
["Host", <MiddleTruncate key="host" mono text={account.host} />],
["Port", mono(account.port)],
["Database", mono(account.database)],
["SSL", ssl ? "Enabled" : "Disabled"],
Expand Down
14 changes: 9 additions & 5 deletions src/lib/initial-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ const candidate = (element: HTMLElement) =>
/**
* An onOpenAutoFocus handler for overlays: focus lands on the first form control, else the first
* tabbable element that is not marked with skipAutoFocus, so a help button beside the first label
* never takes focus and opens its tooltip.
* never takes focus and opens its tooltip. With prefer, the first control inside that element wins,
* such as a two-pane sheet's main pane over its aside.
*/
export function focusFirstControl(event: Event) {
export function focusFirstControl(event: Event, prefer?: string) {
if (event.defaultPrevented || !(event.target instanceof HTMLElement)) return;
const container = event.target;
const find = (selector: string) =>
const root = event.target;
const preferred = prefer ? root.querySelector<HTMLElement>(prefer) : null;
const find = (container: HTMLElement, selector: string) =>
Array.from(container.querySelectorAll<HTMLElement>(selector)).find(candidate);
const target = find(formControlSelector) ?? find(tabbableSelector);
const first = (container: HTMLElement) =>
find(container, formControlSelector) ?? find(container, tabbableSelector);
const target = (preferred && first(preferred)) ?? first(root);
if (!target) return;
event.preventDefault();
target.focus({ preventScroll: true });
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.generated.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
--cipher-size-measure-prose: 65ch;
--cipher-size-sidecar: 384px;
--cipher-size-pane-aside: 320px;
--cipher-size-pane-collapse: 720px;
--cipher-size-pane-collapse: 880px;
--cipher-size-sidecar-collapse: 896px;
--cipher-size-data-list-term: 128px;
--cipher-size-data-list-row: var(--cipher-size-control-sm);
Expand Down
4 changes: 2 additions & 2 deletions src/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,8 @@
},
{
"name": "size-pane-collapse",
"value": "720px",
"usage": "Panes width below which the aside stops sitting beside the main pane. Its identity (media, title, description and badges) becomes a fixed header with tabs on its bottom rule: Details first, then the header's own tabs, or the main pane's label when there are none. It opens on the main pane's tab. Measured on the Panes itself, so a 672px sheet or a phone collapses and a 1024px sheet splits."
"value": "880px",
"usage": "Panes width below which the aside stops sitting beside the main pane: size-pane-aside plus a 560px main pane, so a table beside the aside keeps its columns. Its identity (media, title, description and badges) becomes a fixed header with tabs on its bottom rule: Details first, then the header's own tabs, or the main pane's label when there are none. It opens on the main pane's tab. Measured on the Panes itself, so a 768px sheet (an xl sheet on a 1024px viewport) or a phone collapses and a 960px sheet splits."
},
{
"name": "size-sidecar-collapse",
Expand Down
9 changes: 6 additions & 3 deletions src/ui/panes.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
.aside :global([data-slot="data-list"]) > * {
flex-direction: column;
align-items: flex-start;
align-items: stretch;
gap: var(--cipher-space-2);
}
.aside :global([data-slot="data-list"][data-density="compact"]) > * {
Expand Down Expand Up @@ -70,15 +70,18 @@
flex-direction: column;
}
.root[data-narrow] > .columns > .identity {
flex: 0 1 auto;
flex: none;
max-height: 40%;
overflow-y: auto;
overscroll-behavior: contain;
flex-direction: row;
align-items: flex-start;
gap: var(--cipher-space-12);
padding: var(--cipher-pane-pad, var(--cipher-space-overlay-inset));
padding-inline-end: var(--cipher-pane-head-end, var(--cipher-pane-pad, var(--cipher-space-overlay-inset)));
padding-inline-end: var(
--cipher-pane-head-end,
var(--cipher-pane-pad, var(--cipher-space-overlay-inset))
);
border-bottom: var(--cipher-size-control-border) solid var(--cipher-line-soft);
}
.root[data-narrow] > .columns > .main {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function SheetContent({
aria-busy={blocked || undefined}
onOpenAutoFocus={(event) => {
onOpenAutoFocus?.(event);
focusFirstControl(event);
focusFirstControl(event, aside ? '[data-slot="sheet-main"]' : undefined);
}}
{...props}
{...(viewLabels?.title ? { "aria-labelledby": viewLabels.title } : {})}
Expand Down
Loading