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
7 changes: 7 additions & 0 deletions .changeset/sheet-side-drawer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@codeui/solid": minor
"@codeui/styles": minor
"@codeui/inkstone": minor
---

Sheet: left and right sheets float 8px in from the edges and become a bottom sheet at 768px and below, where `draggable` shows the grip. A `mount` other than `document.body` makes the sheet and its scrim cover that element. The sheet slides with transitions (in 260ms on the new `--cui-motion-ease-drawer`, out 200ms), stays mounted through its exit, reverses when reopened mid-exit, and no longer leaves the page unclickable while it closes. A modal sheet without an overlay no longer blocks clicks on the page.
5 changes: 4 additions & 1 deletion .claude/skills/verify-codeui/features/overlays.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Overlays

Dialog and Popover open from a trigger, move focus inside, trap Tab while modal, close on Escape or the close button, and return focus to the trigger. Both render the same in dark and light themes. Sheet and CommandMenu arrive in later PRs; add them here when their stories land.
Dialog and Popover open from a trigger, move focus inside, trap Tab while modal, close on Escape or the close button, and return focus to the trigger. Both render the same in dark and light themes. Sheet follows the same focus rules; CommandMenu arrives in a later PR.

## Sub-features

Expand All @@ -21,6 +21,9 @@ Dialog and Popover open from a trigger, move focus inside, trap Tab while modal,
- `hovercard-touch` opens the card on a touch tap without following the link, places it on the right of the trigger by default, keeps the floating surface (dialog fill, shadow with the dark inset ring, radius 16, max width 320), closes on an outside press, and opens at once on a mouse click. Journey: `journeys/hovercard-touch.mjs` on `designsystem-hovercard--hover-card-story`.
- `hovercard-edge` flips the card to the left when there is no room on the right. Journey: `journeys/hovercard-edge.mjs` on `designsystem-hovercard--edge-placement`.
- `hovercard-list` renders `HoverCardList`: one 28px line per entry, 16px indent per depth, truncated titles, named state icons, capped at 24rem with its own scroll. Journey: `journeys/hovercard-list.mjs` on `designsystem-hovercard--task-list`.
- `sheet-side` a right sheet mounted in a content island: floats 8px in from the island's top, right and bottom; the scrim covers only the island; Enter opens it with `data-motion="none"` and focus inside; Escape and a scrim click close it and return focus to the opener; at 390×844 it becomes a full-width bottom sheet with the grip. Journey: `journeys/sheet-drawer.mjs` on `designsystem-sheet--drawer`.
- `sheet-swap` choosing another row, or Edit, swaps the open sheet's content: same element, `data-expanded` never removed. Journeys: `journeys/sheet-drawer.mjs` (Edit, modal) and `journeys/sheet-swap.mjs` on `designsystem-sheet--drawer-nonmodal` (row clicks).
- `sheet-motion` the slide itself. drive.mjs disables motion, so `node scripts/sheet-motion.mjs <url> designsystem-sheet--sides "Open (right)" [reduce]` samples the content and scrim with motion on: pointer enter 260ms transform on the drawer curve, exit 200ms ease-out and still mounted at 150ms, reopen mid-exit reverses, keyboard `data-motion="none"`, reduced motion opacity only.
- `popover-parts` composes `@codeui/solid/popover/parts` parts with title, description, arrow and close button.

## How to get to it (user POV)
Expand Down
121 changes: 121 additions & 0 deletions .claude/skills/verify-codeui/journeys/sheet-drawer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Drives designsystem-sheet--drawer (modal) like a keyboard user.
export default async ({ page, step, check, focus, axe }) => {
const dialog = () => page.getByRole("dialog");
const tabTo = async name => {
for (let i = 0; i < 30; i++) {
await page.keyboard.press("Tab");
if ((await focus()).name?.startsWith(name)) return;
}
throw new Error(`Tab never reached ${name}`);
};
const boxes = () =>
page.evaluate(() => {
const r = el => el && el.getBoundingClientRect().toJSON();
return {
main: r(document.querySelector("main")),
sheet: r(document.querySelector('[data-cui="sheet-content"]')),
overlay: r(document.querySelector('[data-cui="sheet-overlay"]')),
handleShown: (() => {
const h = document.querySelector('[data-cui="sheet-handle"]');
return !!h && getComputedStyle(h).display !== "none";
})(),
};
});

await step("closed", async () => {});
await check("closed: no dialog", async () => ({ pass: (await dialog().count()) === 0 }));

await step("open New automation with Enter", async () => {
await tabTo("New automation");
await page.keyboard.press("Enter");
await dialog().waitFor();
await page.waitForFunction(() => document.activeElement?.closest('[role="dialog"]'));
});
await check("open: named New automation, focus inside", async () => {
const f = await focus();
const name = await dialog().getAttribute("aria-labelledby").then(id => page.locator(`#${id}`).textContent());
return { pass: f.inDialog && name === "New automation", name, focus: f };
});
await check("open: keyboard open does not move", async () => ({
pass: (await dialog().getAttribute("data-motion")) === "none",
}));
await check("open: floats inside the island, inset 8px, scrim covers only the island", async () => {
const { main, sheet, overlay } = await boxes();
const pass =
Math.round(main.right - sheet.right) === 8 &&
Math.round(sheet.top - main.top) === 8 &&
Math.round(main.bottom - sheet.bottom) === 8 &&
Math.round(overlay.left) === Math.round(main.left) &&
Math.round(overlay.width) === Math.round(main.width);
return { pass, main, sheet, overlay };
});
await axe("open-new");

await step("Escape closes", async () => {
await page.keyboard.press("Escape");
await dialog().waitFor({ state: "detached" });
});
await page.waitForFunction(() => document.activeElement?.textContent === "New automation");
await check("closed: focus back on New automation", async () => {
const f = await focus();
return { pass: f.name === "New automation", focus: f };
});

await step("open a row with Enter", async () => {
await tabTo("Morning digest");
await page.keyboard.press("Enter");
await dialog().waitFor();
await page.evaluate(() => (window.__sheet = document.querySelector('[data-cui="sheet-content"]')));
});
await check("detail: title is the row", async () => ({
pass: (await page.locator('[data-cui="sheet-title"]').textContent()) === "Morning digest",
}));
await axe("detail");

await step("Edit swaps the content in place", async () => {
await tabTo("Edit");
await page.keyboard.press("Enter");
await page.locator('[data-cui="sheet-title"]', { hasText: "Edit automation" }).waitFor();
});
await check("swap: same sheet element, still open, no remount", async () => {
const same = await page.evaluate(
() => window.__sheet === document.querySelector('[data-cui="sheet-content"]') && window.__sheet.hasAttribute("data-expanded"),
);
return { pass: same };
});
await axe("form");

await step("scrim click closes", async () => {
const { main } = await boxes();
await page.mouse.click(main.left + 40, main.top + 200);
await dialog().waitFor({ state: "detached" });
});
await page.waitForFunction(() => document.activeElement?.hasAttribute("data-row"), null, { timeout: 3000 }).catch(() => {});
await check("scrim: closed and focus back on the row", async () => {
const f = await focus();
return { pass: (await dialog().count()) === 0 && f.name?.startsWith("Morning digest"), focus: f };
});

await step("phone: open becomes a bottom sheet", async () => {
await page.setViewportSize({ width: 390, height: 844 });
await page.locator("body").press("Escape");
await tabTo("New automation");
await page.keyboard.press("Enter");
await dialog().waitFor();
});
await check("phone: full width of the island, on its bottom edge, grip shown", async () => {
const { main, sheet, handleShown } = await boxes();
const pass =
Math.round(sheet.left) === Math.round(main.left) &&
Math.round(sheet.right) === Math.round(main.right) &&
Math.round(sheet.bottom) === Math.round(main.bottom) &&
sheet.top > main.top &&
handleShown;
return { pass, main, sheet, handleShown };
});
await axe("phone");
await step("phone: Escape closes", async () => {
await page.keyboard.press("Escape");
await dialog().waitFor({ state: "detached" });
});
};
35 changes: 35 additions & 0 deletions .claude/skills/verify-codeui/journeys/sheet-swap.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// designsystem-sheet--drawernonmodal: clicking another row swaps the open sheet.
export default async ({ page, step, check, focus, axe }) => {
const title = () => page.locator('[data-cui="sheet-title"]').textContent();
await step("click Morning digest", async () => {
await page.getByRole("button", { name: /^Morning digest/ }).click();
await page.getByRole("dialog").waitFor();
await page.evaluate(() => {
const sheet = document.querySelector('[data-cui="sheet-content"]');
window.__sheet = sheet;
window.__lostExpanded = false;
new MutationObserver(() => {
if (!sheet.hasAttribute("data-expanded")) window.__lostExpanded = true;
}).observe(sheet, { attributes: true, attributeFilter: ["data-expanded"] });
});
});
await check("detail open", async () => ({ pass: (await title()) === "Morning digest" }));
await step("click Issue triage while open", async () => {
await page.getByRole("button", { name: /^Issue triage/ }).click();
await page.locator('[data-cui="sheet-title"]', { hasText: "Issue triage" }).waitFor();
});
await check("swap: same element, never closed", async () => {
const r = await page.evaluate(() => ({
same: window.__sheet === document.querySelector('[data-cui="sheet-content"]'),
lost: window.__lostExpanded,
current: document.querySelector('[aria-current="true"]')?.textContent,
}));
return { pass: r.same && !r.lost && r.current?.startsWith("Issue triage"), ...r };
});
await axe("swapped");
await step("Escape closes", async () => {
await page.getByRole("dialog").focus();
await page.keyboard.press("Escape");
await page.getByRole("dialog").waitFor({ state: "detached" });
});
};
73 changes: 73 additions & 0 deletions .claude/skills/verify-codeui/scripts/sheet-motion.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Records what a Sheet animates with motion on (drive.mjs turns motion off).
// usage: node .claude/skills/verify-codeui/scripts/sheet-motion.mjs <baseUrl> <storyId> <openButtonName> [reduce]
import { launch } from "../../../../tools/baseline/browser.mjs";

const [base, story, buttonName, reduce] = process.argv.slice(2);
const browser = await launch();
const context = await browser.newContext({
viewport: { width: 1280, height: 900 },
reducedMotion: reduce ? "reduce" : "no-preference",
});
const page = await context.newPage();
await page.goto(`${base}/iframe.html?id=${story}&viewMode=story`, { waitUntil: "networkidle" });

const snapshot = () =>
page.evaluate(() => {
const pick = sel => {
const el = document.querySelector(sel);
if (!el) return null;
return {
motion: el.getAttribute("data-motion"),
anims: el.getAnimations().map(a => {
const t = a.effect.getTiming();
return {
type: a.constructor.name,
name: a.animationName ?? a.transitionProperty,
duration: t.duration,
easing: t.easing === "linear" ? getComputedStyle(el).transitionTimingFunction || getComputedStyle(el).animationTimingFunction : t.easing,
};
}),
transform: getComputedStyle(el).transform,
opacity: getComputedStyle(el).opacity,
};
};
return { content: pick('[data-cui="sheet-content"]'), overlay: pick('[data-cui="sheet-overlay"]') };
});

const result = {};
// Pointer open
await page.getByRole("button", { name: buttonName }).click();
await page.waitForTimeout(30);
result.pointerOpen = await snapshot();
await page.waitForTimeout(600);
// Pointer close via the close button
await page.locator('[data-cui="sheet-close-button"]').click();
await page.waitForTimeout(30);
result.pointerClose30ms = await snapshot();
await page.waitForTimeout(120);
result.pointerClose150ms = await snapshot();
await page.waitForTimeout(450);
result.after600ms = await snapshot();
// Interrupt: close, then reopen 80ms into the exit
await page.getByRole("button", { name: buttonName }).click();
await page.waitForTimeout(600);
await page.locator('[data-cui="sheet-close-button"]').click();
await page.waitForTimeout(80);
result.interruptMidExit = await snapshot();
await page.getByRole("button", { name: buttonName }).click({ force: true });
await page.waitForTimeout(20);
result.interruptReopened20ms = await snapshot();
await page.waitForTimeout(600);
result.interruptSettled = await snapshot();
await page.keyboard.press("Escape");
await page.waitForTimeout(600);
// Keyboard open
await page.getByRole("button", { name: buttonName }).focus();
await page.keyboard.press("Enter");
await page.waitForTimeout(30);
result.keyboardOpen = await snapshot();
await page.keyboard.press("Escape");
await page.waitForTimeout(30);
result.keyboardClose30ms = await snapshot();
console.log(JSON.stringify(result, null, 1));
await browser.close();
16 changes: 11 additions & 5 deletions apps/docs/content/docs/(kit)/components/sheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,33 @@ Use [Dialog](/docs/components/dialog) for a blocking decision. Use [Popover](/do

<SolidDemo name="sheet/sides" />

`side` accepts `left`, `right`, and `bottom`. Bottom is the default.
`side` accepts `left`, `right`, and `bottom`. Bottom is the default. A left or right sheet floats 8px in from the top, bottom and its edge, with every corner rounded, and is 24rem wide (set `--cui-sheet-width` on the content to change it). At 768px and below it becomes a bottom sheet.

### In a container

Pass `mount` an element other than `document.body`, and the sheet and its scrim cover that element instead of the viewport. Give the element `position: relative`. CodeLoom mounts its side sheet in the content island, so the sidebar stays uncovered and usable.

Change what the sheet shows while it stays open, and it swaps in place with no close and reopen. For a nonmodal sheet beside a list, keep a click on another row from dismissing it: call `event.preventDefault()` in `contentProps.onInteractOutside` when the target is a row.

<SolidDemo name="sheet/nonmodal" />

Modal sheets render a scrim and trap focus. `modal={false}` removes the scrim and leaves the page interactive.

<SolidDemo name="sheet/draggable" />

`draggable` adds a handle only to a bottom sheet. The placement union rejects draggable left and right sheets.
`draggable` adds a handle to a bottom sheet. A left or right sheet renders the handle only while it is a bottom sheet, at 768px and below.

<SolidDemo name="sheet/motion" />

`motion="auto"` slides on pointer open and close. Keyboard actions do not animate. Reduced motion replaces the slide with a fade. `motion="none"` disables presence animation.
`motion="auto"` slides on pointer open and close: in over 260ms on the drawer curve, out over 200ms ease-out. The slide is a CSS transition, so reopening a sheet mid-exit turns it around from where it is. Keyboard actions do not animate. Reduced motion replaces the slide with a fade. `motion="none"` disables presence animation.

A downward drag tracks the handle 1:1. Dragging above the open position applies rubber band resistance. A downward flick above 0.5 px/ms or a drag beyond 35% of the sheet height dismisses it. Short drags and `pointercancel` settle back open. A new grab can interrupt the settle. Reduced motion skips the settle animation.

Drag events belong to `Handle`, not `Body`. Scrollable body content scrolls without starting a dismiss gesture. The draggable demo includes a scroll region for this distinction.

## States

The live demo controls `open` with `onOpenChange`. Parts also support `defaultOpen` for uncontrolled state. Closed content unmounts after its exit animation unless Kobalte force mounting is enabled.
The live demo controls `open` with `onOpenChange`. Parts also support `defaultOpen` for uncontrolled state. Closed content stays mounted until its exit transition ends, then unmounts unless `forceMount` is set. During the exit the sheet is inert and the page under it takes clicks.

## Ready API

Expand Down Expand Up @@ -132,7 +138,7 @@ Kobalte Dialog.Overlay with scrim styles. Include it only for a modal sheet.

### `Portal`

Kobalte Dialog.Portal. `mount` selects the browser destination. It renders no wrapper.
Kobalte Dialog.Portal. `mount` selects the browser destination. It renders no wrapper. With a `mount` other than `document.body`, the overlay and the content get `data-contained` and cover that element.

<PropsTable name="SheetPortal" />

Expand Down
3 changes: 2 additions & 1 deletion apps/docs/content/docs/(kit)/foundations/tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Tokens"
description: "The --cui-* custom properties every kit style reads."
---

Every color, radius, space, size, shadow and motion value in the kit is a `--cui-*` CSS custom property. Kit components read only these properties, so changing one changes every component that uses it. The kit defines 142 of them.
Every color, radius, space, size, shadow and motion value in the kit is a `--cui-*` CSS custom property. Kit components read only these properties, so changing one changes every component that uses it. The kit defines 143 of them.

<SolidDemo name="tokens/overview" source="hidden" />

Expand Down Expand Up @@ -296,5 +296,6 @@ The kit does not load a font file. Without Inter, the stack falls back to the sy
| `motion.duration.slow` | `--cui-motion-duration-slow` | `260ms` |
| `motion.duration.rise` | `--cui-motion-duration-rise` | `400ms` |
| `motion.ease.out` | `--cui-motion-ease-out` | `cubic-bezier(0.23, 1, 0.32, 1)` |
| `motion.ease.drawer` | `--cui-motion-ease-drawer` | `cubic-bezier(0.32, 0.72, 0, 1)` |

[Motion](/docs/foundations/motion) explains when to use each duration.
Loading
Loading