diff --git a/.changeset/design-guide-from-sessions.md b/.changeset/design-guide-from-sessions.md new file mode 100644 index 00000000..a479c4bb --- /dev/null +++ b/.changeset/design-guide-from-sessions.md @@ -0,0 +1,5 @@ +--- +"@codeui/kit": patch +--- + +Extend the Inkstone guide with rules from CodeLoom reviews: a 6px gap between islands, hover cards instead of `title`, rows in a list, background work, technical values, avatars, forms, and loading without an empty flash. diff --git a/.changeset/dropdown-menu-spacing.md b/.changeset/dropdown-menu-spacing.md new file mode 100644 index 00000000..ce8a51cc --- /dev/null +++ b/.changeset/dropdown-menu-spacing.md @@ -0,0 +1,5 @@ +--- +"@codeui/styles": patch +--- + +Draw dropdown separators as a single line aligned with the item labels. Reduce row padding and the gaps between items and before shortcuts. diff --git a/.changeset/hover-card-resizable.md b/.changeset/hover-card-resizable.md new file mode 100644 index 00000000..9e6fef7d --- /dev/null +++ b/.changeset/hover-card-resizable.md @@ -0,0 +1,9 @@ +--- +"@codeui/kit": minor +"@codeui/styles": minor +--- + +Add HoverCard (`@codeui/kit/hover-card`) and Resizable (`@codeui/kit/resizable`), with their styles in `@codeui/styles/hovercard` and `@codeui/styles/resizable`. + +- `HoverCard`, `HoverCardTrigger` and `HoverCardContent` show supplementary details on hover or keyboard focus. The card opens after 500ms, closes 150ms after the pointer leaves, closes on Escape, uses the Popover surface with a 320px max width, and does not animate when opened from the keyboard. +- `Resizable`, `ResizablePanel` and `ResizableHandle` split a row or a column into panels sized by fractions or `"240px"` strings, with `minSize`, `maxSize` and `collapsible`. The handle is an 8px hit area with a 1px line that changes colour on hover, drag and focus, and it moves with the arrow keys, Home and End. diff --git a/.changeset/hover-card-shared-surface.md b/.changeset/hover-card-shared-surface.md new file mode 100644 index 00000000..11f39289 --- /dev/null +++ b/.changeset/hover-card-shared-surface.md @@ -0,0 +1,14 @@ +--- +"@codeui/kit": minor +"@codeui/styles": minor +--- + +Hover cards share one card and move it between triggers. + +- All the hover cards of a page share one card. Moving the pointer or keyboard focus to another trigger while a card is open moves that card at once: it slides to the new trigger, resizes to the new content, and fades the new content in. For 400ms after a card closes, the next one opens at once and without the pop. The move lasts 200ms (`--cui-motion-duration-panel`) with the kit's ease-out. While the pointer is on its way to the open card, another trigger it crosses takes the card only after 150ms of rest. A move from the keyboard swaps the content in place with no motion; with reduced motion only the new content fades in. +- `HoverCardGroup` gives the cards inside it a card of their own, with `skipDelayDuration` for the skip window. `shared={false}` gives one `HoverCard` its own surface; `forceMount` implies it. +- `HoverCardContent` is no longer polymorphic. Its props (`class`, `classes`, `style`, `ref`, `mount`, dismiss handlers, and any other attribute or event handler) go on the shared card while that card shows it, and come off when another card takes it over. +- `HoverCard` drops the Kobalte root options it never used (`id`). The trigger renders without a Kobalte popover anchor and still sets `data-expanded` and `data-closed`. +- Overlays opened by hover tell pointer from keyboard more reliably: the input tracker also records `pointerover`, which the browser fires before the `pointermove` that crosses into an element. +- A hover card opened from inside another card's content gets a surface of its own. The outer card stays open while the pointer is on the inner card and until it closes, and a press on the inner card does not close it. +- An `a` trigger (alone or `as={Link}`) has a dotted underline in the hint tone (`--cui-hovercard-trigger-decoration-color`) that takes the text colour on hover and while the card is open. diff --git a/.changeset/hovercard-controlled-closed.md b/.changeset/hovercard-controlled-closed.md new file mode 100644 index 00000000..f063d267 --- /dev/null +++ b/.changeset/hovercard-controlled-closed.md @@ -0,0 +1,5 @@ +--- +"@codeui/kit": patch +--- + +HoverCard no longer opens an empty card. With `open={false}` a second hover, focus or click left the shared surface open with nothing in it, and a card without `HoverCardContent` opened an empty surface too. Both now stay closed. diff --git a/.changeset/kit-avatar-hovercard.md b/.changeset/kit-avatar-hovercard.md new file mode 100644 index 00000000..bbe77593 --- /dev/null +++ b/.changeset/kit-avatar-hovercard.md @@ -0,0 +1,10 @@ +--- +"@codeui/kit": minor +"@codeui/styles": minor +--- + +Add Avatar (`@codeui/kit/avatar`, styles in `@codeui/styles/avatar`) and bring HoverCard in line with the Inkstone guide. + +- `Avatar` shows a person's picture, or one or two initials on a fill whose hue comes from a stable `identifier` (never the name). It has a full radius with a neutral 20% ring, sizes `xs` to `lg` from the shared control scale and density, the name as its accessible name and in the kit Tooltip, and a dashed `unassigned` state. `avatarHue` and `avatarInitials` are exported. +- `HoverCard` opens at once on click as well as on hover and focus. On a touch screen the first tap on a link opens the card instead of following it. The default placement is `right-start` (it was `bottom`), and the card wraps long words. +- `HoverCardList` and `HoverCardItem` render a list inside a hover card: one line per entry with a state icon, an identifier and a truncated title, nesting by `depth`, capped at 24rem with its own scroll. diff --git a/.changeset/solid-2.md b/.changeset/solid-2.md new file mode 100644 index 00000000..70691cb9 --- /dev/null +++ b/.changeset/solid-2.md @@ -0,0 +1,8 @@ +--- +"@codeui/kit": minor +"@codeui/styles": patch +--- + +Require Solid 2 and `@solidjs/web` for the component kit. Upgrade the application to Solid 2 and switch to `@solidjs/vite-plugin` before installing this release. The kit uses Kobalte 2.0.0. + +Keep the background from receiving pointer input while a hydrated modal is open. diff --git a/.changeset/tooltip-provider-defaults.md b/.changeset/tooltip-provider-defaults.md new file mode 100644 index 00000000..9e2cf40f --- /dev/null +++ b/.changeset/tooltip-provider-defaults.md @@ -0,0 +1,7 @@ +--- +"@codeui/kit": minor +--- + +Add `TooltipProvider` (`Provider` in `@codeui/kit/tooltip/parts`) to set `openDelay`, `closeDelay`, `skipDelayDuration`, `gutter`, `shift` and `variant` for every tooltip below it. A prop on one tooltip still wins. + +Tooltips are calmer by default: they open 700ms after hover (was 200ms), the next one opens at once for 400ms after one closes (was 300ms), and they use the neutral `secondary` fill (was the brand `primary`). Pass `openDelay`, `skipDelayDuration` or `variant` to keep the old behaviour. diff --git a/.claude/skills/verify-codeui/features/README.md b/.claude/skills/verify-codeui/features/README.md index 9dea01d2..5bb08075 100644 --- a/.claude/skills/verify-codeui/features/README.md +++ b/.claude/skills/verify-codeui/features/README.md @@ -31,9 +31,10 @@ Each feature file has an H1, one paragraph of user-visible behavior, and exactly ## Features -- [Overlays](./overlays.md): Dialog and Popover open, focus, dismiss and focus return. Proven journey: `journeys/dialog-keyboard.mjs`. +- [Overlays](./overlays.md): Dialog, Popover and HoverCard open, focus, dismiss and focus return; HoverCard tap, placement and list. Proven journeys: `journeys/dialog-keyboard.mjs`, `journeys/hovercard-touch.mjs`, `journeys/hovercard-list.mjs`, `journeys/hovercard-edge.mjs`. +- [Avatar](./avatar.md): initials contrast on every hue, hue from the id, ring, sizes per density, unassigned, tooltip. Journeys: `journeys/avatar.mjs`, `journeys/avatar-sizes.mjs`. - [Form fields](./form-fields.md): TextField, Select, Listbox, NumberField, SegmentedControl, RadioList, Checkbox input by keyboard, validation states. - [Theming](./theming.md): `data-cui-theme` modes, `--cui-*` tokens, and the `@layer cui` override contract. - [Settings rows](./settings.md): SettingsRow and SettingsGroup labelling, CodeImage parity and phone stacking. Journey: `journeys/settings-row.mjs`. - [Feedback](./feedback.md): Tooltip on hover and focus. Keyboard journey: `journeys/tooltip-keyboard.mjs`. -- [Sidebar and settings controls](./controls.md): Accordion first click, Switch pointer vs keyboard focus, OptionCard keyboard. Journeys: `journeys/accordion-first-click.mjs`, `journeys/switch-focus.mjs`, `journeys/option-card-keyboard.mjs`. +- [Sidebar and settings controls](./controls.md): Accordion first click, Switch pointer vs keyboard focus, OptionCard keyboard. Resizable handle keyboard. Journeys: `journeys/accordion-first-click.mjs`, `journeys/resizable-keyboard.mjs`, `journeys/switch-focus.mjs`, `journeys/option-card-keyboard.mjs`. diff --git a/.claude/skills/verify-codeui/features/avatar.md b/.claude/skills/verify-codeui/features/avatar.md new file mode 100644 index 00000000..897553a1 --- /dev/null +++ b/.claude/skills/verify-codeui/features/avatar.md @@ -0,0 +1,29 @@ +# Avatar + +A person shows as a circle: their picture, or one or two initials on a hue derived from a stable id. The name is the accessible name (`role="img"`) and shows in the kit Tooltip on hover. Sizes follow the shared control scale and density; an unassigned owner is a dashed empty circle. + +## Sub-features + +- `avatar-initials`: initials reach 4.5:1 against the fill on every hue in both themes; hues differ by id, and the same name with different ids gets different hues; neutral fill without an id. +- `avatar-ring`: full radius and a 1px inset ring at 20% of `--cui-text-default` (§2.5 neutral, 16–35% alpha). +- `avatar-sizes`: `xs`, `sm`, `md`, `lg` equal `--cui-control-height-*` at compact, comfortable and touch density. +- `avatar-unassigned`: dashed border in `--cui-text-muted`, no fill, no children, named "Unassigned". +- `avatar-picture`: the picture covers the circle; a failed picture falls back to initials (`designsystem-avatar--states`). +- `avatar-tooltip`: hovering shows the name in `[data-cui=tooltip-content]`. + +## How to get to it (user POV) + +- `designsystem-avatar--initials`: eight people, three "Sam Lee" with different ids, one guest without an id. +- `designsystem-avatar--sizes`: every size at compact, comfortable and touch density, with initials, picture and unassigned. +- `designsystem-avatar--states`: picture, failed picture, unassigned. + +## Driving it with drive.mjs + +- `node .claude/skills/verify-codeui/scripts/drive.mjs designsystem-avatar--initials --journey .claude/skills/verify-codeui/journeys/avatar.mjs` checks contrast per avatar by painting the computed fill into a canvas (Chrome reports OKLCH), hue difference, the ring alpha, and the tooltip on hover. +- `node .claude/skills/verify-codeui/scripts/drive.mjs designsystem-avatar--sizes --journey .claude/skills/verify-codeui/journeys/avatar-sizes.mjs` checks heights against the size table, the unassigned border, and that the picture covers the circle. + +## Gotchas + +- `getComputedStyle().backgroundColor` returns `oklch(...)`; convert through a canvas before computing contrast. +- The avatar is not focusable, so its tooltip opens on hover only. Keyboard users get the name from the accessible name. +- The failed-picture state needs a request that 404s; the static Storybook server answers `/missing-avatar.png` with 404. diff --git a/.claude/skills/verify-codeui/features/controls.md b/.claude/skills/verify-codeui/features/controls.md index 81a90b14..0204d5d6 100644 --- a/.claude/skills/verify-codeui/features/controls.md +++ b/.claude/skills/verify-codeui/features/controls.md @@ -9,6 +9,7 @@ The controls CodeImage's sidebar and Settings dialog are built from: the accordi - `switch-pointer` toggles on click with no focus ring. - `switch-keyboard` toggles with Space and shows the 2px ring; Tab focus shows it too. - `option-card-keyboard` enters the group with Tab, selects with arrows, draws one ring outside the focused card and the inset accent ring on the selected one. +- `resizable-keyboard` focuses the `separator` handle with Tab, moves it with the arrow keys and stops at the panel's `minSize`/`maxSize` (Home 200px, End 360px). Journey: `journeys/resizable-keyboard.mjs` on `designsystem-resizable--sidebar`; `--vertical` and `--collapsible` render-only. ## How to get to it (user POV) diff --git a/.claude/skills/verify-codeui/features/overlays.md b/.claude/skills/verify-codeui/features/overlays.md index 0cf6b2cc..eaf2c45d 100644 --- a/.claude/skills/verify-codeui/features/overlays.md +++ b/.claude/skills/verify-codeui/features/overlays.md @@ -17,6 +17,10 @@ Dialog and Popover open from a trigger, move focus inside, trap Tab while modal, - `popover-dismiss` closes on Escape and returns focus to the trigger. - `popover-pop` opens with `data-motion="none"` from the keyboard and pops from the trigger side with a pointer; surface `--cui-surface-dialog`, radius 18, 14px / 1.3 text. Journey: `journeys/popover-pop.mjs` on `designsystem-popover--popover-story`. - `menu-pop` the same for DropdownMenu, with 36px rows at 14px. Journey: `journeys/menu-pop.mjs` on `designsystem-dropdownmenu--dropdown-menu-story`. +- `hovercard-open` opens `[data-cui=hovercard-content]` on trigger focus (no motion, focus stays on the trigger) and on a resting pointer; Escape and moving away close it; surface `--cui-surface-dialog`, radius 16, max width 320. Journey: `journeys/hovercard-open.mjs` on `designsystem-hovercard--hover-card-story`. +- `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`. - `popover-parts` composes `@codeui/kit/popover/parts` parts with title, description, arrow and close button. ## How to get to it (user POV) diff --git a/.claude/skills/verify-codeui/journeys/avatar-sizes.mjs b/.claude/skills/verify-codeui/journeys/avatar-sizes.mjs new file mode 100644 index 00000000..b9027af8 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/avatar-sizes.mjs @@ -0,0 +1,57 @@ +// Avatar sizes follow the shared control height scale and density; unassigned is a dashed empty circle. +export default async ({ page, check }) => { + await check("sizes match the control scale per density", () => + page.locator("[data-cui-density]").evaluateAll(groups => + (() => { + const expected = { + compact: [24, 32, 38, 46], + comfortable: [28, 36, 44, 52], + touch: [32, 40, 50, 58], + }; + const actual = Object.fromEntries( + groups.map(g => [ + g.getAttribute("data-cui-density"), + [...g.querySelectorAll("[data-cui=avatar]:not([data-unassigned])")] + .filter((_, i) => i % 2 === 0) + .map(a => a.getBoundingClientRect().height), + ]), + ); + return { + pass: JSON.stringify(actual) === JSON.stringify(expected), + actual, + expected, + }; + })(), + ), + ); + await check("unassigned is a dashed empty circle in secondary text colour", () => + page + .locator("[data-cui=avatar][data-unassigned]") + .first() + .evaluate(a => { + const c = getComputedStyle(a); + return { + pass: + c.borderTopStyle === "dashed" && + a.childElementCount === 0 && + c.backgroundColor === "rgba(0, 0, 0, 0)" && + a.getAttribute("aria-label") === "Unassigned", + border: c.borderTopStyle, + color: c.borderTopColor, + }; + }), + ); + await check("the picture covers the circle and keeps the ring", () => + page + .locator("[data-cui=avatar-image]") + .first() + .evaluate(img => ({ + pass: + img.complete && + img.naturalWidth > 0 && + img.getBoundingClientRect().width === + img.parentElement.getBoundingClientRect().width, + natural: img.naturalWidth, + })), + ); +}; diff --git a/.claude/skills/verify-codeui/journeys/avatar.mjs b/.claude/skills/verify-codeui/journeys/avatar.mjs new file mode 100644 index 00000000..d741fb1d --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/avatar.mjs @@ -0,0 +1,81 @@ +// Avatar: initials reach 4.5:1 on their hue in both themes, the ring is a neutral +// 16-35% line, sizes follow the control scale, hover shows the name in the kit Tooltip. +export default async ({ page, step, check, axe }) => { + const contrast = () => + page.locator("[data-cui=avatar]").evaluateAll(avatars => { + const canvas = document.createElement("canvas"); + canvas.width = canvas.height = 1; + const ctx = canvas.getContext("2d", { willReadFrequently: true }); + const rgb = color => { + ctx.clearRect(0, 0, 1, 1); + ctx.fillStyle = color; + ctx.fillRect(0, 0, 1, 1); + return [...ctx.getImageData(0, 0, 1, 1).data].slice(0, 3); + }; + const lum = ([r, g, b]) => + [r, g, b] + .map(v => v / 255) + .map(v => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4)) + .reduce((sum, v, i) => sum + v * [0.2126, 0.7152, 0.0722][i], 0); + const ratio = (a, b) => { + const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x); + return (hi + 0.05) / (lo + 0.05); + }; + return avatars + .filter( + a => + a.querySelector("[data-cui=avatar-fallback]") && + !a.hasAttribute("data-unassigned"), + ) + .map(a => { + const c = getComputedStyle(a); + return { + name: a.getAttribute("aria-label"), + ratio: Math.round(ratio(rgb(c.backgroundColor), rgb(c.color)) * 100) / 100, + ring: getComputedStyle(a, "::after").boxShadow, + radius: c.borderRadius, + }; + }); + }); + const rows = await contrast(); + await check("initials reach 4.5:1 on every hue", () => ({ + pass: rows.length > 0 && rows.every(r => r.ratio >= 4.5), + min: Math.min(...rows.map(r => r.ratio)), + rows, + })); + await check("hues differ by id, and the same name with different ids differs", () => + page.locator("[data-cui=avatar]").evaluateAll(avatars => { + const fills = avatars.map(a => getComputedStyle(a).backgroundColor); + const sam = avatars + .filter(a => a.getAttribute("aria-label") === "Sam Lee") + .map(a => getComputedStyle(a).backgroundColor); + return { + pass: new Set(fills.slice(0, 8)).size === 8 && new Set(sam).size === 3, + sam, + }; + }), + ); + await check("full radius and a neutral ring at 20% alpha", () => { + const ring = rows[0].ring; + const alpha = Number(/(?:\/\s*|,\s*)([\d.]+)\)/.exec(ring)?.[1]); + return { + pass: + rows.every(r => r.radius === "9999px" || parseFloat(r.radius) >= 9999) && + /inset/.test(ring) && + alpha >= 0.16 && + alpha <= 0.35, + ring, + alpha, + radius: rows[0].radius, + }; + }); + await step("Hover Ada Lovelace", async () => { + await page.getByRole("img", { name: "Ada Lovelace" }).hover(); + await page.locator("[data-cui=tooltip-content]").waitFor({ timeout: 2000 }); + }); + await check("the tooltip shows the name", async () => { + const text = await page.locator("[data-cui=tooltip-content]").innerText(); + return { pass: text.trim() === "Ada Lovelace", text }; + }); + await axe("tooltip"); +}; diff --git a/.claude/skills/verify-codeui/journeys/hovercard-edge.mjs b/.claude/skills/verify-codeui/journeys/hovercard-edge.mjs new file mode 100644 index 00000000..d3544c38 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/hovercard-edge.mjs @@ -0,0 +1,14 @@ +// With no room on the right, the card flips to the left of the trigger. +export default async ({ page, step, check }) => { + const content = page.locator("[data-cui=hovercard-content]"); + const trigger = page.locator("[data-cui=hovercard-trigger]"); + await step("Tab to the trigger", async () => { + await page.keyboard.press("Tab"); + await content.waitFor({ timeout: 2000 }); + }); + await check("the card sits on the left of the trigger", async () => { + const t = await trigger.boundingBox(); + const c = await content.boundingBox(); + return { pass: c.x + c.width <= t.x, cardRight: c.x + c.width, triggerLeft: t.x }; + }); +}; diff --git a/.claude/skills/verify-codeui/journeys/hovercard-list.mjs b/.claude/skills/verify-codeui/journeys/hovercard-list.mjs new file mode 100644 index 00000000..49020965 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/hovercard-list.mjs @@ -0,0 +1,74 @@ +// A list in a hover card: one line per entry, nesting by indent, truncated titles, +// capped near 24rem with its own scroll. +export default async ({ page, step, check, axe }) => { + const content = page.locator("[data-cui=hovercard-content]"); + await step("Tab to the trigger", async () => { + await page.keyboard.press("Tab"); + await content.waitFor({ timeout: 2000 }); + }); + await check("the list caps at 24rem and scrolls on its own", () => + page.locator("[data-cui=hovercard-list]").evaluate(el => ({ + pass: + el.clientHeight <= 384 && + el.clientHeight > 300 && + el.scrollHeight > el.clientHeight && + getComputedStyle(el).overflowY === "auto", + clientHeight: el.clientHeight, + scrollHeight: el.scrollHeight, + })), + ); + await check("every entry is one line: icon, identifier, truncated title", () => + page.locator("[data-cui=hovercard-item]").evaluateAll(items => { + const heights = [ + ...new Set(items.map(item => Math.round(item.getBoundingClientRect().height))), + ]; + const title = items[2].querySelector("[data-cui=hovercard-item-title]"); + return { + pass: + heights.length === 1 && + heights[0] <= 32 && + title.scrollWidth > title.clientWidth && + getComputedStyle(title).textOverflow === "ellipsis" && + items.every( + item => + item.querySelector("[data-cui=hovercard-item-icon]") && + item.querySelector("[data-cui=hovercard-item-id]"), + ), + heights, + truncated: title.scrollWidth > title.clientWidth, + }; + }), + ); + await check("nesting is shown by indent, 16px per level", () => + page.locator("[data-cui=hovercard-item]").evaluateAll(items => { + const left = i => + items[i].querySelector("[data-cui=hovercard-item-icon]").getBoundingClientRect() + .left; + return { + pass: left(1) - left(0) === 16 && left(3) - left(0) === 32, + d1: left(1) - left(0), + d2: left(3) - left(0), + }; + }), + ); + await check("state icons are named", async () => { + const names = await page.getByRole("img", { name: "Running" }).count(); + return { pass: names > 0, running: names }; + }); + await step("Scroll the list to the end", async () => { + await page + .locator("[data-cui=hovercard-list]") + .evaluate(el => el.scrollTo(0, el.scrollHeight)); + }); + await check( + "the card stays open and the same size while the list scrolls", + async () => { + const box = await content.boundingBox(); + return { + pass: (await content.count()) === 1 && box.height < 480, + height: box.height, + }; + }, + ); + await axe("open"); +}; diff --git a/.claude/skills/verify-codeui/journeys/hovercard-open.mjs b/.claude/skills/verify-codeui/journeys/hovercard-open.mjs new file mode 100644 index 00000000..7e3c3447 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/hovercard-open.mjs @@ -0,0 +1,59 @@ +// HoverCard: keyboard focus opens it in place (data-motion=none) and Escape closes it with +// focus kept on the trigger; a resting pointer opens it, and moving away closes it. +export default async ({ page, step, check, focus, axe, theme }) => { + const content = page.locator("[data-cui=hovercard-content]"); + const trigger = page.locator("[data-cui=hovercard-trigger]"); + const surface = () => + content.evaluate(el => { + const c = getComputedStyle(el); + return { + motion: el.getAttribute("data-motion"), + bg: c.backgroundColor, + radius: c.borderRadius, + maxWidth: c.maxWidth, + origin: c.getPropertyValue("--cui-popper-content-transform-origin").trim(), + }; + }); + await step("Tab to the trigger", async () => { + await page.keyboard.press("Tab"); + await content.waitFor({ timeout: 2000 }); + }); + const kbd = await surface(); + await check("focus opens the card without motion, focus stays on the trigger", async () => ({ + pass: kbd.motion === "none" && (await focus()).dataCui === "hovercard-trigger", + ...kbd, + })); + await check("Popover surface: dialog fill, radius 16, max width 320, origin at the trigger side", () => ({ + pass: + kbd.bg === (theme === "dark" ? "rgb(37, 37, 37)" : "rgb(255, 255, 255)") && + kbd.radius === "16px" && + kbd.maxWidth === "320px" && + kbd.origin === "left top", + ...kbd, + })); + await axe("open"); + await step("Press Escape", async () => { + await page.keyboard.press("Escape"); + await content.waitFor({ state: "detached", timeout: 2000 }); + }); + await check("Escape closes the card and focus stays on the trigger", async () => ({ + pass: (await content.count()) === 0 && (await focus()).dataCui === "hovercard-trigger", + })); + await step("Blur, then rest the pointer on the trigger", async () => { + await page.evaluate(() => document.activeElement.blur()); + const box = await trigger.boundingBox(); + await page.mouse.move(box.x + 4, box.y + box.height / 2); + await page.mouse.move(box.x + 8, box.y + box.height / 2); + await content.waitFor({ timeout: 2000 }); + }); + await check("hover opens the card with motion allowed", async () => { + const s = await surface(); + return { pass: s.motion === null, ...s }; + }); + await step("Move the pointer far away", async () => { + await page.mouse.move(5, 800); + await page.mouse.move(10, 850); + await content.waitFor({ state: "detached", timeout: 2000 }); + }); + await check("leaving closes the card", async () => ({ pass: (await content.count()) === 0 })); +}; diff --git a/.claude/skills/verify-codeui/journeys/hovercard-touch.mjs b/.claude/skills/verify-codeui/journeys/hovercard-touch.mjs new file mode 100644 index 00000000..b3d0bb56 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/hovercard-touch.mjs @@ -0,0 +1,60 @@ +// HoverCard opens on a touch tap without following the link, sits on the right of its +// trigger by default, keeps the Pop surface, and a second tap closes nothing. +export default async ({ page, step, check, axe, theme }) => { + const content = page.locator("[data-cui=hovercard-content]"); + const trigger = page.locator("[data-cui=hovercard-trigger]"); + const startUrl = page.url(); + await step("Tap the trigger with a touch pointer", async () => { + await trigger.dispatchEvent("pointerdown", { pointerType: "touch", bubbles: true }); + await trigger.dispatchEvent("pointerup", { pointerType: "touch", bubbles: true }); + await trigger.dispatchEvent("click", { bubbles: true, cancelable: true }); + await content.waitFor({ timeout: 2000 }); + }); + await check("tap opens the card and does not follow the link", async () => ({ + pass: (await content.count()) === 1 && page.url() === startUrl, + url: page.url(), + })); + const geometry = async () => { + const t = await trigger.boundingBox(); + const c = await content.boundingBox(); + return { triggerRight: t.x + t.width, cardLeft: c.x, cardWidth: c.width }; + }; + await check("the card sits on the right of the trigger", async () => { + const g = await geometry(); + return { pass: g.cardLeft >= g.triggerRight, ...g }; + }); + await check("floating surface: dialog fill, shadow, radius 16, max width 20rem", () => + content.evaluate((el, theme) => { + const c = getComputedStyle(el); + return { + pass: + c.backgroundColor === + (theme === "dark" ? "rgb(37, 37, 37)" : "rgb(255, 255, 255)") && + c.borderRadius === "16px" && + c.maxWidth === "320px" && + c.boxShadow !== "none" && + (theme === "light" || c.boxShadow.includes("inset")), + bg: c.backgroundColor, + radius: c.borderRadius, + maxWidth: c.maxWidth, + shadow: c.boxShadow, + }; + }, theme), + ); + await axe("open"); + await step("Tap outside", async () => { + await page.mouse.click(1200, 850); + await content.waitFor({ state: "detached", timeout: 2000 }); + }); + await check("an outside press closes the card", async () => ({ + pass: (await content.count()) === 0, + })); + await step("Click the trigger with a mouse", async () => { + const box = await trigger.boundingBox(); + await page.mouse.click(box.x + 8, box.y + box.height / 2); + await page.waitForTimeout(100); + }); + await check("a click opens the card at once, without the 500ms delay", async () => ({ + pass: (await content.count()) === 1, + })); +}; diff --git a/.claude/skills/verify-codeui/journeys/resizable-keyboard.mjs b/.claude/skills/verify-codeui/journeys/resizable-keyboard.mjs new file mode 100644 index 00000000..19f83272 --- /dev/null +++ b/.claude/skills/verify-codeui/journeys/resizable-keyboard.mjs @@ -0,0 +1,45 @@ +// Resizable sidebar: arrow keys move the handle, End stops at maxSize (360px), Home at +// minSize (200px); the focused handle shows the focus colour. +export default async ({ page, step, check, focus, axe }) => { + const sidebar = page.locator("[data-testid=sidebar]"); + const handle = page.getByRole("separator", { name: "Resize sidebar" }); + const width = () => sidebar.evaluate(el => Math.round(el.getBoundingClientRect().width)); + const line = () => + handle.evaluate(el => { + const c = getComputedStyle(el, "::before"); + return { color: c.backgroundColor, width: c.width, focusColor: getComputedStyle(document.documentElement).getPropertyValue("--cui-focus-color").trim() }; + }); + await check("sidebar starts at 240px", async () => { + const w = await width(); + return { pass: w === 240, width: w }; + }); + await step("Tab to the handle", async () => { + await page.keyboard.press("Tab"); + }); + await check("handle has focus and shows a 2px focus-colour line", async () => { + const f = await focus(); + const l = await line(); + return { pass: f.role === "separator" && l.width === "2px", focus: f, ...l }; + }); + await axe("focused"); + await step("ArrowRight", async () => page.keyboard.press("ArrowRight")); + await check("ArrowRight widens the sidebar", async () => { + const w = await width(); + return { pass: w > 240 && w <= 360, width: w }; + }); + await step("End", async () => page.keyboard.press("End")); + await check("End stops at maxSize 360px", async () => { + const w = await width(); + return { pass: w === 360, width: w }; + }); + await step("ArrowRight past the max", async () => page.keyboard.press("ArrowRight")); + await check("the sidebar stays at 360px", async () => { + const w = await width(); + return { pass: w === 360, width: w }; + }); + await step("Home", async () => page.keyboard.press("Home")); + await check("Home stops at minSize 200px", async () => { + const w = await width(); + return { pass: w === 200, width: w }; + }); +}; diff --git a/.claude/skills/verify-codeui/journeys/tooltip-empty.mjs b/.claude/skills/verify-codeui/journeys/tooltip-empty.mjs index f4d3826d..fecafb6f 100644 --- a/.claude/skills/verify-codeui/journeys/tooltip-empty.mjs +++ b/.claude/skills/verify-codeui/journeys/tooltip-empty.mjs @@ -8,7 +8,7 @@ export default async ({ page, step, check, focus, axe }) => { for (const name of empties) { await step(`hover ${name}`, async () => { await page.getByRole("button", { name }).hover(); - await page.waitForTimeout(600); + await page.waitForTimeout(1000); }); await check(`hover ${name}: no bubble`, async () => ({ pass: (await bubbles()) === 0, @@ -20,7 +20,7 @@ export default async ({ page, step, check, focus, axe }) => { for (const [i, name] of empties.entries()) { await step(`Tab to ${name}`, async () => { await page.keyboard.press("Tab"); - await page.waitForTimeout(600); + await page.waitForTimeout(1000); }); await check(`focus ${name}: no bubble, no aria-describedby`, async () => { const f = await focus(); diff --git a/.github/workflows/consumer.yml b/.github/workflows/consumer.yml index df6b42c3..3e9110c4 100644 --- a/.github/workflows/consumer.yml +++ b/.github/workflows/consumer.yml @@ -1,6 +1,18 @@ name: Packed kit consumer on: workflow_dispatch: + pull_request: + paths: + - ".github/workflows/consumer.yml" + - "examples/check-hydration.mjs" + - "examples/consumer-*/**" + - "examples/run-consumer-check.mjs" + - "packages/inkstone/**" + - "packages/kit/**" + - "packages/styles/**" + - "package.json" + - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" jobs: consumer: runs-on: ubuntu-latest @@ -14,4 +26,5 @@ jobs: node-version: 24.x cache: pnpm - run: pnpm install --frozen-lockfile + - run: pnpm exec playwright install-deps chromium - run: node examples/run-consumer-check.mjs diff --git a/.github/workflows/package-preview.yml b/.github/workflows/package-preview.yml new file mode 100644 index 00000000..9fee9d0d --- /dev/null +++ b/.github/workflows/package-preview.yml @@ -0,0 +1,108 @@ +name: Package preview + +on: + pull_request: + +permissions: + contents: read + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + persist-credentials: false + + - uses: pnpm/action-setup@v4 + with: + version: 10.34.9 + + - uses: actions/setup-node@v4 + with: + node-version: 24.x + cache: pnpm + + - run: pnpm install --frozen-lockfile + - run: pnpm build:kit + + - name: Pack the preview packages + run: pnpm --filter '@codeui/kit...' pack --recursive --pack-destination "$RUNNER_TEMP/codeui-preview" + + - name: Upload installable packages + id: artifact + uses: actions/upload-artifact@v4 + with: + name: codeui-preview + path: ${{ runner.temp }}/codeui-preview/*.tgz + if-no-files-found: error + retention-days: 14 + + - name: Publish package preview URLs + id: publish + # The GitHub artifact can still be installed if pkg.pr.new is unavailable. + continue-on-error: true + run: >- + pnpm exec pkg-pr-new publish --pnpm --no-compact --no-template + --previewVersion --comment=off --json "$RUNNER_TEMP/codeui-preview.json" + ./packages/inkstone ./packages/styles ./packages/kit + + - name: Comment the preview links + if: steps.publish.outcome == 'success' && github.event.pull_request.head.repo.full_name == github.repository + uses: actions/github-script@v7 + with: + script: | + const { readFileSync } = require('node:fs'); + const { join } = require('node:path'); + const { packages } = JSON.parse(readFileSync(join(process.env.RUNNER_TEMP, 'codeui-preview.json'), 'utf8')); + const kit = packages.find(pkg => pkg.name === '@codeui/kit'); + const marker = ''; + const body = [ + marker, + '### CodeUI package preview', + '', + `Built from \`${context.payload.pull_request.head.sha.slice(0, 7)}\`.`, + '', + '\`\`\`sh', + `npm install ${kit.url}`, + '\`\`\`', + '', + 'The kit installs matching previews of \`@codeui/styles\` and \`@codeui/inkstone\`.', + '', + ...packages.map(pkg => `- [${pkg.name}](${pkg.url})`), + ].join('\n'); + const issue = { ...context.repo, issue_number: context.issue.number }; + const comments = await github.paginate(github.rest.issues.listComments, issue); + const previous = comments.find(comment => + comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(marker) + ); + if (previous) { + await github.rest.issues.updateComment({ ...context.repo, comment_id: previous.id, body }); + } else { + await github.rest.issues.createComment({ ...issue, body }); + } + + - name: Show download instructions + env: + ARTIFACT_URL: ${{ steps.artifact.outputs.artifact-url }} + PUBLISH_OUTCOME: ${{ steps.publish.outcome }} + run: | + { + echo "### CodeUI preview packages" + if [ "$PUBLISH_OUTCOME" != success ]; then + echo "pkg.pr.new could not publish preview URLs. Check the publish step for details." + echo + fi + echo "[Download the three package tarballs]($ARTIFACT_URL)" + echo + echo '```sh' + echo "gh run download $GITHUB_RUN_ID --repo $GITHUB_REPOSITORY -n codeui-preview -D .codeui-preview" + echo 'npm install ./.codeui-preview/*.tgz' + echo '```' + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.gitignore b/.gitignore index 28b7af10..315ee9d1 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,8 @@ storybook-static # docs: the example apps, copied from apps/examples/dist by scripts/copy-examples.mjs apps/docs/public/examples -# Vitest browser failure screenshots +# Vitest browser failure artifacts __screenshots__ +.vitest-attachments /packages/styles/src/generated-appearance/ diff --git a/README.md b/README.md index 1760172a..669c271d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,18 @@ +## Try packages from a pull request + +Use the `pkg.pr.new` install command in the **CodeUI package preview** comment on the pull request. It points to a specific commit. The kit preview includes matching previews of `@codeui/styles` and `@codeui/inkstone` as dependencies. The Solid 2 kit requires both `solid-js@^2` and `@solidjs/web@^2`. + +You can also download the `codeui-preview` artifact from the **Package preview** run on the pull request. Extract the ZIP in your consumer project and install all three tarballs together. + +```sh +npm install ./.codeui-preview/*.tgz +``` + +The run summary includes a GitHub CLI command that downloads the tarballs to that directory. The artifact expires after 14 days. Repository maintainers can enable direct install URLs by installing the [pkg.pr.new GitHub App](https://github.com/apps/pkg-pr-new) for CodeUI. + ## Project Commands List of cli commands available from a project root. diff --git a/apps/docs/content/docs/(kit)/agents.mdx b/apps/docs/content/docs/(kit)/agents.mdx index 91af4aff..732f60f0 100644 --- a/apps/docs/content/docs/(kit)/agents.mdx +++ b/apps/docs/content/docs/(kit)/agents.mdx @@ -35,7 +35,7 @@ Import parts as a namespace: import * as D from "@codeui/kit/dialog/parts"; ``` -The app needs `solid-js ^1.9.8` and the vanilla-extract Vite plugin. See [Installation](/docs/installation). +The app needs Solid 2, `@solidjs/web`, and `@solidjs/vite-plugin`. See [Installation](/docs/installation). ## Rules for generated code diff --git a/apps/docs/content/docs/(kit)/components/avatar.mdx b/apps/docs/content/docs/(kit)/components/avatar.mdx new file mode 100644 index 00000000..4bfa7369 --- /dev/null +++ b/apps/docs/content/docs/(kit)/components/avatar.mdx @@ -0,0 +1,153 @@ +--- +title: "Avatar" +description: "A person: their picture, or their initials on a colour from their id." +--- + +## When to use + +Use `Avatar` wherever the interface shows a person: the owner of a task, the author of a comment, the members of a group. It shows the person's picture when there is one. Otherwise it shows one or two initials on a fill whose hue comes from a stable id, so the same person keeps the same colour on every screen and two people with the same name do not share one. + +Use one `Avatar` for every person in the app. Do not build a separate badge or initials chip per feature. + +## When to choose another component + +- Use [`Badge`](/docs/components/badge) for a status or a category. An avatar always stands for a person or an owner. +- Use the item's own mark, such as a provider or repository logo in a rounded tile, for something that is not a person. + +## Live demo + + + +Hover an avatar to see the name in the kit [`Tooltip`](/docs/components/tooltip). + +## Anatomy + + + +| Export | Renders | `classes` key | `data-cui` | Role | +| --- | --- | --- | --- | --- | +| `Avatar` | `span` | `root` | `avatar` | `img`, named by `name` | +| Initials | `span`, hidden from assistive technology | `fallback` | `avatar-fallback` | None | +| Picture | `img` with an empty `alt`, only when `src` is set | `image` | `avatar-image` | None | + +The root also renders `data-size` (`xs`, `sm`, `md` or `lg`, default `xs`) and `data-unassigned` when the avatar is unassigned. The picture covers the initials while it loads, so a slow or failed picture never leaves an empty circle. + +## Variants + +### Hue from the id + + + +`identifier` takes a stable id, such as a user id. `avatarHue(identifier)` hashes it to a hue between 0 and 359, and the fill uses that hue at a fixed lightness and chroma per theme. Never pass the name: a name changes and two people can share it. Without `identifier` the fill is neutral grey. + +### Size + + + +`size` takes a step of the shared control scale, so an avatar lines up with the buttons and fields next to it, and it follows `data-cui-density`. + +| `size` | Compact | Comfortable | Touch | Initials | +| --- | --- | --- | --- | --- | +| `xs` (default) | 24px | 28px | 32px | 11px (`--cui-font-size-badge`) | +| `sm` | 32px | 36px | 40px | 13px (`--cui-font-size-caption`) | +| `md` | 38px | 44px | 50px | 14px (`--cui-font-size-sm`) | +| `lg` | 46px | 52px | 58px | 16px (`--cui-font-size-md`) | + +### Initials + +`avatarInitials(name)` takes the first letter of the first and of the last word: "Ada King Lovelace" becomes AL, and "Linus" becomes L. It counts code points, so accented and non-Latin letters stay whole. Pass `initials` when your data has better ones. + +## States + + + +### Picture + +Set `src`. The picture fills the circle with `object-fit: cover`, under the same ring as the initials. + +### Picture failed + +When the picture fails to load, `Avatar` removes it and the initials show. + +### Unassigned + +`unassigned` draws an empty circle with a dashed edge in secondary text colour. It has no fill and no initials. Its accessible name and tooltip are "Unassigned" unless you pass `name`. + +## Ready API + +### `Avatar` + + + +Every other prop goes to the root `span`. `Avatar` wraps no Kobalte primitive. With `tooltip`, the root sits inside the kit `Tooltip` trigger. + +### `avatarHue` + +`avatarHue(identifier: string): number` returns the hue `Avatar` uses for an id, an FNV-1a hash folded to 0–359. Use it to colour something else that belongs to the same person. + +### `avatarInitials` + +`avatarInitials(name: string): string` returns the one or two initials `Avatar` shows for a name, in upper case. + +## Styled parts API + +Import the parts from `@codeui/kit/avatar/parts`. The entry also exports `avatarParts`, `avatarHue`, `avatarInitials` and the types `AvatarPart`, `AvatarClasses`, `AvatarSize` and `AvatarVariants`. + +### `Root` + +The circle. It takes `size`, `unassigned`, `hue` and every `span` attribute. Give it `role="img"` and the name as `aria-label`. + + + +### `Image` + +The picture. It renders while `src` is set and removes itself on error. Its `alt` defaults to empty, because the root carries the name. + +### `Fallback` + +The initials. It sets `aria-hidden="true"`. + +## Styles export + +### `avatarStyles` + +`avatarStyles.root()`, `avatarStyles.image()` and `avatarStyles.fallback()` return `cui-avatar`, `cui-avatar-image` and `cui-avatar-fallback`. On custom markup, set `data-size` and `--cui-avatar-hue`. + +## Accessibility + +The root has `role="img"` and the name as its accessible name, so a screen reader reads "Ada Lovelace, image". The initials are hidden, so they are not read letter by letter, and the picture has an empty `alt`. + +The name also shows in the kit Tooltip on hover. The avatar is not focusable, so put it next to text or inside a control that names the person for keyboard users, such as a row title or a button label. + +The initials reach 4.5:1 against their fill on every hue in both themes: at least 5.5:1 in dark and 10:1 in light. The fill itself can sit close to the surface, which is why the circle has the neutral ring. + +## SSR notes + +`Avatar` renders completely on the server, with the picture and the initials. The hue is computed from the id, so the server and the client agree. The tooltip content renders on the client when it opens. + +## Theming hooks + +| Variable | Default | Used for | +| --- | --- | --- | +| `--cui-avatar-hue` | Set from `identifier` | Fill hue | +| `--cui-avatar-lightness` | `light-dark(0.86, 0.48)` | Fill lightness in OKLCH | +| `--cui-avatar-chroma` | `light-dark(0.06, 0.07)`; `0` without an id | Fill chroma in OKLCH | +| `--cui-avatar-color` | `--cui-text-default` | Initials | +| `--cui-avatar-ring` | `--cui-text-default` at 20% | The 1px inner ring | +| `--cui-avatar-unassigned-color` | `--cui-text-muted` | Dashed edge of an unassigned avatar | +| `--cui-avatar-size`, `--cui-avatar-font-size` | From `data-size` | Diameter and initials size | +| `--cui-radius-full` | | Full radius | + +## Composition examples + +### In a row + + + +In a list row the avatar sits in the leading slot and tells the rows apart by owner. An item with no owner shows the unassigned circle, so every row keeps the same shape. + +## Related + +- [`Tooltip`](/docs/components/tooltip) shows the name on hover. +- [`HoverCard`](/docs/components/hover-card) holds more about the person than a name. +- [Patterns](/docs/design/patterns) explains where avatars go. diff --git a/apps/docs/content/docs/(kit)/components/hover-card.mdx b/apps/docs/content/docs/(kit)/components/hover-card.mdx new file mode 100644 index 00000000..cc4040f0 --- /dev/null +++ b/apps/docs/content/docs/(kit)/components/hover-card.mdx @@ -0,0 +1,200 @@ +--- +title: HoverCard +description: A card of extra detail beside a link, opened by hover, focus or click. +--- + +## When to use + +Use a hover card to preview what sits behind a link: a file, a person, a thread. Use it for a description or for more than one fact. A single name belongs in a [Tooltip](/docs/components/tooltip), and the `title` attribute is never the answer. +It opens when the pointer rests on the trigger, when the trigger gets keyboard focus, and on click, so it works on touch screens. It closes when the pointer leaves both, on blur, on Escape and on a press outside. + +A hover card is supplementary. Never put the only path to an action or to information inside it. The card never takes focus, so a keyboard user cannot reach a button inside it. Keep the same details reachable from the page the link opens. + +## When to choose another component + +- [Tooltip](/docs/components/tooltip) names a control in a few words. A hover card holds a few lines of rich content. +- [Popover](/docs/components/popover) opens on click, takes focus, and can hold buttons and fields. Use it when the user has to act on the content. + +## Live demo + + + +Put `HoverCardTrigger` and `HoverCardContent` in `HoverCard`. Hover the link, or move focus to it with Tab. + +## Anatomy + + + +| Export | Renders | `classes` key | `data-cui` | Role | +| --- | --- | --- | --- | --- | +| `HoverCardGroup` | Nothing. Gives the cards inside it a surface of their own, optional | none | none | none | +| `HoverCard` | Nothing. Holds the open state and the timers | none | none | none | +| `HoverCardTrigger` | `a`, or the element passed to `as` | none | `hovercard-trigger` | Link | +| `HoverCardContent` | The shared card, a `div` in a portal on `mount` or `document.body` | `content` | `hovercard-content` | none | +| `HoverCardList` | `ul`, optional | none | `hovercard-list` | List | +| `HoverCardItem` | `li`, with an icon slot, an identifier and a title | `item`, `itemIcon`, `itemId`, `itemTitle` | `hovercard-item`, `hovercard-item-icon`, `hovercard-item-id`, `hovercard-item-title` | List item | + +## Variants + +### Placement + + + +`placement` sets the side and the alignment. The default is `right-start`: the card sits beside its trigger, top edges aligned, so it does not cover the lines below. When there is no room on the right, Kobalte flips it to the left. The card wraps its text at 20rem (320px). +`gutter` sets the distance from the trigger. The kit sets it to 6px. + +### Delays + + + +The card opens 500ms after the pointer enters or the trigger gets focus, and closes 150ms after the pointer leaves the trigger and the card. Change this with `openDelay` and `closeDelay`. +On its way from the trigger to the card, the pointer may cross the gap between them without closing the card. `ignoreSafeArea` turns that off. + +Once one card is open, the next one opens at once. See [Moving between cards](#moving-between-cards). + +### Moving between cards + + + +All the hover cards of a page share one card. When the pointer or keyboard focus moves to another trigger while a card is open, that card moves to the new trigger instead of closing while a second one opens: it slides to its new place, grows or shrinks to the new content, and the new content fades in. Each `HoverCard` keeps its own props, so the card takes the `placement`, `gutter`, class and handlers of the trigger it moves to. + +- The move happens at once, without `openDelay`. +- For 400ms after a card closes, the next one still opens at once and without the pop. +- On its way to the open card, the pointer may cross another trigger. The card only moves when the pointer rests on that trigger for 150ms, so you can still reach the card you opened. +- When focus moves from the keyboard, the card swaps its content in place, with no motion. +- With reduced motion, the card stays in place and only the new content fades in. + +Because the card is shared, only one hover card of the page is open at a time. A card that must stay open next to another needs its own surface: put it in a `HoverCardGroup` or pass `shared={false}`. + +### Nested cards + +A hover card inside the content of another one gets a surface of its own, without a group. Both cards stay open: the outer card waits while the pointer is on the inner card and until the inner card closes. A press on the inner card does not close the outer one. Escape closes the inner card first. + +### Groups + + + +`HoverCardGroup` gives the cards inside it a card of their own. Moving between triggers of the same group moves the group's card. The cards of a group never take over the page card or another group's card, so a card from each can be open at the same time. A card uses the nearest group above it; outside any group it uses the page card. + +`skipDelayDuration` sets how long after a card of the group closes the next one still opens at once. The page card uses 400ms. + +`shared={false}` gives one `HoverCard` a surface of its own, like a group with a single card. A card with `forceMount` always has its own. + +### List of entries + + + +Use `HoverCardList` and `HoverCardItem` to list tasks, files or members. Each entry is one line: a state icon, a short identifier, then the title, truncated. Show nesting with `depth`, which indents the entry 16px per level, not with tree lines. Drop a prefix every entry shares. A finished entry shows no icon, and the icon slot stays so the identifiers line up. + +The list caps at 24rem (`--cui-hovercard-list-max-height`) and scrolls on its own, so the card keeps its size. The list takes focus with Tab once the card is open, so a keyboard user can scroll it. + +Give each state icon a name with `iconLabel`, such as "Running", and make each state differ in shape, not only colour. + +## States + +### Opened by click or tap + +A click opens the card at once, without `openDelay`. On a touch screen, the first tap on a closed card opens it and does not follow the link; the next tap follows it. A press outside closes the card. + +### Controlled + +Without `open`, the card manages its own state. To control it, pass `open` and `onOpenChange`. When another card takes over the shared surface, the card calls `onOpenChange(false)`. + +## Ready API + +Import from `@codeui/kit/hover-card` or from `@codeui/kit`. + +### `HoverCardGroup` + +Optional. Gives the cards inside it a surface of their own. + + + +### `HoverCard` + +Holds the open state, the hover and focus timers, and the position. + + + +Inherited from Kobalte's [popover](https://kobalte.dev/docs/core/components/popover) root: + + + +### `HoverCardTrigger` + +Renders an `a`. Give it an `href`, or render another focusable element with `as`, so keyboard users can reach it. An `a` without `href` cannot take focus. + +A trigger that renders an `a`, alone or through `as={Link}`, has a dotted underline in the hint tone, so it reads as something to hover inside running text. The underline takes the text colour on hover and while the card is open. A trigger rendered as a button or a row keeps its own look. + +### `HoverCardContent` + +Renders its children into the shared card, which is portaled to `document.body` and placed next to the trigger. While this card is the one shown, its props go on the card: `class`, `classes`, `style`, `ref`, `mount`, the dismiss handlers, and any other attribute or event handler, such as `id`, `aria-hidden` or `onPointerEnter`. When another card takes the card over, they come off and that card's props go on. Attributes take string, number or boolean values. + + + + + +### `HoverCardList` + +A `ul` that caps at 24rem and scrolls. Give it an `aria-label`. Every other prop goes to the `ul`. + +### `HoverCardItem` + +One line in a `HoverCardList`. + + + +### `hoverCardStyles` + +`hoverCardStyles.content()` returns the card class, `cui-hovercard-content`. `hoverCardStyles.list()`, `item()`, `itemIcon()`, `itemId()` and `itemTitle()` return the list classes. `hoverCardParts` maps each part to its `data-cui` value. + +## Accessibility + +### Keyboard + +| Key | Action | +| --- | --- | +| Tab | Moving focus to the trigger opens the card after `openDelay`. Moving focus away closes it. Moving focus to another trigger while the card is open moves the card there at once. | +| Enter | Follows the link. A trigger rendered as a button opens the card. | +| Escape | Closes the card. Focus stays on the trigger. | + +### ARIA + +- A `HoverCardList` is a list with its `aria-label`; a named state icon is an image with its state name. +- The card has no role and is not linked to the trigger. Screen readers announce the link only, which is why the card must not hold anything the user needs. +- Escape closes the innermost layer only, so a hover card inside a dialog closes before the dialog. + +### Focus + +The card never takes focus. Focus stays on the trigger while it is open. + +## SSR notes + +The trigger renders on the server. The card renders on the client, and only while it is open. The page card is created the first time a card opens, in a `div` it appends to `document.body`. + +## Theming hooks + +`HoverCardContent` reads these variables. Set the `--cui-hovercard-content-*` ones on the card to change a single card. See [Tokens](/docs/foundations/tokens) for the defaults. + +| Variable | Default | Used for | +| --- | --- | --- | +| `--cui-hovercard-trigger-decoration-color` | `--cui-text-hint` | Dotted underline of an `a` trigger, before hover | +| `--cui-hovercard-content-background` | `--cui-surface-dialog` | Fill | +| `--cui-hovercard-content-box-shadow` | `--cui-shadow-dialog` | Shadow, and the 1px ring in dark mode | +| `--cui-hovercard-content-radius` | `--cui-radius-card` | Radius (16px) | +| `--cui-hovercard-content-padding` | `--cui-space-4` | Padding | +| `--cui-hovercard-content-max-width` | `min(320px, 100vw - 32px)` | Width limit | +| `--cui-hovercard-content-font-size`, `--cui-hovercard-content-line-height` | `--cui-font-size-sm`, `--cui-font-line-height-snug` | Text (14px / 1.3) | +| `--cui-hovercard-content-color` | `--cui-text-dialog` | Text colour | +| `--cui-hovercard-list-max-height` | `24rem` | Height of a list before it scrolls | +| `--cui-hovercard-item-indent` | `16px` | Indent per `depth` level | +| `--cui-hovercard-item-depth` | Set from `depth` | Nesting level of one entry | +| `--cui-motion-duration-normal`, `--cui-motion-duration-fast`, `--cui-motion-ease-out` | | Pop: in from `scale(0.96)` over 160ms, out to `scale(0.98)` over 120ms | +| `--cui-motion-duration-panel`, `--cui-motion-ease-out` | | Moving between cards: slide, resize and content fade over 200ms, ease-out | + +A card opened by hover or click pops from the trigger side, with `transform-origin` from `--cui-popper-content-transform-origin`. A card opened by keyboard focus, or within 400ms of another card closing, appears with no animation (`data-motion="none"`). With reduced motion, the card only fades, and moving between cards only fades the new content in. Moving between cards from the keyboard has no motion. + +## Related + +- [Tooltip](/docs/components/tooltip) names a control in a few words. +- [Popover](/docs/components/popover) holds interactive content and takes focus. diff --git a/apps/docs/content/docs/(kit)/components/index.mdx b/apps/docs/content/docs/(kit)/components/index.mdx index e219dffc..7acbd906 100644 --- a/apps/docs/content/docs/(kit)/components/index.mdx +++ b/apps/docs/content/docs/(kit)/components/index.mdx @@ -3,7 +3,7 @@ title: Overview description: Every kit component, grouped by the job it does. --- -The kit has 36 components, grouped by purpose. Each link includes live examples and the public API. +The kit has 39 components, grouped by purpose. Each link includes live examples and the public API. ## Actions @@ -13,7 +13,9 @@ The kit has 36 components, grouped by purpose. Each link includes live examples ## Layout and text +- [Avatar](/docs/components/avatar): A person: their picture, or their initials on a colour from their id. - [Kbd](/docs/components/kbd): A keycap that shows a key or a keyboard shortcut. +- [Resizable](/docs/components/resizable): Panels in a row or a column, split by handles the user drags to resize them. - [Stack](/docs/components/stack): A flex container that spaces its children with token gaps. - [Table](/docs/components/table): A native table with Inkstone styles. - [Text](/docs/components/text): Text set in the kit type scale, with tones and polymorphic headings. @@ -54,6 +56,7 @@ The kit has 36 components, grouped by purpose. Each link includes live examples - [CommandMenu](/docs/components/command-menu): A searchable palette of commands opened from the keyboard. - [Dialog](/docs/components/dialog): A modal window over the page, for a decision that blocks the user. - [DropdownMenu](/docs/components/dropdown-menu): A menu of actions opened from a trigger. +- [HoverCard](/docs/components/hover-card): A card of extra detail beside a link, opened by hover, focus or click. - [Popover](/docs/components/popover): A floating panel anchored to a trigger, for content the user opens on demand. - [Sheet](/docs/components/sheet): A panel that slides in from an edge of the screen. - [Tooltip](/docs/components/tooltip): A short label that appears on hover or focus. diff --git a/apps/docs/content/docs/(kit)/components/meta.json b/apps/docs/content/docs/(kit)/components/meta.json index dd56f337..8ba35fc8 100644 --- a/apps/docs/content/docs/(kit)/components/meta.json +++ b/apps/docs/content/docs/(kit)/components/meta.json @@ -7,7 +7,9 @@ "icon-button", "link", "---Layout and text---", + "avatar", "kbd", + "resizable", "settings-row", "stack", "table", @@ -41,6 +43,7 @@ "command-menu", "dialog", "dropdown-menu", + "hover-card", "popover", "sheet", "tooltip" diff --git a/apps/docs/content/docs/(kit)/components/resizable.mdx b/apps/docs/content/docs/(kit)/components/resizable.mdx new file mode 100644 index 00000000..8ea6b914 --- /dev/null +++ b/apps/docs/content/docs/(kit)/components/resizable.mdx @@ -0,0 +1,130 @@ +--- +title: Resizable +description: Panels in a row or a column, split by handles the user drags to resize them. +--- + +## When to use + +Use Resizable when the user decides how much room two areas get: a sidebar next to a conversation, an editor over a console. +The user drags a handle, or focuses it and uses the arrow keys. + +## When to choose another component + +- [Stack](/docs/components/stack) lays out fixed areas. Use it when the sizes are yours to choose, not the user's. +- [Sheet](/docs/components/sheet) is the side panel on a phone. Resizing needs a fine pointer or a keyboard, so swap to a sheet at 768px and below. + +## Live demo + + + +Put `ResizablePanel`s in `Resizable`, with a `ResizableHandle` between each pair. Give the root a size: a height for a row, and both a width and a height for a column. + +## Anatomy + + + +| Export | Renders | `classes` key | `data-cui` | Role | +| --- | --- | --- | --- | --- | +| `Resizable` | `div` with `display: flex` | `root` | `resizable` | none | +| `ResizablePanel` | `div` with `flex-basis` set to its size | `panel` | `resizable-panel` | none | +| `ResizableHandle` | `button` | `handle` | `resizable-handle` | `separator` | + +Only the handle has kit styles. Style the panels yourself. Put padding on a child of the panel: on the panel it adds to the size Kobalte sets. + +## Variants + +### Vertical + + + +`orientation="vertical"` stacks the panels. The handle draws a horizontal line and the arrow keys become Up and Down. + +### Sidebar with a minimum and a maximum width + + + +Sizes take a fraction of the root (`0.25`) or a pixel string (`"240px"`). Here the sidebar starts at 240px and stays between 200px and 360px. The panel without `initialSize` takes the space the others leave. + +### Islands + + + +The handle draws a 1px line in `--cui-border-divider`. In an Inkstone layout of islands, the 8px gap already separates them, and Inkstone allows no line between islands. Set `--cui-resizable-handle-line-color: transparent` on the handle there. The line still shows on hover, while dragging, and on keyboard focus. + +## States + +### Collapsible + + + +`collapsible` lets a panel collapse to `collapsedSize` (0 by default) when the user drags past its `minSize`, or presses Enter on the handle. `onCollapse` and `onExpand` report the change. + +### Controlled + +Without `sizes`, the root manages the sizes. To control them, pass `sizes` as fractions that add up to 1, with `onSizesChange`. Save them to restore the layout on the next visit. + +## Ready API + +Import from `@codeui/kit/resizable` or from `@codeui/kit`. Everything not listed here passes through to Kobalte's [resizable](https://kobalte.dev/docs/core/components/resizable). + +### `Resizable` + + + +### `ResizablePanel` + + + +### `ResizableHandle` + +Give every handle an `aria-label` that names what it resizes. + + + +### `resizableStyles` + +`resizableStyles.handle()` returns the handle class, `cui-resizable-handle`. `root()` and `panel()` return an empty string. `resizableParts` maps each part to its `data-cui` value. `ResizableSize` is a fraction or a `` `${number}px` `` string. `ResizeStrategy` (`"preceding"`, `"following"`, `"both"`) picks which neighbours give up space when a panel resizes from code. + +## Accessibility + +### Keyboard + +| Key | Action | +| --- | --- | +| Tab | Focuses the handle. | +| ← → | Move a horizontal handle by `keyboardDelta` (0.1 of the root by default). | +| ↑ ↓ | Move a vertical handle by `keyboardDelta`. | +| Shift + arrow | Moves the handle as far as the panels allow. | +| Home End | Move the handle to the minimum or the maximum size. | +| Enter | Collapses or expands the nearest collapsible panel. | + +### ARIA + +- The handle has `role="separator"`, `aria-orientation`, and `aria-controls` pointing at the panel before it. +- `aria-valuenow`, `aria-valuemin` and `aria-valuemax` are fractions from 0 to 1. + +### Focus + +Keyboard focus draws the handle line 2px wide in `--cui-focus-color`, with no transition. + +## SSR notes + +Panels with fractional sizes render at their size on the server. A pixel `initialSize` needs the measured root, so prefer fractions when the first server paint matters. + +## Theming hooks + +Set these on the handle. See [Tokens](/docs/foundations/tokens) for the defaults. + +| Variable | Default | Used for | +| --- | --- | --- | +| `--cui-resizable-handle-size` | `--cui-space-2` (8px) | Hit area. It overlaps both panels, so the panels still fill the root | +| `--cui-resizable-handle-line-color` | `--cui-border-divider` | Line at rest | +| `--cui-resizable-handle-line-active-color` | `--cui-surface-scroll-thumb` | Line on hover and focus (`data-active`) | +| `--cui-resizable-handle-line-dragging-color` | `--cui-surface-scroll-thumb-hover` | Line while dragging (`data-dragging`) | +| `--cui-resizable-handle-line-width` | `--cui-border-width` (1px) | Line width; 2px on keyboard focus | +| `--cui-motion-duration-fast`, `--cui-motion-ease-out` | | Line colour change, 120ms | + +## Related + +- [Sheet](/docs/components/sheet) holds the same panel on a phone. +- [Stack](/docs/components/stack) lays out areas the user does not resize. diff --git a/apps/docs/content/docs/(kit)/components/tooltip.mdx b/apps/docs/content/docs/(kit)/components/tooltip.mdx index 21c42897..1354fdb4 100644 --- a/apps/docs/content/docs/(kit)/components/tooltip.mdx +++ b/apps/docs/content/docs/(kit)/components/tooltip.mdx @@ -38,8 +38,8 @@ Wrap the element in `Tooltip` and pass the label as `content`. Hover the button, -`variant="primary"` fills the tooltip with the brand blue. It is the default. `variant="secondary"` uses the neutral fill. -Inkstone keeps the accent for focus, selection, and the one primary action, so prefer `secondary` in toolbars and panels. +`variant="secondary"` uses the neutral fill. It is the default. `variant="primary"` fills the tooltip with the brand blue. +Inkstone keeps the accent for focus, selection, and the one primary action, so keep `secondary` in toolbars and panels. ### Placement @@ -52,9 +52,24 @@ Inkstone keeps the accent for focus, selection, and the one primary action, so p -The tooltip opens 200ms after the pointer enters and closes at once when it leaves. Change this with `openDelay` and `closeDelay`. +The tooltip opens 700ms after the pointer enters and closes at once when it leaves. Change this with `openDelay` and `closeDelay`. Keyboard focus ignores `openDelay` and opens the tooltip at once. +### Defaults for a whole app + +Wrap the app in `TooltipProvider` to set the defaults of every tooltip below it. A prop on one tooltip still wins. + +```tsx +import { TooltipProvider } from "@codeui/kit"; + + + +; +``` + +It takes `openDelay`, `closeDelay`, `skipDelayDuration`, `gutter`, `shift` and `variant`. With parts, import it as `Provider` from `@codeui/kit/tooltip/parts`. +`skipDelayDuration` is how long after a tooltip closes the next one opens at once, without its delay or its animation. The kit default is 400ms. + ### Icon button trigger @@ -128,7 +143,7 @@ The trigger `div` and its children render on the server. The content renders on | `--cui-shadow-md` | Shadow | | `--cui-motion-duration-normal`, `--cui-motion-duration-fast`, `--cui-motion-ease-out` | Pop: in from `scale(0.96)` over 160ms, out to `scale(0.98)` over 120ms | -A tooltip opened by hover pops from its trigger. One opened by keyboard focus, and the next tooltip opened within 300ms of another closing, appear with no animation (`data-motion="none"`), as Inkstone asks. The description goes on the first focusable element inside the trigger, so a screen reader reads it with the focused control. +A tooltip opened by hover pops from its trigger. One opened by keyboard focus, and the next tooltip opened within 400ms of another closing, appear with no animation (`data-motion="none"`), as Inkstone asks. The description goes on the first focusable element inside the trigger, so a screen reader reads it with the focused control. ## Composition examples diff --git a/apps/docs/content/docs/(kit)/contributing/add-a-component.mdx b/apps/docs/content/docs/(kit)/contributing/add-a-component.mdx index d5e70c6c..23c374cd 100644 --- a/apps/docs/content/docs/(kit)/contributing/add-a-component.mdx +++ b/apps/docs/content/docs/(kit)/contributing/add-a-component.mdx @@ -17,7 +17,7 @@ Each component has three layers. Each layer builds on the one before it. | Parts | `packages/kit/src/parts/.tsx` | `@codeui/kit/` | Apps that need a custom layout, and the ready component | | Ready component | `packages/kit/src/components//.tsx` | `@codeui/kit` | Most apps | -Wrap a Kobalte primitive when one exists. Check the [Kobalte components](https://kobalte.dev) for version 0.13.14 first. Build on plain elements only when Kobalte has nothing, as `Stack` and `Text` do. +Wrap a Kobalte primitive when one exists. Check the [Kobalte 2 components](https://github.com/kobaltedev/kobalte/tree/solid2/packages/core/src) first. Build on plain elements only when Kobalte has nothing, as `Stack` and `Text` do. ## Write the styles @@ -58,12 +58,8 @@ export const badgeStyles: BadgeStyles = { }; export function Root(props: PolymorphicProps>) { - const [local, others] = splitProps(props as PolymorphicProps<"span", RootProps>, [ - "class", - "size", - "tone", - "variant", - ]); + const local = props as PolymorphicProps<"span", RootProps>; + const others = omit(local, "class", "size", "tone", "variant"); return ( = B.RootProps & { /** A short, non-interactive status label. Set `textValue` when the content is not text. */ export function Badge(props: PolymorphicProps>) { - const [local, others] = splitProps(props as PolymorphicProps<"span", BadgeProps>, [ - "children", - "icon", - "classes", - "class", - ]); + const local = props as PolymorphicProps<"span", BadgeProps>; + const others = omit(local, "children", "icon", "classes", "class"); return ( @@ -133,7 +125,7 @@ export function Badge(props: PolymorphicProps ## Test the behavior -Tests live in `packages/kit/test`. Client tests run in jsdom with `solid-testing-library`. A file that ends in `.ssr.test.tsx` runs in the server test config instead. +Tests live in `packages/kit/test`. Client tests run in Chromium with Vitest and `@solidjs/testing-library`. A file that ends in `.ssr.test.tsx` runs in the server test config instead. ```tsx title="packages/kit/test/display.test.tsx" it("names the badge with its text, not its icon", () => { diff --git a/apps/docs/content/docs/(kit)/contributing/verify-accessibility-and-ssr.mdx b/apps/docs/content/docs/(kit)/contributing/verify-accessibility-and-ssr.mdx index 48e63e84..5ab9e5b1 100644 --- a/apps/docs/content/docs/(kit)/contributing/verify-accessibility-and-ssr.mdx +++ b/apps/docs/content/docs/(kit)/contributing/verify-accessibility-and-ssr.mdx @@ -84,7 +84,7 @@ The harness runs `pnpm install`, so do not run it in a checkout that another pro ## Test the server render ```tsx title="packages/kit/test/accordion.ssr.test.tsx" -import { renderToString } from "solid-js/web"; +import { renderToString } from "@solidjs/web"; import { Accordion } from "../src/components/Accordion/Accordion"; it("server renders labelled headers and expanded content without DOM measurement", () => { const html = renderToString(() => ( diff --git a/apps/docs/content/docs/(kit)/installation.mdx b/apps/docs/content/docs/(kit)/installation.mdx index 5ae25062..517cec0f 100644 --- a/apps/docs/content/docs/(kit)/installation.mdx +++ b/apps/docs/content/docs/(kit)/installation.mdx @@ -5,26 +5,28 @@ description: "Install static styles and the Solid components." ## Requirements -The component package supports Solid `^1.9.8`. Its styles are plain CSS. The library builds the Inkstone theme from DTCG tokens before publishing. +The component package requires Solid 2 and `@solidjs/web`. It uses Kobalte 2.0.0. Its styles are plain CSS. The library builds the Inkstone theme from DTCG tokens before publishing. ## Install ```sh -pnpm add @codeui/kit solid-js@^1.9.8 -pnpm add -D vite vite-plugin-solid +pnpm add @codeui/kit solid-js@^2 @solidjs/web@^2 +pnpm add -D vite@^8 @solidjs/vite-plugin@^3 ``` ## Configure Vite ```ts title="vite.config.ts" import { defineConfig } from "vite"; -import solid from "vite-plugin-solid"; +import solid from "@solidjs/vite-plugin"; export default defineConfig({ plugins: [solid()], }); ``` +Set `jsxImportSource` to `@solidjs/web` in `tsconfig.json`. To upgrade an existing project, follow the [Solid 2 migration guide](https://docs.solidjs.com/migration/from-solid-1/). + ## Automatic styles Import a Solid component normally. Its module imports the compiled component stylesheet, shared styles and theme. diff --git a/apps/docs/content/docs/(kit)/migration/from-0-1.mdx b/apps/docs/content/docs/(kit)/migration/from-0-1.mdx index 8d0c6b35..e4a94a55 100644 --- a/apps/docs/content/docs/(kit)/migration/from-0-1.mdx +++ b/apps/docs/content/docs/(kit)/migration/from-0-1.mdx @@ -10,10 +10,12 @@ Work through the sections in order. ## Raise the Solid version ```sh -pnpm add @codeui/kit solid-js@^1.9.8 +pnpm add @codeui/kit solid-js@^2 @solidjs/web@^2 ``` -The kit depends on `@kobalte/core` 0.13.14 and `@kobalte/utils` 0.9.2. Kobalte 0.13.13 raised its own peer to `solid-js ^1.9.8`, so the kit's peer moved from `^1.7.0` to `^1.9.8`. An app on Solid 1.8 gets a peer dependency warning and can resolve two Solid copies. +Upgrade the app to Solid 2 before installing the current kit. Follow the [Solid 2 migration guide](https://docs.solidjs.com/migration/from-solid-1/). + +For Vite, replace `vite-plugin-solid` with `@solidjs/vite-plugin` and set `jsxImportSource` to `@solidjs/web`. See the [Vite setup](/docs/installation#configure-vite). ## Load the compiled CSS @@ -23,7 +25,7 @@ The library publishes plain CSS with its generated Inkstone theme. Remove a vani ## Check the Kobalte behavior changes -No Kobalte release between 0.13.6 and 0.13.14 is marked breaking. These changes are visible in kit components: +The kit now uses [Kobalte 2.0.0](https://github.com/kobaltedev/kobalte/releases/tag/@kobalte%2Fcore@2.0.0). If your app also imports Kobalte directly, upgrade that dependency to the same release. These behavior changes also apply when upgrading from a kit version built on Kobalte 0.13. | Change | Where you see it | What to do | | --- | --- | --- | diff --git a/apps/docs/content/docs/(kit)/migration/from-codeimage-ui.mdx b/apps/docs/content/docs/(kit)/migration/from-codeimage-ui.mdx index 69436e8c..93aaed5d 100644 --- a/apps/docs/content/docs/(kit)/migration/from-codeimage-ui.mdx +++ b/apps/docs/content/docs/(kit)/migration/from-codeimage-ui.mdx @@ -9,7 +9,7 @@ This page maps every export of `@codeimage/ui` that CodeImage still imports. Mov ## Before you start -1. Install the kit as shown in [Installation](/docs/installation). The kit needs `solid-js ^1.9.8` and the vanilla-extract Vite plugin. +1. Install the kit as shown in [Installation](/docs/installation). The kit requires Solid 2 and `@solidjs/web`. 2. Put your CSS reset below the kit's layer. See [Keep app resets below the kit layer](#keep-app-resets-below-the-kit-layer). 3. Set `data-cui-theme` on ``. See [Replace the theme attributes](#replace-the-theme-attributes). diff --git a/apps/docs/content/docs/css/components/avatar.mdx b/apps/docs/content/docs/css/components/avatar.mdx new file mode 100644 index 00000000..0cfa5812 --- /dev/null +++ b/apps/docs/content/docs/css/components/avatar.mdx @@ -0,0 +1,69 @@ +--- +title: Avatar +description: "A person in plain HTML: their picture, or their initials on a colour from their id." +--- + +Load `@codeui/styles/avatar.css`, or `all.css`. The Solid component is documented in [Avatar](/docs/components/avatar). + +## Demo + + + +## Markup + +| Part | Element | Class | `data-cui` | +| --- | --- | --- | --- | +| Root | `span` with `role="img"` and the name as `aria-label` | `cui-avatar` | `avatar` | +| Initials | `span` with `aria-hidden="true"` | `cui-avatar-fallback` | `avatar-fallback` | +| Picture | `img` with `alt=""`, after the initials | `cui-avatar-image` | `avatar-image` | + +| Attribute | Values | Default | +| --- | --- | --- | +| `data-size` | `xs`, `sm`, `md`, `lg` | `xs` | +| `data-unassigned` | Presence | Off | +| `--cui-avatar-hue` (inline style) | A hue in degrees | `0` | +| `--cui-avatar-chroma` (inline style) | `0` for a neutral fill | Set per theme | + +## Variants + +### Size + + + +The sizes are the shared control heights, `--cui-control-height-xs` to `--cui-control-height-lg`, so they follow `data-cui-density`. Comfortable density gives 28, 36, 44 and 52px. + +### Hue + +Set `--cui-avatar-hue` from a stable id, never from the name. `avatarHue(id)` from `@codeui/styles/avatar` returns the hue the Solid component uses. Without an id, set `--cui-avatar-chroma: 0` for a neutral fill. + +## States + +### Picture + +Put the `img` after the initials. It covers them while it loads. When it fails, remove it and the initials show. + +### Unassigned + +Set `data-unassigned` and leave the root empty. It draws a dashed circle with no fill. Name it "Unassigned". + +## What you supply + +- The hue from a stable id, and the initials from the name. `avatarHue` and `avatarInitials` from `@codeui/styles/avatar` do both. +- Removing the picture when it fails to load. +- A tooltip with the name, such as the [Tooltip](/docs/css/components/tooltip) markup. + +## Helper + +```ts +import "@codeui/styles/avatar.css"; +import { applyStyleProps } from "@codeui/styles"; +import { avatarHue, avatarInitials, avatarStyleProps } from "@codeui/styles/avatar"; + +const avatar = document.createElement("span"); +applyStyleProps(avatar, avatarStyleProps({ size: "sm" })); +avatar.role = "img"; +avatar.ariaLabel = "Grace Hopper"; +avatar.style.setProperty("--cui-avatar-hue", String(avatarHue("user_grace"))); +avatar.innerHTML = ``; +// class="cui-avatar" data-cui="avatar" data-size="sm" +``` diff --git a/apps/docs/content/docs/css/components/dropdown-menu.mdx b/apps/docs/content/docs/css/components/dropdown-menu.mdx index 4585f48a..bbc021cb 100644 --- a/apps/docs/content/docs/css/components/dropdown-menu.mdx +++ b/apps/docs/content/docs/css/components/dropdown-menu.mdx @@ -19,7 +19,7 @@ The demos render the open menu in normal flow, under its trigger. On a page, the | Content | `div` | `cui-dropdownmenu-content` | `dropdownmenu-content` | | Item | `div` or `button` | `cui-dropdownmenu-item` | `dropdownmenu-item` | | Right slot | `div` or `span` | `cui-dropdownmenu-right-slot` | None | -| Separator | `div` | `cui-dropdownmenu-separator` | None | +| Separator | `hr` or `div` | `cui-dropdownmenu-separator` | None | | Submenu content | `div` | `cui-dropdownmenu-submenu-content cui-dropdownmenu-content` | None | The right slot holds a shortcut or a submenu arrow. It pushes itself to the end of the item and uses muted text. diff --git a/apps/docs/content/docs/css/components/hover-card.mdx b/apps/docs/content/docs/css/components/hover-card.mdx new file mode 100644 index 00000000..85a530cf --- /dev/null +++ b/apps/docs/content/docs/css/components/hover-card.mdx @@ -0,0 +1,65 @@ +--- +title: HoverCard +description: A card of extra detail next to a link, in plain HTML. +--- + +Load `@codeui/styles/hovercard.css`, or `all.css`. The Solid component is documented in [HoverCard](/docs/components/hover-card). + +## Demo + + + +The demo renders the open card in normal flow, under its trigger. On a page, the card floats and your positioning code places it. + +## Markup + +| Part | Element | Class | `data-cui` | +| --- | --- | --- | --- | +| Trigger | `a` with an `href`. It gets a dotted underline in the hint tone | none | `hovercard-trigger` | +| Content | `div` | `cui-hovercard-content` | `hovercard-content` | +| List | `ul` with an `aria-label` | `cui-hovercard-list` | `hovercard-list` | +| Entry | `li` | `cui-hovercard-item` | `hovercard-item` | +| State icon | `span`, 16px, always present | `cui-hovercard-item-icon` | `hovercard-item-icon` | +| Identifier | `span` | `cui-hovercard-item-id` | `hovercard-item-id` | +| Title | `span`, truncated | `cui-hovercard-item-title` | `hovercard-item-title` | + +| Attribute | Values | Default | +| --- | --- | --- | +| `data-expanded` on the trigger | Presence, while the card is open. The dotted underline takes the text colour | Off | +| `data-expanded` on the content | Presence | Off | +| `data-motion` on the content | `none` | None | + +## List of entries + + + +One line per entry: state icon, identifier, then the title truncated. Set `--cui-hovercard-item-depth` on an entry to indent it 16px per level. The list caps at 24rem and scrolls on its own. Keep the icon span on a finished entry, empty, so the identifiers line up. + +## States + +### Open + +`data-expanded` plays the pop-in: a fade from `scale(0.96)`. The animation grows from `--cui-popper-content-transform-origin`, so set it to the side that faces the trigger. +Without `data-expanded`, the content plays its exit animation and stays transparent. Set it on an open card even without a script. + +### Closing + +Remove `data-expanded` while the card is still in the page, and remove the card when the animation ends. `data-motion="none"` turns off both animations. Use it when the card opens from keyboard focus. With reduced motion, the card only fades. + +## What you supply + +- Showing the card at once on a click or tap, and 500ms after the pointer rests on the trigger or the trigger gets focus, and hiding it 150ms after the pointer leaves the trigger and the card, on blur, and on Escape. +- Placement beside the trigger, on the right unless there is no room, then on the left, and `--cui-popper-content-transform-origin`. +- A focusable trigger. Nothing in the card may be the only way to reach an action: the card never takes focus. + +## Helper + +```ts +import "@codeui/styles/hovercard.css"; +import { hoverCardParts, hoverCardStyles } from "@codeui/styles/hovercard"; + +const card = document.querySelector("#thread-card")!; +card.className = hoverCardStyles.content(); +card.dataset.cui = hoverCardParts.content; +// class="cui-hovercard-content" data-cui="hovercard-content" +``` diff --git a/apps/docs/content/docs/css/components/meta.json b/apps/docs/content/docs/css/components/meta.json index fb997792..ee9de684 100644 --- a/apps/docs/content/docs/css/components/meta.json +++ b/apps/docs/content/docs/css/components/meta.json @@ -6,7 +6,9 @@ "icon-button", "link", "---Layout and text---", + "avatar", "kbd", + "resizable", "settings-row", "stack", "table", @@ -39,6 +41,7 @@ "command-menu", "dialog", "dropdown-menu", + "hover-card", "popover", "sheet", "tooltip" diff --git a/apps/docs/content/docs/css/components/resizable.mdx b/apps/docs/content/docs/css/components/resizable.mdx new file mode 100644 index 00000000..56ac08b9 --- /dev/null +++ b/apps/docs/content/docs/css/components/resizable.mdx @@ -0,0 +1,55 @@ +--- +title: Resizable +description: The handle between two resizable panels, in plain HTML. +--- + +Load `@codeui/styles/resizable.css`, or `all.css`. The Solid component is documented in [Resizable](/docs/components/resizable). + +## Demo + + + +## Markup + +| Part | Element | Class | `data-cui` | +| --- | --- | --- | --- | +| Root | `div` | none | `resizable` | +| Panel | `div` | none | `resizable-panel` | +| Handle | `button type="button"` with `role="separator"` | `cui-resizable-handle` | `resizable-handle` | + +Only the handle has styles. Give the root `display: flex` (`flex-direction: column` when vertical) and a size, and give each panel `flex: none`, `overflow: hidden` and a `flex-basis`. + +| Attribute | Values | Default | +| --- | --- | --- | +| `data-orientation` on the handle | `horizontal`, `vertical` | `horizontal` | +| `data-active` on the handle | Presence: hovered, focused or dragged | Off | +| `data-dragging` on the handle | Presence | Off | + +## Variants + +### Vertical + + + +`data-orientation="vertical"` draws a horizontal line and a row-resize cursor. + +## States + +The line is `--cui-border-divider` at rest, `--cui-surface-scroll-thumb` on hover and with `data-active`, `--cui-surface-scroll-thumb-hover` with `data-dragging`, and 2px of `--cui-focus-color` on `:focus-visible`. The colour changes over 120ms, except on keyboard focus. In an island layout, set `--cui-resizable-handle-line-color: transparent`: the gap between islands already separates them. + +## What you supply + +- Dragging and keyboard resizing: arrow keys by a step, Home and End to the limits, Enter to collapse. +- `aria-orientation`, `aria-controls`, `aria-valuenow`, `aria-valuemin` and `aria-valuemax` on the handle, and an `aria-label`. + +## Helper + +```ts +import "@codeui/styles/resizable.css"; +import { applyStyleProps } from "@codeui/styles"; +import { resizableStyleProps } from "@codeui/styles/resizable"; + +const handle = document.querySelector("[role=separator]")!; +applyStyleProps(handle, resizableStyleProps({ orientation: "vertical" })); +// class="cui-resizable-handle" data-cui="resizable-handle" data-orientation="vertical" +``` diff --git a/apps/docs/content/docs/design/color.mdx b/apps/docs/content/docs/design/color.mdx index bfa0ea87..66f7a180 100644 --- a/apps/docs/content/docs/design/color.mdx +++ b/apps/docs/content/docs/design/color.mdx @@ -165,6 +165,12 @@ Toghen resolves the status tokens from the Gosfuig ramps. Danger uses red, cauti When you override a status `base` token, its hover and active colours follow through CSS relative colours. +### Workflow states are not status + +A task "in review" or "to test" needs nothing from the user, so it is neutral or uses the brand wash. In CodeLoom, every in-progress Jira item once had the same orange half-circle, and it read as a warning: "alcuni sembrano warning anche se sono in to test". Every state has a visible name, in a label or a tooltip, and its glyph changes shape as well as colour. + +The reverse matters as much. A real warning, such as a server that needs you to sign in, always shows in the caution tone with an alert icon, and never folds into ordinary content or a collapsed group. And a finished item does not celebrate in green: it shows no status icon and keeps its time. + ## Lines A line is allowed only where a fill would disappear: diff --git a/apps/docs/content/docs/design/decisions.mdx b/apps/docs/content/docs/design/decisions.mdx index 534f0f18..77a3a004 100644 --- a/apps/docs/content/docs/design/decisions.mdx +++ b/apps/docs/content/docs/design/decisions.mdx @@ -33,6 +33,11 @@ Every rule in Inkstone was decided by reviewing a working build. None comes from | A toast pointing to "7 new things" in Settings | It sent the user away from their work | Dots on the controls themselves | | A 9.5px timeline label | Unreadable | 11px minimum | | Glass window style, dot grid backgrounds | Glossy and busy | Hairline, flat or accent wash | +| `title` attributes for descriptions | Slow, unstyled, unreachable by touch | A hover card | +| A status footer for ambient state | "un po fuorviante" | A header control shown only when it needs action | +| A full screen with "Back to …" | It hid the work | A tab in an island | +| A formatting toolbar under a text input | "non servono a niente" | Shortcuts that render as you type | +| A generic icon and the same label on every row | Every row looked the same | The item's own mark in the leading slot | ## Where the kit disagrees with Inkstone @@ -47,8 +52,9 @@ The kit's tokens were measured from CodeImage, so they carry CodeImage's drift a | Selection | Kit listbox fills the selected row with blue | Neutral fill | | Radius | Eleven tokens; buttons at 9px, dialogs at 14px, the toolbar at 18px | The nesting table | | Selection ring | Drawn with inset shadow, outline or border in different places | `outline` with a negative offset | -| Focus | Mostly 2px offset, 3px in the accordion | 2px everywhere | +| Focus | Mostly 2px offset, 3px in the accordion | 2px offset, inside the row in packed lists and toolbars | | Motion | Button press 200ms `ease`; focus `ease-in`; dialog `ease-in-out` keyframes | The movements on the Motion page | +| Island gap | CodeImage sits 8px from the edge and between islands | 6px (`--cui-space-1-5`) | | Breakpoints | 767, 768 and 769px | 768 / 769 only | | Export colour | CodeImage's Export still uses the old kit blue `#0072f5` | `--cui-action-brand-base` | | Tags, keycaps, grips | Three tag styles, three keycap styles, two grips | One each | diff --git a/apps/docs/content/docs/design/layout.mdx b/apps/docs/content/docs/design/layout.mdx index b2bd8c26..da0b05c2 100644 --- a/apps/docs/content/docs/design/layout.mdx +++ b/apps/docs/content/docs/design/layout.mdx @@ -17,9 +17,15 @@ description: A still content island, a 360px side panel, floating bars, and one └──────────────────────────────────────────────────────────────┘ ``` -The interface has fixed sizes and the content takes all the remaining space. The side panel is 360px. The header row is 36px. Everything sits 8px from the window edge and 8px from its neighbours. +The interface has fixed sizes and the content takes all the remaining space. The side panel is 360px. The header row is 36px. Everything sits 6px from the window edge and 6px from its neighbours. -When the content is read-only, the layout leaves out the containers of the controls it does not show. The content gets that space, instead of empty frames where the controls would be. +The space of an island layout goes inside the islands. The page between them is a thin seam. CodeLoom started with wider gaps, and they spent room on background instead of content: "questo permette di risparmiare spazio". + +A side panel may be resizable with the kit `Resizable`, always between a minimum and a maximum width, so it can make room for long titles without swallowing the content. + +A view opens as a tab in an island, beside the content. It never replaces the content with a full screen and a "Back to …" button. + +When the content is read-only, the layout leaves out the containers of the controls it does not show. The content gets that space, instead of empty frames where the controls would be. The same goes for lists: an item with nothing in it gets no row. CodeLoom once showed an empty "checkpoint" row: "non ha molto senso". ## Side panel @@ -28,6 +34,7 @@ CodeImage's side panel is an accordion. Its rules came from several review round - **One section open at a time.** With several sections open, the panel scrolled further every time a section was opened. - **Everything visible inside the open section.** An early build had "More / Less" toggles inside sections, which hid options without making the panel easier to scan. They were removed. - **The header carries the current value.** Each section header shows an icon, a title, the current value as a short grey summary (for example "64" or "macOS"), and a chevron. The user can read the whole configuration with every section closed. +- **The whole header is the trigger.** The chevron is an icon inside the row, not a separate button, and row actions sit over the end of the row inside its fill. A separate chevron button left the rest of the row dead and made the two hit areas collide. - **The open section sits on an inset**, a quieter island inside the panel, so it is clear which header the controls belong to. The panel can also be shown as a rail of icons, one panel per section. That is a preference in Settings, not a separate layout. Both forms render the same sections from the same code, so they cannot drift apart. A hybrid of rail and accordion was tried and rejected. diff --git a/apps/docs/content/docs/design/motion.mdx b/apps/docs/content/docs/design/motion.mdx index bfb358b6..4abc7973 100644 --- a/apps/docs/content/docs/design/motion.mdx +++ b/apps/docs/content/docs/design/motion.mdx @@ -41,6 +41,10 @@ Naming the movements gives designers, developers and agents a shared vocabulary. When you minimise CodeImage's large "What's new" dialog, it does not just fade out. It shrinks to a third of its size and slides into the small card in the bottom-left corner, in 200ms. The motion tells the user where the content went, so they know where to find it again. This is what motion is for in Inkstone. +### Spinners share one clock + +Several spinners that mount at different moments, in a sidebar row, a list entry and a chip, turn out of phase and look like separate, nervous activities. Every spinner turns on one clock, aligned to the document timeline, so they read as one. **Proposed:** the kit `Spinner` does this itself. + ### What stays still In CodeImage's side panel, the segmented control's indicator **jumps** to the new option instead of sliding. That is deliberate. The control is used many times while working, and the content it changes, such as the frame radius, animates instead. The control responds instantly and the content changes smoothly. diff --git a/apps/docs/content/docs/design/patterns.mdx b/apps/docs/content/docs/design/patterns.mdx index dc7d3d7f..670686e7 100644 --- a/apps/docs/content/docs/design/patterns.mdx +++ b/apps/docs/content/docs/design/patterns.mdx @@ -51,6 +51,7 @@ The preview is a schematic drawn in the option's own colours, not a miniature of | Overlay | When | Backdrop | | --- | --- | --- | | Tooltip | Name an icon, explain a value | None | +| Hover card | Show several facts or a description | None | | Popover | Pick a value for one row | None | | Menu | Choose an action | None | | Command menu | Find anything by name | None | @@ -70,13 +71,19 @@ A picker opens over the panel that holds it, anchored to its row. It does not pu A dialog is for settings and for decisions the user must make before continuing, such as reviewing detected secrets before an export. It is not for asking "are you sure?" about something that can be undone. +A tooltip is one line that names one thing. A description, or several facts about a row, goes in a hover card beside its trigger, on the right unless there is no room, wrapped at about 20rem. It opens on click too, so touch works, and everything in it is reachable another way. The `title` attribute is never used: it is slow, unstyled, and invisible to touch and keyboard. Use the kit [`HoverCard`](/docs/components/hover-card): it opens on hover, focus and click, sits on the right by default, and follows Pop. Moving to the next trigger while a card is open moves that card instead of opening a second one: it slides to the new trigger and resizes to the new content. A trigger in running text has a dotted underline in the hint tone, so it reads as something to hover. + +A list inside a menu or a hover card has one line per entry: state icon, identifier, title truncated. Nesting shows by indent, and a prefix that every entry shares is dropped. Two or more entries for the same action go in a submenu labelled with the count, so the menu does not fill up with "Open …" rows. A long list caps at about 24rem and scrolls on its own. In a hover card, build it with `HoverCardList` and `HoverCardItem`. + Escape closes only the innermost layer. In CodeImage, pressing Escape on a segmented control inside Settings once closed the whole dialog. ## Command menu `⌘K`, or `Ctrl+K` outside Apple platforms, opens the command menu in every layout. It floats at the bottom centre, six rows tall, with no scrim, so the content stays in view while you browse. -It lists every option of every visible control, every action and every setting. It reads the same data as the controls, so a new setting appears in it without extra work. Moving through the rows previews each option on the content. Enter applies it and Escape puts the old value back. A short hint in the search row says so: `↑↓ preview · ↵ apply · esc cancel`. +It lists every option of every visible control, every action and every setting. It reads the same data as the controls, so a new setting appears in it without extra work. Moving through the rows previews each option on the content. Enter applies it and Escape puts the old value back. A footer row of keycaps says so: `↑↓ Navigate · ↵ Apply · esc Close`. + +Rows are an icon, the name, and the description on the right. The highlighted row's full description opens in a hover card that follows the arrow keys. A group label has about `--cui-space-2` above it and `--cui-space-1` below, and the first label adds nothing above. ## Actions in dialogs and toasts @@ -91,6 +98,42 @@ Close and Confirm go on the right of the footer. A third, minor action is a smal +An action at the end of a sentence or a notice, such as **Sign in** after a message that asks for it, is a text link after `--cui-space-2`, underlined on hover. A button box pressed against the text looked "orrendo". + +## Rows in a list + +- **The leading slot tells the item apart.** It holds the item's type, source or owner, never a generic icon repeated on every row. A label that is the same on every row moves to the accessible description. +- **The trailing slot has one meaning.** It shows the time, and an icon only for live work, a failure, a stop or a request for the user. A list where some finished rows showed a check and others showed "2h" raised the question: "what's the difference between completed and 1h?" +- **Ownership is nesting.** An item sits under its owner, not under a separate heading that changes with the selection. Organising groups, such as pinned or archived, stay outside that tree. +- **One row per thing.** A summary and its members are one row: the live member first, then the count that opens the rest. A fact every member shares goes once on the group row. +- **A large flat group gets a second level** by the owner the user recognises, with an avatar and a count, instead of long paths on every row. + +## Background work + +Work that runs while the user does something else stays visible as one control near where the user acts. It shows a count and how many are still active, for example "3 tasks · 1 running", opens the list, where each item shows what it runs and for how long, and goes away when nothing is left. + +## Data and technical values + +- **Show data as what it is.** A file read shows the lines, a change shows a diff, anything else shows name and value rows. Raw JSON is only for data with no known shape. +- **Show the value, not a verb about it.** A command, path or query shows itself. The part that identifies it is primary text, the rest is tertiary mono and truncates. Opened, the full value is highlighted in the code font with a Copy button. "Running pnpm" said nothing about what ran. +- **Running work shows its time** at the end of its row, in tabular figures with a reserved width, and the time stays once the work ends. +- **An author line** is the author's mark in a rounded tile, the name in primary text, then facts in secondary text joined by " · ". + +## Avatar + +A person is an avatar: their picture when there is one, otherwise one or two initials on a hue derived from their id, never from their name, so the colour does not change when the name does. Full radius with a neutral ring, so it never vanishes into its background. The name is in the tooltip and the accessible name. Sizes come from the shared control scale, and an unassigned owner is an empty dashed circle. Use the kit [`Avatar`](/docs/components/avatar); three CodeLoom features had each built their own. + +## Forms and inputs + +- **A setup form asks the main choice first** and puts advanced methods behind a disclosure. Each method has a one-line hint on where to find its value. An error sits under the field that caused it, and clears when the method changes. +- **A suggested value is the placeholder**, with a Tab keycap to accept it, not a separate chip with ×. +- **Attached context is a chip above the input**: the source's mark, the key at 600, the title truncated, on the brand wash, with a remove button. Attaching never sends. +- **A text input has no formatting toolbar.** Formatting comes from shortcuts and renders as you type: "bold italic etc non servono a niente". + +## Loading + +Loading never shows the empty state, not even for one frame. While the next content loads, keep the previous content or show a skeleton, and keep recently viewed content cached so going back is instant. In CodeLoom, switching threads once flashed "nothing here" before the thread appeared. + ## Announcing new things A new feature gets a small blue dot on its control, at most three at a time across the app, and the dot never animates. A release is announced by a small card in the bottom-left corner, once per release. A blocking "What's new" dialog was replaced, and so was a toast that said "Settings has 7 new things". @@ -108,7 +151,7 @@ A new feature gets a small blue dot on its control, at most three at a time acro - Text contrast is at least 4.5:1 below 18px. Icons, rings and control edges are at least 3:1. Both themes are checked. - Every control works from the keyboard. Pickers and cards open with Enter and Space. A list previews on focus just as it does on hover. -- There is one focus ring: 2px, offset 2px, shown on `:focus-visible`. +- There is one focus ring: 2px, offset 2px, shown on `:focus-visible`. In packed lists, trees and toolbars the ring sits inside the row and shows only for keyboard input, because an outer ring covers the row next to it. - Closing an overlay returns focus to whatever opened it. - On a phone, opening a dialog does not focus a text field, so the keyboard does not cover the dialog. - Every icon button and field has an accessible name. Colour is never the only signal. diff --git a/apps/docs/content/docs/design/space-and-shape.mdx b/apps/docs/content/docs/design/space-and-shape.mdx index f7624454..0d82434d 100644 --- a/apps/docs/content/docs/design/space-and-shape.mdx +++ b/apps/docs/content/docs/design/space-and-shape.mdx @@ -22,7 +22,7 @@ There are no lines between groups, so space alone shows what belongs together. T ### The shell -Everything sits 8px from the window edge and 8px from its neighbours. The header has no bar of its own. It is as tall as its controls (36px) and reads as the first row of islands, with its edges aligned to the islands below. +Everything sits 6px from the window edge and 6px from its neighbours, so the page between islands reads as a thin seam and the space goes inside the islands. The header has no bar of its own. It is as tall as its controls (36px) and reads as the first row of islands, with its edges aligned to the islands below. ## Radius follows nesting diff --git a/apps/docs/content/docs/design/typography.mdx b/apps/docs/content/docs/design/typography.mdx index c3aab619..44fbc907 100644 --- a/apps/docs/content/docs/design/typography.mdx +++ b/apps/docs/content/docs/design/typography.mdx @@ -40,6 +40,7 @@ A selected option may become bolder only if its box already reserves the bold wi ## Rules that keep text steady +- **A section heading is text, not a row.** It has no fill, no row height and no capitals: Label or Meta at 600 in secondary text, with a count in tertiary text at 400. In CodeLoom, a "Pinned" shelf drawn with a row's height and fill read as one more item, not as the start of a group. - **Tabular numbers.** Durations, sizes, zoom levels and timers use `font-variant-numeric: tabular-nums`, so the row does not shift while a value counts up. - **Truncate values, not labels.** A long value ends in an ellipsis inside a capped width, and the full text stays reachable through a tooltip or the accessible name. A label is never cut. diff --git a/apps/docs/export-manifest.json b/apps/docs/export-manifest.json index ca2397d3..1a83b9e0 100644 --- a/apps/docs/export-manifest.json +++ b/apps/docs/export-manifest.json @@ -240,7 +240,45 @@ "TableSize": "components/table#variants", "tableStyles": "components/table#tablestyles", "TableStyles": "components/table#tablestyles", - "TableVariants": "components/table#variants" + "TableVariants": "components/table#variants", + "HoverCard": "components/hover-card#hovercard", + "HoverCardClasses": "components/hover-card#anatomy", + "HoverCardContent": "components/hover-card#hovercardcontent", + "HoverCardContentProps": "components/hover-card#hovercardcontent", + "HoverCardPart": "components/hover-card#anatomy", + "hoverCardParts": "components/hover-card#anatomy", + "HoverCardProps": "components/hover-card#hovercard", + "hoverCardStyles": "components/hover-card#hovercardstyles", + "HoverCardStyles": "components/hover-card#hovercardstyles", + "HoverCardTrigger": "components/hover-card#hovercardtrigger", + "HoverCardTriggerProps": "components/hover-card#hovercardtrigger", + "Resizable": "components/resizable#resizable", + "ResizableClasses": "components/resizable#anatomy", + "ResizableHandle": "components/resizable#resizablehandle", + "ResizableHandleProps": "components/resizable#resizablehandle", + "ResizableOrientation": "components/resizable#resizable", + "ResizablePanel": "components/resizable#resizablepanel", + "ResizablePanelProps": "components/resizable#resizablepanel", + "ResizablePart": "components/resizable#anatomy", + "resizableParts": "components/resizable#anatomy", + "ResizableProps": "components/resizable#resizable", + "ResizableSize": "components/resizable#resizablestyles", + "resizableStyles": "components/resizable#resizablestyles", + "ResizableStyles": "components/resizable#resizablestyles", + "ResizeStrategy": "components/resizable#resizablestyles", + "Avatar": "components/avatar#avatar", + "avatarHue": "components/avatar#avatarhue", + "avatarInitials": "components/avatar#avatarinitials", + "AvatarProps": "components/avatar#avatar", + "avatarVars": "components/avatar#avatar", + "HoverCardItem": "components/hover-card#hovercarditem", + "HoverCardItemProps": "components/hover-card#hovercarditem", + "HoverCardList": "components/hover-card#hovercardlist", + "HoverCardListProps": "components/hover-card#hovercardlist", + "TooltipDefaults": "components/tooltip#defaults-for-a-whole-app", + "TooltipProvider": "components/tooltip#defaults-for-a-whole-app", + "HoverCardGroup": "components/hover-card#hovercardgroup", + "HoverCardGroupProps": "components/hover-card#hovercardgroup" }, "@codeui/kit/accordion/parts": { "AccordionClasses": "components/accordion#anatomy", @@ -1022,7 +1060,9 @@ }, "@codeui/kit/tooltip": { "Tooltip": "components/tooltip#tooltip", - "TooltipProps": "components/tooltip#tooltip" + "TooltipProps": "components/tooltip#tooltip", + "TooltipDefaults": "components/tooltip#defaults-for-a-whole-app", + "TooltipProvider": "components/tooltip#defaults-for-a-whole-app" }, "@codeui/kit/virtualized-listbox": { "VirtualizedListbox": "components/virtualized-listbox#virtualizedlistbox", @@ -1190,7 +1230,9 @@ "Root": "components/tooltip#styled-parts-api", "RootProps": "components/tooltip#styled-parts-api", "Trigger": "components/tooltip#styled-parts-api", - "TriggerProps": "components/tooltip#styled-parts-api" + "TriggerProps": "components/tooltip#styled-parts-api", + "Provider": "components/tooltip#defaults-for-a-whole-app", + "TooltipDefaults": "components/tooltip#defaults-for-a-whole-app" }, "@codeui/kit/table": { "Table": "components/table#table", @@ -1204,6 +1246,65 @@ "tableStyles": "components/table#tablestyles", "TableStyles": "components/table#tablestyles", "TableVariants": "components/table#variants" + }, + "@codeui/kit/hover-card": { + "HoverCard": "components/hover-card#hovercard", + "HoverCardClasses": "components/hover-card#anatomy", + "HoverCardContent": "components/hover-card#hovercardcontent", + "HoverCardContentProps": "components/hover-card#hovercardcontent", + "HoverCardPart": "components/hover-card#anatomy", + "hoverCardParts": "components/hover-card#anatomy", + "HoverCardProps": "components/hover-card#hovercard", + "hoverCardStyles": "components/hover-card#hovercardstyles", + "HoverCardStyles": "components/hover-card#hovercardstyles", + "HoverCardTrigger": "components/hover-card#hovercardtrigger", + "HoverCardTriggerProps": "components/hover-card#hovercardtrigger", + "HoverCardItem": "components/hover-card#hovercarditem", + "HoverCardItemProps": "components/hover-card#hovercarditem", + "HoverCardList": "components/hover-card#hovercardlist", + "HoverCardListProps": "components/hover-card#hovercardlist", + "HoverCardGroup": "components/hover-card#hovercardgroup", + "HoverCardGroupProps": "components/hover-card#hovercardgroup" + }, + "@codeui/kit/resizable": { + "Resizable": "components/resizable#resizable", + "ResizableClasses": "components/resizable#anatomy", + "ResizableHandle": "components/resizable#resizablehandle", + "ResizableHandleProps": "components/resizable#resizablehandle", + "ResizableOrientation": "components/resizable#resizable", + "ResizablePanel": "components/resizable#resizablepanel", + "ResizablePanelProps": "components/resizable#resizablepanel", + "ResizablePart": "components/resizable#anatomy", + "resizableParts": "components/resizable#anatomy", + "ResizableProps": "components/resizable#resizable", + "ResizableSize": "components/resizable#resizablestyles", + "resizableStyles": "components/resizable#resizablestyles", + "ResizableStyles": "components/resizable#resizablestyles", + "ResizeStrategy": "components/resizable#resizablestyles" + }, + "@codeui/kit/avatar": { + "Avatar": "components/avatar#avatar", + "avatarHue": "components/avatar#avatarhue", + "avatarInitials": "components/avatar#avatarinitials", + "AvatarProps": "components/avatar#avatar", + "avatarVars": "components/avatar#avatar" + }, + "@codeui/kit/avatar/parts": { + "AvatarClasses": "components/avatar#anatomy", + "avatarHue": "components/avatar#avatarhue", + "avatarInitials": "components/avatar#avatarinitials", + "AvatarPart": "components/avatar#anatomy", + "avatarParts": "components/avatar#anatomy", + "AvatarSize": "components/avatar#variants", + "avatarStyles": "components/avatar#avatarstyles", + "AvatarStyles": "components/avatar#avatarstyles", + "AvatarVariants": "components/avatar#variants", + "Fallback": "components/avatar#fallback", + "FallbackProps": "components/avatar#fallback", + "Image": "components/avatar#image", + "ImageProps": "components/avatar#image", + "Root": "components/avatar#root", + "RootProps": "components/avatar#root" } } } diff --git a/apps/docs/html-demos/avatar/basic.html b/apps/docs/html-demos/avatar/basic.html new file mode 100644 index 00000000..78c4e9cd --- /dev/null +++ b/apps/docs/html-demos/avatar/basic.html @@ -0,0 +1,12 @@ +
+ + + + + + + + + + +
diff --git a/apps/docs/html-demos/avatar/sizes.html b/apps/docs/html-demos/avatar/sizes.html new file mode 100644 index 00000000..46929cab --- /dev/null +++ b/apps/docs/html-demos/avatar/sizes.html @@ -0,0 +1,6 @@ +
+ + + + +
diff --git a/apps/docs/html-demos/hover-card/basic.html b/apps/docs/html-demos/hover-card/basic.html new file mode 100644 index 00000000..e3690b21 --- /dev/null +++ b/apps/docs/html-demos/hover-card/basic.html @@ -0,0 +1,7 @@ +
+ Fix flaky hydration test +
+ Fix flaky hydration test + Opened 2 hours ago · 3 subagents +
+
diff --git a/apps/docs/html-demos/hover-card/list.html b/apps/docs/html-demos/hover-card/list.html new file mode 100644 index 00000000..4e5405cc --- /dev/null +++ b/apps/docs/html-demos/hover-card/list.html @@ -0,0 +1,20 @@ +
+ Migrate the kit to Solid 2 +
    +
  • + + T-12 + Migrate the kit to Solid 2 +
  • +
  • + + T-13 + Port Popover and Tooltip to the new reactivity model +
  • +
  • + + T-15 + Keep keyboard opens free of motion +
  • +
+
diff --git a/apps/docs/html-demos/resizable/basic.html b/apps/docs/html-demos/resizable/basic.html new file mode 100644 index 00000000..d40820bd --- /dev/null +++ b/apps/docs/html-demos/resizable/basic.html @@ -0,0 +1,5 @@ +
+
Threads
+ +
Conversation
+
diff --git a/apps/docs/html-demos/resizable/vertical.html b/apps/docs/html-demos/resizable/vertical.html new file mode 100644 index 00000000..134ef951 --- /dev/null +++ b/apps/docs/html-demos/resizable/vertical.html @@ -0,0 +1,5 @@ +
+
Threads
+ +
Conversation
+
diff --git a/apps/examples/README.md b/apps/examples/README.md index 9be08ab6..1cb1a5d1 100644 --- a/apps/examples/README.md +++ b/apps/examples/README.md @@ -9,7 +9,7 @@ Solid apps made with `@codeui/kit`. The docs site lists them at `/examples` and | `theme-studio` | Theme Studio | A theme builder for CodeImage that exports a `createTheme` module | | `inspector` | Inspector playground | The [prosemirror-inspector](https://github.com/riccardoperra/prosemirror-devtools) invoice workbench, with plain ProseMirror | -Each app is a real consumer of the kit: Vite and `vite-plugin-solid`, as [Installation](../docs/content/docs/(kit)/installation.mdx) describes. The interface uses kit components and `--cui-*` tokens only, and follows [`packages/kit/DESIGN.md`](../../packages/kit/DESIGN.md). +Each app is a real consumer of the kit: Vite and `@solidjs/vite-plugin`, as [Installation](../docs/content/docs/(kit)/installation.mdx) describes. The interface uses kit components and `--cui-*` tokens only, and follows [`packages/kit/DESIGN.md`](../../packages/kit/DESIGN.md). ## Develop diff --git a/apps/examples/package.json b/apps/examples/package.json index ba20c687..9d9925d3 100644 --- a/apps/examples/package.json +++ b/apps/examples/package.json @@ -16,8 +16,8 @@ "@codeui/kit": "workspace:*", "@fontsource-variable/inter": "^5.2.8", "@fontsource-variable/jetbrains-mono": "^5.2.8", - "@kobalte/core": "^0.13.14", - "lucide-solid": "^1.74.0", + "@kobalte/core": "2.0.0", + "@lucide/solid": "1.77.0", "prosemirror-commands": "^1.7.2", "prosemirror-history": "^1.5.1", "prosemirror-inspector": "^0.3.0", @@ -27,11 +27,12 @@ "prosemirror-state": "^1.4.4", "prosemirror-transform": "^1.12.6", "prosemirror-view": "^1.42.9", - "solid-js": "^1.9.8" + "solid-js": "2.0.3", + "@solidjs/web": "2.0.3" }, "devDependencies": { "typescript": "^5.6.2", - "vite": "^8.0.0", - "vite-plugin-solid": "^2.11.12" + "vite": "8.3.8", + "@solidjs/vite-plugin": "3.0.1" } } diff --git a/apps/examples/src/dashboard/App.tsx b/apps/examples/src/dashboard/App.tsx index e166f9c6..489ac5c2 100644 --- a/apps/examples/src/dashboard/App.tsx +++ b/apps/examples/src/dashboard/App.tsx @@ -1,12 +1,13 @@ import { Button, type CommandItem, CommandMenu, createToaster, DropdownMenuItem, IconButton, Kbd, Sheet, Text, Toaster, Tooltip } from "@codeui/kit"; -import Activity from "lucide-solid/icons/activity"; -import ChartNoAxesColumn from "lucide-solid/icons/chart-no-axes-column"; -import Menu from "lucide-solid/icons/menu"; -import Search from "lucide-solid/icons/search"; -import SettingsIcon from "lucide-solid/icons/settings"; -import UserPlus from "lucide-solid/icons/user-plus"; -import Users from "lucide-solid/icons/users"; -import { createSignal, For, type JSX, Match, Show, Switch } from "solid-js"; +import Activity from "@lucide/solid/icons/activity"; +import ChartNoAxesColumn from "@lucide/solid/icons/chart-no-axes-column"; +import Menu from "@lucide/solid/icons/menu"; +import Search from "@lucide/solid/icons/search"; +import SettingsIcon from "@lucide/solid/icons/settings"; +import UserPlus from "@lucide/solid/icons/user-plus"; +import Users from "@lucide/solid/icons/users"; +import { createSignal, For, Match, Show, Switch } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { ExampleMenu, MadeWith } from "../shared/ExampleMenu"; import { modKey, onModK } from "../shared/hotkey"; import { createIsPhone } from "../shared/media"; @@ -145,7 +146,7 @@ export function App() { onModK(openCommands); return ( - +
@@ -234,6 +235,6 @@ export function App() { }} /> - + ); } diff --git a/apps/examples/src/dashboard/CustomerSheet.tsx b/apps/examples/src/dashboard/CustomerSheet.tsx index bb75f922..4aab9bf3 100644 --- a/apps/examples/src/dashboard/CustomerSheet.tsx +++ b/apps/examples/src/dashboard/CustomerSheet.tsx @@ -1,5 +1,5 @@ import { Badge, Button, SegmentedControl, SegmentedControlItem, Sheet, type SheetProps, Text } from "@codeui/kit"; -import { createEffect, createSignal, For, Show } from "solid-js"; +import { createMemo, For, Show } from "solid-js"; import { formatMoneyWhole, formatNumber } from "../shared/format"; import { createIsPhone } from "../shared/media"; import { createControlSize } from "../shared/size"; @@ -12,11 +12,9 @@ export function CustomerSheet() { const isPhone = createIsPhone(); const size = createControlSize(); // The last customer stays on screen while the sheet slides out. - const [customer, setCustomer] = createSignal(); - createEffect(() => { - const open = pulse.customers().find(c => c.id === pulse.openCustomer()); - if (open) setCustomer(open); - }); + const customer = createMemo(previous => + pulse.customers().find(c => c.id === pulse.openCustomer()) ?? previous, + ); const placement = (): Pick => (isPhone() ? { side: "bottom", draggable: true } : { side: "right" }); return ( diff --git a/apps/examples/src/dashboard/Customers.tsx b/apps/examples/src/dashboard/Customers.tsx index 4aaa31eb..95b9591d 100644 --- a/apps/examples/src/dashboard/Customers.tsx +++ b/apps/examples/src/dashboard/Customers.tsx @@ -22,8 +22,8 @@ import { TextField, Tooltip, } from "@codeui/kit"; -import Ellipsis from "lucide-solid/icons/ellipsis"; -import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from "solid-js"; +import Ellipsis from "@lucide/solid/icons/ellipsis"; +import { createEffect, createMemo, createSignal, For, onSettled, Show } from "solid-js"; import { formatMoneyWhole, formatNumber } from "../shared/format"; import { createIsPhone } from "../shared/media"; import { createControlSize } from "../shared/size"; @@ -52,10 +52,10 @@ export function Customers() { const [page, setPage] = createSignal(1); const [selected, setSelected] = createSignal([]); - onMount(() => { + onSettled(() => { if (pulse.customersLoaded()) return; const timer = setTimeout(() => pulse.setCustomersLoaded(true), 700); - onCleanup(() => clearTimeout(timer)); + return () => clearTimeout(timer); }); const sorted = createMemo(() => [...pulse.customers()].sort((a, b) => a.lastSeen - b.lastSeen)); @@ -68,8 +68,8 @@ export function Customers() { const pages = () => Math.max(1, Math.ceil(filtered().length / pageSize)); const rows = () => filtered().slice((page() - 1) * pageSize, page() * pageSize); // A new filter starts from the first page with nothing selected. An archive only steps back when its page empties. - createEffect(on([tab, query], () => (setPage(1), setSelected([])), { defer: true })); - createEffect(() => page() > pages() && setPage(pages())); + createEffect(() => [tab(), query()], () => { setPage(1); setSelected([]); }, { defer: true }); + createEffect(() => ({ page: page(), pages: pages() }), state => { if (state.page > state.pages) setPage(state.pages); }); const onPage = () => rows().filter(c => selected().includes(c.id)); const selectPage = (checked: boolean) => { diff --git a/apps/examples/src/dashboard/Overview.tsx b/apps/examples/src/dashboard/Overview.tsx index c20de361..53818462 100644 --- a/apps/examples/src/dashboard/Overview.tsx +++ b/apps/examples/src/dashboard/Overview.tsx @@ -1,5 +1,6 @@ import { SegmentedControl, SegmentedControlItem, Text } from "@codeui/kit"; -import { For, type JSX } from "solid-js"; +import { For } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { BarChart, BarList, ChartLegend, LineChart, type Series, Sparkline } from "../shared/charts"; import { formatChange, formatCompact, formatMoneyWhole, formatNumber, formatPercent } from "../shared/format"; import { createIsPhone } from "../shared/media"; diff --git a/apps/examples/src/dashboard/Settings.tsx b/apps/examples/src/dashboard/Settings.tsx index bcbb64e5..87bc2ae9 100644 --- a/apps/examples/src/dashboard/Settings.tsx +++ b/apps/examples/src/dashboard/Settings.tsx @@ -17,12 +17,13 @@ import { TextField, } from "@codeui/kit"; import * as D from "@codeui/kit/dialog/parts"; -import Bell from "lucide-solid/icons/bell"; -import ChevronDown from "lucide-solid/icons/chevron-down"; -import Palette from "lucide-solid/icons/palette"; -import SlidersHorizontal from "lucide-solid/icons/sliders-horizontal"; -import Users from "lucide-solid/icons/users"; -import { createEffect, createSignal, For, type JSX, Match, Show, Switch as SwitchMatch } from "solid-js"; +import Bell from "@lucide/solid/icons/bell"; +import ChevronDown from "@lucide/solid/icons/chevron-down"; +import Palette from "@lucide/solid/icons/palette"; +import SlidersHorizontal from "@lucide/solid/icons/sliders-horizontal"; +import Users from "@lucide/solid/icons/users"; +import { createMemo, createSignal, For, Match, Show, Switch as SwitchMatch } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { createIsPhone } from "../shared/media"; import { setTheme, theme, type Theme } from "../shared/theme"; import type { Role, WeekStart } from "./data"; @@ -48,8 +49,8 @@ export function Settings() { const isPhone = createIsPhone(); const [query, setQuery] = createSignal(""); // The last section stays on screen while the dialog closes. - const [shown, setShown] = createSignal("general"); - createEffect(() => pulse.section() && setShown(pulse.section()!)); + const shown = createMemo(previous => pulse.section() ?? previous ?? "general"); + const matches = () => { const text = query().trim().toLowerCase(); @@ -211,14 +212,14 @@ function Notifications() { <> - {control => pulse.setAlerts("digest", checked)} />} + {control => pulse.setAlerts(draft => { draft.digest = checked; })} />} {alert => ( - {control => pulse.setAlerts(alert.key, checked)} />} + {control => pulse.setAlerts(draft => { draft[alert.key] = checked; })} />} )} diff --git a/apps/examples/src/dashboard/main.tsx b/apps/examples/src/dashboard/main.tsx index 47a8fb7d..c943816b 100644 --- a/apps/examples/src/dashboard/main.tsx +++ b/apps/examples/src/dashboard/main.tsx @@ -1,5 +1,5 @@ import "../shared/base.css"; -import { render } from "solid-js/web"; +import { render } from "@solidjs/web"; import { App } from "./App"; import "./dashboard.css"; diff --git a/apps/examples/src/dashboard/pulse.ts b/apps/examples/src/dashboard/pulse.ts index 2ca7679e..4698354a 100644 --- a/apps/examples/src/dashboard/pulse.ts +++ b/apps/examples/src/dashboard/pulse.ts @@ -1,6 +1,6 @@ import type { ToastController } from "@codeui/kit"; import { createContext, createMemo, createSignal, useContext } from "solid-js"; -import { createStore } from "solid-js/store"; +import { createStore } from "solid-js"; import { bucketSeries, createBuckets, diff --git a/apps/examples/src/finance/App.tsx b/apps/examples/src/finance/App.tsx index 91b90dff..6af1e8e0 100644 --- a/apps/examples/src/finance/App.tsx +++ b/apps/examples/src/finance/App.tsx @@ -1,8 +1,8 @@ import { Button, type CommandItem, CommandMenu, createSelectOptions, createToaster, IconButton, Kbd, SegmentedControl, SegmentedControlItem, Select, Sheet, Text, Toaster } from "@codeui/kit"; -import PanelRight from "lucide-solid/icons/panel-right"; -import Plus from "lucide-solid/icons/plus"; -import Search from "lucide-solid/icons/search"; -import Wallet from "lucide-solid/icons/wallet"; +import PanelRight from "@lucide/solid/icons/panel-right"; +import Plus from "@lucide/solid/icons/plus"; +import Search from "@lucide/solid/icons/search"; +import Wallet from "@lucide/solid/icons/wallet"; import { createSignal, Show } from "solid-js"; import { ExampleMenu } from "../shared/ExampleMenu"; import { modKey, onModK } from "../shared/hotkey"; @@ -86,7 +86,7 @@ export function App() { ); return ( - +
@@ -173,6 +173,6 @@ export function App() { }} /> - + ); } diff --git a/apps/examples/src/finance/Planning.tsx b/apps/examples/src/finance/Planning.tsx index 613fbdc3..17a1c474 100644 --- a/apps/examples/src/finance/Planning.tsx +++ b/apps/examples/src/finance/Planning.tsx @@ -1,8 +1,9 @@ import { Accordion, type AccordionEntry, Badge, Button, Progress, Slider, Text } from "@codeui/kit"; -import CalendarClock from "lucide-solid/icons/calendar-clock"; -import PiggyBank from "lucide-solid/icons/piggy-bank"; -import Target from "lucide-solid/icons/target"; -import { createSignal, For, type JSX, Show } from "solid-js"; +import CalendarClock from "@lucide/solid/icons/calendar-clock"; +import PiggyBank from "@lucide/solid/icons/piggy-bank"; +import Target from "@lucide/solid/icons/target"; +import { createSignal, For, Show } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { MadeWith } from "../shared/ExampleMenu"; import { formatDay, formatMoneyWhole } from "../shared/format"; import { bills, budgets, goals, monthSpending, today } from "./data"; diff --git a/apps/examples/src/finance/Transactions.tsx b/apps/examples/src/finance/Transactions.tsx index 512c72b8..6199e3ec 100644 --- a/apps/examples/src/finance/Transactions.tsx +++ b/apps/examples/src/finance/Transactions.tsx @@ -16,8 +16,8 @@ import { Text, TextField, } from "@codeui/kit"; -import Ellipsis from "lucide-solid/icons/ellipsis"; -import { createEffect, createMemo, createSignal, For, on, Show } from "solid-js"; +import Ellipsis from "@lucide/solid/icons/ellipsis"; +import { createEffect, createMemo, createSignal, For, Show } from "solid-js"; import { formatDay, formatMoney } from "../shared/format"; import { createControlSize } from "../shared/size"; import { accounts, categories, type Category, type Transaction } from "./data"; @@ -47,8 +47,8 @@ export function Transactions() { const pages = () => Math.max(1, Math.ceil(filtered().length / pageSize)); const rows = () => filtered().slice((page() - 1) * pageSize, page() * pageSize); // A new filter or scope starts from the first page. A deletion only steps back when its page empties. - createEffect(on([query, category, ledger.account, ledger.period], () => setPage(1), { defer: true })); - createEffect(() => page() > pages() && setPage(pages())); + createEffect(() => [query(), category(), ledger.account(), ledger.period()], () => { setPage(1); }, { defer: true }); + createEffect(() => ({ page: page(), pages: pages() }), state => { if (state.page > state.pages) setPage(state.pages); }); const clear = () => { setQuery(""); diff --git a/apps/examples/src/finance/main.tsx b/apps/examples/src/finance/main.tsx index c17520c1..87d7a68c 100644 --- a/apps/examples/src/finance/main.tsx +++ b/apps/examples/src/finance/main.tsx @@ -1,5 +1,5 @@ import "../shared/base.css"; -import { render } from "solid-js/web"; +import { render } from "@solidjs/web"; import { App } from "./App"; import "./finance.css"; diff --git a/apps/examples/src/gallery/main.tsx b/apps/examples/src/gallery/main.tsx index 4c5a5e8a..d87ae19b 100644 --- a/apps/examples/src/gallery/main.tsx +++ b/apps/examples/src/gallery/main.tsx @@ -1,7 +1,7 @@ import "../shared/base.css"; import { Badge, Link, Text } from "@codeui/kit"; import { For } from "solid-js"; -import { render } from "solid-js/web"; +import { render } from "@solidjs/web"; import { docsUrl, examples } from "../shared/examples"; import "./gallery.css"; diff --git a/apps/examples/src/inspector/App.tsx b/apps/examples/src/inspector/App.tsx index 663eb233..3e6ddd81 100644 --- a/apps/examples/src/inspector/App.tsx +++ b/apps/examples/src/inspector/App.tsx @@ -1,9 +1,9 @@ import { Button, createToaster, DropdownMenuItem, IconButton, Kbd, SegmentedControl, SegmentedControlItem, Sheet, Text, Toaster } from "@codeui/kit"; -import FileCheck from "lucide-solid/icons/file-check"; -import PanelLeft from "lucide-solid/icons/panel-left"; -import RotateCcw from "lucide-solid/icons/rotate-ccw"; -import ScanSearch from "lucide-solid/icons/scan-search"; -import { For, lazy, onCleanup, onMount, Show } from "solid-js"; +import FileCheck from "@lucide/solid/icons/file-check"; +import PanelLeft from "@lucide/solid/icons/panel-left"; +import RotateCcw from "@lucide/solid/icons/rotate-ccw"; +import ScanSearch from "@lucide/solid/icons/scan-search"; +import { For, lazy, onSettled, Show } from "solid-js"; import { ExampleMenu } from "../shared/ExampleMenu"; import { modKey } from "../shared/hotkey"; import { createIsPhone } from "../shared/media"; @@ -33,7 +33,7 @@ export function App() { }; // ⌘⇧D or Ctrl+Shift+D, the shortcut the inspector's own playground uses. - onMount(() => { + onSettled(() => { const listener = (event: KeyboardEvent) => { if (event.key.toLowerCase() !== "d" || !event.shiftKey || !(event.metaKey || event.ctrlKey) || event.altKey) return; event.preventDefault(); @@ -41,7 +41,7 @@ export function App() { else bench.openInspector(false); }; window.addEventListener("keydown", listener, true); - onCleanup(() => window.removeEventListener("keydown", listener, true)); + return () => window.removeEventListener("keydown", listener, true); }); const number = () => readMeta(bench.doc()).number; @@ -49,7 +49,7 @@ export function App() { const toggleInspector = () => (bench.inspectorOpen() ? closeInspector() : bench.openInspector(true)); return ( - +
@@ -74,13 +74,13 @@ export function App() { bench.setSheetOpen(true)}> - + } > - @@ -128,6 +128,6 @@ export function App() { - + ); } diff --git a/apps/examples/src/inspector/InspectorDock.tsx b/apps/examples/src/inspector/InspectorDock.tsx index 0c27d9b6..dbb1a25e 100644 --- a/apps/examples/src/inspector/InspectorDock.tsx +++ b/apps/examples/src/inspector/InspectorDock.tsx @@ -1,11 +1,11 @@ import { IconButton, Text, Tooltip } from "@codeui/kit"; -import Maximize2 from "lucide-solid/icons/maximize-2"; -import Minimize2 from "lucide-solid/icons/minimize-2"; -import X from "lucide-solid/icons/x"; +import Maximize2 from "@lucide/solid/icons/maximize-2"; +import Minimize2 from "@lucide/solid/icons/minimize-2"; +import X from "@lucide/solid/icons/x"; // The default `standalone` entry returns an inactive handle unless NODE_ENV is "development". // This page is served from a production build, so it takes the entry that mounts everywhere. import { mountProseMirrorDevtools } from "prosemirror-inspector/standalone/production"; -import { createEffect, createSignal, onCleanup, onMount, Show } from "solid-js"; +import { createEffect, createSignal, onSettled, Show } from "solid-js"; import { createControlSize } from "../shared/size"; import { theme } from "../shared/theme"; import { useBench } from "./bench"; @@ -22,21 +22,21 @@ export default function InspectorDock(props: { onClose: () => void }) { let dock!: HTMLElement; let host!: HTMLDivElement; - onMount(() => { + const options = () => ({ store, theme: theme(), activePanel: bench.panel(), onActivePanelChange: bench.setPanel }); + let panel: ReturnType | undefined; + onSettled(() => { if (bench.takeDockFocus()) dock.focus(); - const options = () => ({ store, theme: theme(), activePanel: bench.panel(), onActivePanelChange: bench.setPanel }); - const panel = mountProseMirrorDevtools(host, options()); - createEffect(() => panel.update(options())); - onCleanup(() => panel.unmount()); + panel = mountProseMirrorDevtools(host, options()); + return () => panel?.unmount(); }); + createEffect(options, current => panel?.update(current)); return (
event.key === "Escape" && !event.defaultPrevented && props.onClose()} > diff --git a/apps/examples/src/inspector/Outline.tsx b/apps/examples/src/inspector/Outline.tsx index da881a16..9301ea69 100644 --- a/apps/examples/src/inspector/Outline.tsx +++ b/apps/examples/src/inspector/Outline.tsx @@ -1,5 +1,5 @@ import { Badge, Text } from "@codeui/kit"; -import TriangleAlert from "lucide-solid/icons/triangle-exclamation-point"; +import TriangleAlert from "@lucide/solid/icons/triangle-exclamation-point"; import { createMemo, For, Show } from "solid-js"; import { useBench } from "./bench"; import { revealOutlineEntry } from "./invoice/commands"; @@ -9,7 +9,7 @@ import { findOutlineEntry, type OutlineEntry, outlineEntryById, outlineSignature export function Outline(props: { onJump?: () => void }) { const bench = useBench(); // Positions move on every keystroke. The list only changes when a label or a count does. - const outline = createMemo(() => readOutline(bench.doc()), undefined, { equals: (a, b) => outlineSignature(a) === outlineSignature(b) }); + const outline = createMemo(() => readOutline(bench.doc()), { equals: (a, b) => outlineSignature(a) === outlineSignature(b) }); const current = createMemo(() => findOutlineEntry(readOutline(bench.doc()), bench.editor.state().selection.from)?.id); const jump = (id: string) => { @@ -26,8 +26,7 @@ export function Outline(props: { onJump?: () => void }) {
  • + + - - Consumer popover trigger - Popover body - Segment one Segment two diff --git a/examples/consumer-vite/entry.jsx b/examples/consumer-vite/entry.jsx index 53cb8963..e1757a1f 100644 --- a/examples/consumer-vite/entry.jsx +++ b/examples/consumer-vite/entry.jsx @@ -1,4 +1,4 @@ -import { hydrate, render } from "solid-js/web"; +import { hydrate, render } from "@solidjs/web"; import App from "./App"; const container = document.getElementById("app"); if (container.hasChildNodes()) { diff --git a/examples/consumer-vite/package.json b/examples/consumer-vite/package.json index 84dfb45f..fd8c6cc2 100644 --- a/examples/consumer-vite/package.json +++ b/examples/consumer-vite/package.json @@ -6,11 +6,12 @@ "build": "vite build" }, "dependencies": { - "solid-js": "1.9.19" + "solid-js": "2.0.3", + "@solidjs/web": "2.0.3" }, "devDependencies": { - "vite": "5.4.4", - "vite-plugin-solid": "2.10.2", + "vite": "8.3.8", + "@solidjs/vite-plugin": "3.0.1", "playwright": "1.65.1" } } diff --git a/examples/consumer-vite/vite.config.js b/examples/consumer-vite/vite.config.js index b3efef24..c469c1cf 100644 --- a/examples/consumer-vite/vite.config.js +++ b/examples/consumer-vite/vite.config.js @@ -1,3 +1,3 @@ import { defineConfig } from "vite"; -import solid from "vite-plugin-solid"; +import solid from "@solidjs/vite-plugin"; export default defineConfig({ plugins: [solid({ ssr: true })] }); diff --git a/examples/run-consumer-check.mjs b/examples/run-consumer-check.mjs index 143665f9..76902bfd 100644 --- a/examples/run-consumer-check.mjs +++ b/examples/run-consumer-check.mjs @@ -228,7 +228,9 @@ assert.equal(require("@codeui/inkstone/package.json").dependencies, undefined); ); report( "CSS-only dependency boundary", - !existsSync(join(cssRoot, "node_modules/solid-js")) && !scripts.length, + !existsSync(join(cssRoot, "node_modules/solid-js")) && + !existsSync(join(cssRoot, "node_modules/@solidjs/web")) && + !scripts.length, "styles installed without Solid and no scripts requested", ); const classes = JSON.parse( diff --git a/package.json b/package.json index 4df156ef..29a812a8 100644 --- a/package.json +++ b/package.json @@ -33,21 +33,22 @@ }, "devDependencies": { "@changesets/cli": "^2.27.8", + "@solidjs/vite-plugin": "3.0.1", + "@solidjs/web": "2.0.3", "@testing-library/jest-dom": "6.5.0", - "@types/node": "^22.5.4", - "@vitest/browser": "3.2.7", + "@types/node": "^24.19.2", + "esbuild": "^0.28.2", "jsdom": "20.0.3", + "pkg-pr-new": "0.0.94", "playwright": "1.56.1", "prettier": "3.3.3", "rollup": "^4.21.3", - "rollup-preset-solid": "^2.0.1", - "solid-js": "^1.9.8", + "solid-js": "2.0.3", "taze": "^0.16.8", "turbo": "^2.1.1", "typescript": "^5.6.2", - "vite": "^5.4.4", - "vite-plugin-solid": "2.11.8", - "vitest": "3.2.7" + "vite": "8.3.8", + "vitest": "4.1.12" }, "packageManager": "pnpm@10.34.9", "dependencies": { diff --git a/packages/docs-demos/package.json b/packages/docs-demos/package.json index 0eebba13..e979c3f3 100644 --- a/packages/docs-demos/package.json +++ b/packages/docs-demos/package.json @@ -20,13 +20,14 @@ "dependencies": { "@codeui/inkstone": "workspace:*", "@codeui/kit": "workspace:*", - "@kobalte/core": "^0.13.14", - "solid-js": "^1.9.8", + "@kobalte/core": "2.0.0", + "solid-js": "2.0.3", + "@solidjs/web": "2.0.3", "@codeui/styles": "workspace:*" }, "devDependencies": { "typescript": "^5.6.2", - "vite": "^8.0.0", - "vite-plugin-solid": "^2.11.12" + "vite": "8.3.8", + "@solidjs/vite-plugin": "3.0.1" } } diff --git a/packages/docs-demos/src/client.tsx b/packages/docs-demos/src/client.tsx index a70860b2..5d2ffe5a 100644 --- a/packages/docs-demos/src/client.tsx +++ b/packages/docs-demos/src/client.tsx @@ -1,5 +1,5 @@ import type { Component } from "solid-js"; -import { hydrate, render } from "solid-js/web"; +import { hydrate, render } from "@solidjs/web"; const demos = import.meta.glob<{ default: Component }>([ "./demos/*.tsx", diff --git a/packages/docs-demos/src/demos/avatar/anatomy.tsx b/packages/docs-demos/src/demos/avatar/anatomy.tsx new file mode 100644 index 00000000..1c51f8fc --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/anatomy.tsx @@ -0,0 +1,17 @@ +import { Avatar, Stack } from "@codeui/kit"; +import { picture } from "./people"; + +export default function AvatarAnatomy() { + return ( + + + + + ); +} diff --git a/packages/docs-demos/src/demos/avatar/basic.tsx b/packages/docs-demos/src/demos/avatar/basic.tsx new file mode 100644 index 00000000..5ab20f64 --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/basic.tsx @@ -0,0 +1,13 @@ +import { Avatar, Stack } from "@codeui/kit"; +import { picture } from "./people"; + +export default function AvatarBasic() { + return ( + + + + + + + ); +} diff --git a/packages/docs-demos/src/demos/avatar/hue.tsx b/packages/docs-demos/src/demos/avatar/hue.tsx new file mode 100644 index 00000000..8c02ffd8 --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/hue.tsx @@ -0,0 +1,28 @@ +import { Avatar, Stack, Text } from "@codeui/kit"; + +export default function AvatarHue() { + return ( + + + + + + Two people named Sam Lee: two ids, two hues. + + + + + + + One person who changed their name: one id, one hue. + + + + + + No id: a neutral fill. + + + + ); +} diff --git a/packages/docs-demos/src/demos/avatar/in-row.tsx b/packages/docs-demos/src/demos/avatar/in-row.tsx new file mode 100644 index 00000000..5d9fe79c --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/in-row.tsx @@ -0,0 +1,50 @@ +import { Avatar, Stack, Text } from "@codeui/kit"; +import { For } from "solid-js"; + +const reviews = [ + { + title: "Fix flaky hydration test", + owner: "Grace Hopper", + id: "user_grace", + time: "2h", + }, + { + title: "Port the tooltip to Solid 2", + owner: "Alan Turing", + id: "user_alan", + time: "5h", + }, + { title: "Draft the release notes", owner: undefined, id: undefined, time: "1d" }, +]; + +export default function AvatarInRow() { + return ( + + + {review => ( + + + {review.title} + + {review.time} + + + )} + + + ); +} diff --git a/packages/docs-demos/src/demos/avatar/people.ts b/packages/docs-demos/src/demos/avatar/people.ts new file mode 100644 index 00000000..5a3b4a30 --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/people.ts @@ -0,0 +1,6 @@ +/** A local picture, so the demos do not depend on the network. */ +export const picture = + "data:image/svg+xml;utf8," + + encodeURIComponent( + ``, + ); diff --git a/packages/docs-demos/src/demos/avatar/sizes.tsx b/packages/docs-demos/src/demos/avatar/sizes.tsx new file mode 100644 index 00000000..72d02635 --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/sizes.tsx @@ -0,0 +1,21 @@ +import { Avatar, Stack, Text } from "@codeui/kit"; +import { For } from "solid-js"; + +export default function AvatarSizes() { + return ( + + + {density => ( + + + {density} + + + {size => } + + + )} + + + ); +} diff --git a/packages/docs-demos/src/demos/avatar/states.tsx b/packages/docs-demos/src/demos/avatar/states.tsx new file mode 100644 index 00000000..b0a17c7f --- /dev/null +++ b/packages/docs-demos/src/demos/avatar/states.tsx @@ -0,0 +1,32 @@ +import { Avatar, Stack, Text } from "@codeui/kit"; +import { picture } from "./people"; + +export default function AvatarStates() { + return ( + + + + + Picture + + + + + + Picture failed + + + + + + Unassigned + + + + ); +} diff --git a/packages/docs-demos/src/demos/build-forms/export-form.tsx b/packages/docs-demos/src/demos/build-forms/export-form.tsx index f89a75a6..ec9aedd7 100644 --- a/packages/docs-demos/src/demos/build-forms/export-form.tsx +++ b/packages/docs-demos/src/demos/build-forms/export-form.tsx @@ -1,6 +1,6 @@ import { Button, NumberField, Stack, Text, TextArea, TextField } from "@codeui/kit"; import { createSignal, Show } from "solid-js"; -import { createStore } from "solid-js/store"; +import { createStore } from "solid-js"; type ExportSettings = { fileName: string; @@ -51,7 +51,7 @@ export default function ExportForm() { }; return ( -
    + setValues("fileName", value)} + onChange={value => setValues(draft => { draft.fileName = value; })} validationState={state("fileName")} errorMessage={errors().fileName} /> @@ -70,7 +70,7 @@ export default function ExportForm() { description="Optional. Shown under the image." options={{ autoResize: true }} value={values.caption} - onChange={value => setValues("caption", value)} + onChange={value => setValues(draft => { draft.caption = value; })} validationState={state("caption")} errorMessage={errors().caption} /> @@ -83,7 +83,7 @@ export default function ExportForm() { max={4096} step={160} value={values.width} - onChange={value => setValues("width", value)} + onChange={value => setValues(draft => { draft.width = value; })} validationState={state("width")} errorMessage={errors().width} /> diff --git a/packages/docs-demos/src/demos/build-settings/basic.tsx b/packages/docs-demos/src/demos/build-settings/basic.tsx index 9349a763..cd8f5a13 100644 --- a/packages/docs-demos/src/demos/build-settings/basic.tsx +++ b/packages/docs-demos/src/demos/build-settings/basic.tsx @@ -11,8 +11,9 @@ import { TextField, } from "@codeui/kit"; import * as Dialog from "@codeui/kit/dialog/parts"; -import { createMemo, createSignal, For, type JSX, Show } from "solid-js"; -import { createStore } from "solid-js/store"; +import { createMemo, createSignal, For, Show } from "solid-js"; +import { type JSX } from "@solidjs/web"; +import { createStore } from "solid-js"; import { DownloadIcon, FlaskIcon, InfoIcon, PaletteIcon, ResetIcon, SlidersIcon, SparkleIcon } from "./icons"; import "./settings.css"; @@ -51,17 +52,17 @@ export default function Settings() { // A segmented control is 84px per option in settings (Inkstone §6). const segmented = (key: Choice, options: [value: string, label: string][]) => (control: SettingsRowControlProps) => (
    - setValues(key, value)}> + setValues(draft => { draft[key] = value; })}> {([value, label]) => {label}}
    ); // Items are built per render, so a preview's DOM node is never shared between two rows. const cards = (key: Choice, items: () => OptionCardEntry[]) => (control: SettingsRowControlProps) => ( - setValues(key, value)} /> + setValues(draft => { draft[key] = value; })} /> ); const toggle = (key: Toggle) => (control: SettingsRowControlProps) => ( - setValues(key, checked)} /> + setValues(draft => { draft[key] = checked; })} /> ); const sections: Section[] = [ @@ -146,7 +147,12 @@ export default function Settings() { })) .filter(group => group.rows.length > 0); }); - const restore = () => experiments.forEach(key => setValues(key, defaults[key])); + const restore = () => setValues(draft => { + function reset(key: Key) { + draft[key] = defaults[key]; + } + experiments.forEach(reset); + }); let content: HTMLDivElement | undefined; return ( diff --git a/packages/docs-demos/src/demos/build-settings/icons.tsx b/packages/docs-demos/src/demos/build-settings/icons.tsx index 62b6ecd6..fcd6694d 100644 --- a/packages/docs-demos/src/demos/build-settings/icons.tsx +++ b/packages/docs-demos/src/demos/build-settings/icons.tsx @@ -1,4 +1,4 @@ -import type { JSX } from "solid-js"; +import type { JSX } from "@solidjs/web"; // 16px outline icons for the demos. An app uses its own icon set. function Icon(props: { children: JSX.Element; size?: number }) { diff --git a/packages/docs-demos/src/demos/dialog/export.tsx b/packages/docs-demos/src/demos/dialog/export.tsx index b1eaf896..7fb707ce 100644 --- a/packages/docs-demos/src/demos/dialog/export.tsx +++ b/packages/docs-demos/src/demos/dialog/export.tsx @@ -9,7 +9,8 @@ import { Stack, } from "@codeui/kit"; import * as Dialog from "@codeui/kit/dialog/parts"; -import { createSignal, For, type JSX } from "solid-js"; +import { createSignal, For } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { CopyIcon, DownloadIcon, ExternalIcon, LayersIcon, SlidersIcon, TextIcon } from "../build-settings/icons"; const formats = [ diff --git a/packages/docs-demos/src/demos/field-helpers/custom-field.tsx b/packages/docs-demos/src/demos/field-helpers/custom-field.tsx index 4374c56d..712fd586 100644 --- a/packages/docs-demos/src/demos/field-helpers/custom-field.tsx +++ b/packages/docs-demos/src/demos/field-helpers/custom-field.tsx @@ -7,7 +7,8 @@ import { fieldStyles, textFieldStyles, } from "@codeui/kit"; -import { createSignal, For, type JSX, Show } from "solid-js"; +import { createSignal, For, Show } from "solid-js"; +import { type JSX } from "@solidjs/web"; type ExportFormatFieldProps = BaseFieldProps & FieldWithErrorMessageSupport & { @@ -43,7 +44,7 @@ function ExportFormatField(props: ExportFormatFieldProps) { class={`${field.baseStyle()} ${textFieldStyles.textField}`} value={props.value} data-invalid={props.errorMessage ? "" : undefined} - aria-invalid={props.errorMessage ? true : undefined} + aria-invalid={props.errorMessage ? "true" : undefined} aria-describedby={describedBy()} onChange={event => props.onChange(event.currentTarget.value)} > diff --git a/packages/docs-demos/src/demos/hover-card/anatomy.tsx b/packages/docs-demos/src/demos/hover-card/anatomy.tsx new file mode 100644 index 00000000..9ed32919 --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/anatomy.tsx @@ -0,0 +1,39 @@ +import { createSignal } from "solid-js"; +import { + HoverCard, + HoverCardContent, + HoverCardItem, + HoverCardList, + HoverCardTrigger, + Link, + Text, +} from "@codeui/kit"; + +/** Open, with the card rendered under the trigger instead of on document.body. */ +export default function HoverCardAnatomy() { + const [content, setContent] = createSignal(); + return ( +
    + + + fetch-retry.ts + + + fetch-retry.ts + TypeScript, edited 2 hours ago + + + Retry failed requests with backoff + + + Cap the delay at 8 seconds + + + + +
    +
    + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/basic.tsx b/packages/docs-demos/src/demos/hover-card/basic.tsx new file mode 100644 index 00000000..ab090ff3 --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/basic.tsx @@ -0,0 +1,26 @@ +import { Badge, HoverCard, HoverCardContent, HoverCardTrigger, Link, Text } from "@codeui/kit"; + +export default function HoverCardBasic() { + return ( + + Ada shared{" "} + + + fetch-retry.ts + + +
    + fetch-retry.ts + Shared +
    + TypeScript · Vitesse Dark · JetBrains Mono + Retries a failed request three times with exponential backoff. + + Edited by Ada Lovelace 2 hours ago + +
    +
    {" "} + with the team. +
    + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/delays.tsx b/packages/docs-demos/src/demos/hover-card/delays.tsx new file mode 100644 index 00000000..ef74f780 --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/delays.tsx @@ -0,0 +1,26 @@ +import { HoverCard, HoverCardContent, HoverCardTrigger, Link } from "@codeui/kit"; + +export default function HoverCardDelays() { + return ( + <> + + + Default delay + + Opens after 500ms and closes 150ms after you leave. + + + + Short delay + + Opens after 200ms. + + + + Long close delay + + Stays 600ms after you leave the link and the card. + + + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/group.tsx b/packages/docs-demos/src/demos/hover-card/group.tsx new file mode 100644 index 00000000..7317b9e9 --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/group.tsx @@ -0,0 +1,51 @@ +import { For } from "solid-js"; +import { + HoverCard, + HoverCardContent, + HoverCardGroup, + HoverCardTrigger, + Link, + Text, +} from "@codeui/kit"; + +const columns = [ + { name: "Files", items: ["fetch-retry.ts", "hover-card.tsx", "tokens.css"] }, + { name: "People", items: ["Ada Lovelace", "Grace Hopper", "Alan Turing"] }, +]; + +export default function HoverCardGroups() { + return ( +
    + + {column => ( + +
    + {column.name} + + {item => ( + + + {item} + + + + {item}, from the {column.name.toLowerCase()} group. + + + + )} + +
    +
    + )} +
    +
    + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/list.tsx b/packages/docs-demos/src/demos/hover-card/list.tsx new file mode 100644 index 00000000..f4d4fb6c --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/list.tsx @@ -0,0 +1,92 @@ +import { + HoverCard, + HoverCardContent, + HoverCardItem, + HoverCardList, + HoverCardTrigger, + Link, + Text, +} from "@codeui/kit"; +import { For } from "solid-js"; + +// Each state changes shape as well as colour. A finished entry shows no icon. +const svg = { + viewBox: "0 0 16 16", + fill: "none", + stroke: "currentColor", + "stroke-width": "1.5", +}; +const states = { + todo: { + label: "To do", + icon: () => ( + + + + ), + }, + running: { + label: "Running", + icon: () => ( + + + + + ), + }, + done: { label: "Done", icon: () => undefined }, +}; + +const tasks = [ + { id: "T-12", title: "Migrate the kit to Solid 2", state: "running", depth: 0 }, + { + id: "T-13", + title: "Port Popover and Tooltip to the new reactivity model", + state: "done", + depth: 1, + }, + { + id: "T-14", + title: "Rebuild HoverCard on the Kobalte popover", + state: "running", + depth: 1, + }, + { id: "T-15", title: "Keep keyboard opens free of motion", state: "todo", depth: 2 }, + { + id: "T-16", + title: "Update the docs demos for every overlay", + state: "todo", + depth: 1, + }, +] as const; + +export default function HoverCardListDemo() { + return ( + + Codex is working on{" "} + + + 5 tasks + + + Migrate the kit to Solid 2 + + + {task => ( + + {task.title} + + )} + + + + + . + + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/placements.tsx b/packages/docs-demos/src/demos/hover-card/placements.tsx new file mode 100644 index 00000000..534daadc --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/placements.tsx @@ -0,0 +1,19 @@ +import { For } from "solid-js"; +import { HoverCard, HoverCardContent, HoverCardTrigger, Link } from "@codeui/kit"; + +const placements = ["top-start", "right-start", "bottom-start", "left-start"] as const; + +export default function HoverCardPlacements() { + return ( + + {placement => ( + + + {placement} + + The card opens on this side of the link. + + )} + + ); +} diff --git a/packages/docs-demos/src/demos/hover-card/shared.tsx b/packages/docs-demos/src/demos/hover-card/shared.tsx new file mode 100644 index 00000000..007afb56 --- /dev/null +++ b/packages/docs-demos/src/demos/hover-card/shared.tsx @@ -0,0 +1,44 @@ +import { For } from "solid-js"; +import { HoverCard, HoverCardContent, HoverCardTrigger, Link, Text } from "@codeui/kit"; + +const threads = [ + { + id: "fix-flaky", + title: "Fix flaky hydration test", + detail: "Codex · 2 hours ago · 3 subagents", + }, + { id: "port-popover", title: "Port Popover to Solid 2", detail: "Claude · yesterday" }, + { + id: "docs-demos", + title: "Update the docs demos", + detail: + "Codex · 3 days ago · waiting for review. Checks every story in dark and light.", + }, +]; + +export default function HoverCardShared() { + return ( +
    + + {thread => ( + + + {thread.title} + + + {thread.title} + {thread.detail} + + + )} + +
    + ); +} diff --git a/packages/docs-demos/src/demos/kbd/platform.tsx b/packages/docs-demos/src/demos/kbd/platform.tsx index a95b69a3..3c8b4924 100644 --- a/packages/docs-demos/src/demos/kbd/platform.tsx +++ b/packages/docs-demos/src/demos/kbd/platform.tsx @@ -1,5 +1,5 @@ import { Kbd, Stack, Text } from "@codeui/kit"; -import { createSignal, onMount, Show } from "solid-js"; +import { createSignal, onSettled, Show } from "solid-js"; /** True on macOS, iOS and iPadOS. Reads the browser, so call it only after mount. */ function isApplePlatform() { @@ -9,7 +9,7 @@ function isApplePlatform() { export default function KbdPlatform() { // The server cannot know the platform. Render Ctrl first, then switch after hydration. const [apple, setApple] = createSignal(false); - onMount(() => setApple(isApplePlatform())); + onSettled(() => { setApple(isApplePlatform()); }); return ( diff --git a/packages/docs-demos/src/demos/motion/durations.tsx b/packages/docs-demos/src/demos/motion/durations.tsx index a9268b2d..6a9c2908 100644 --- a/packages/docs-demos/src/demos/motion/durations.tsx +++ b/packages/docs-demos/src/demos/motion/durations.tsx @@ -1,12 +1,12 @@ import { Button } from "@codeui/kit"; -import { For, createSignal, onMount } from "solid-js"; +import { For, createSignal, onSettled } from "solid-js"; const durations = ["fast", "normal", "panel", "slow"] as const; export default function MotionDurations() { const [moved, setMoved] = createSignal(false); const [reduced, setReduced] = createSignal(false); - onMount(() => setReduced(matchMedia("(prefers-reduced-motion: reduce)").matches)); + onSettled(() => { setReduced(matchMedia("(prefers-reduced-motion: reduce)").matches); }); return (
    diff --git a/packages/docs-demos/src/demos/resizable/anatomy.tsx b/packages/docs-demos/src/demos/resizable/anatomy.tsx new file mode 100644 index 00000000..0f6fabd7 --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/anatomy.tsx @@ -0,0 +1,15 @@ +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +export default function ResizableAnatomy() { + return ( + + + Panel + + + + Panel + + + ); +} diff --git a/packages/docs-demos/src/demos/resizable/basic.tsx b/packages/docs-demos/src/demos/resizable/basic.tsx new file mode 100644 index 00000000..2e0d3354 --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/basic.tsx @@ -0,0 +1,24 @@ +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +/** Padding goes on a child: on the panel it would add to the size Kobalte sets. */ +const pane = { padding: "var(--cui-space-4)" }; + +export default function ResizableBasic() { + return ( + + + Editor + + + + Preview + + + ); +} diff --git a/packages/docs-demos/src/demos/resizable/collapsible.tsx b/packages/docs-demos/src/demos/resizable/collapsible.tsx new file mode 100644 index 00000000..a3a6ed5a --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/collapsible.tsx @@ -0,0 +1,39 @@ +import { createSignal } from "solid-js"; +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +/** Padding goes on a child: on the panel it would add to the size Kobalte sets. */ +const pane = { padding: "var(--cui-space-4)" }; + +export default function ResizableCollapsible() { + const [collapsed, setCollapsed] = createSignal(false); + return ( +
    + + + + fetch-retry.ts + + + + setCollapsed(true)} + onExpand={() => setCollapsed(false)} + > + + Settings + + + + {collapsed() ? "Settings is collapsed." : "Settings is open."} +
    + ); +} diff --git a/packages/docs-demos/src/demos/resizable/islands.tsx b/packages/docs-demos/src/demos/resizable/islands.tsx new file mode 100644 index 00000000..68d8a921 --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/islands.tsx @@ -0,0 +1,32 @@ +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +/** Each island leaves 4px on the handle side, so two islands sit 8px apart and the handle fills the gap. */ +const island = (side: "start" | "end") => ({ + height: "100%", + "box-sizing": "border-box" as const, + padding: "var(--cui-space-4)", + [`margin-inline-${side}`]: "4px", + background: "var(--cui-surface-canvas)", + "border-radius": "var(--cui-radius-command)", +}); + +export default function ResizableIslands() { + return ( + + + + fetch-retry.ts + + + + + + Side panel + + + + ); +} diff --git a/packages/docs-demos/src/demos/resizable/sidebar.tsx b/packages/docs-demos/src/demos/resizable/sidebar.tsx new file mode 100644 index 00000000..3e7ab64e --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/sidebar.tsx @@ -0,0 +1,24 @@ +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +/** Padding goes on a child: on the panel it would add to the size Kobalte sets. */ +const pane = { padding: "var(--cui-space-4)" }; + +export default function ResizableSidebar() { + return ( + + + Snippets + + + + fetch-retry.ts + + + ); +} diff --git a/packages/docs-demos/src/demos/resizable/vertical.tsx b/packages/docs-demos/src/demos/resizable/vertical.tsx new file mode 100644 index 00000000..6579a264 --- /dev/null +++ b/packages/docs-demos/src/demos/resizable/vertical.tsx @@ -0,0 +1,25 @@ +import { Resizable, ResizableHandle, ResizablePanel, Text } from "@codeui/kit"; + +/** Padding goes on a child: on the panel it would add to the size Kobalte sets. */ +const pane = { padding: "var(--cui-space-4)" }; + +export default function ResizableVertical() { + return ( + + + fetch-retry.ts + + + + Console + + + ); +} diff --git a/packages/docs-demos/src/demos/run-commands/async.tsx b/packages/docs-demos/src/demos/run-commands/async.tsx index 8934c3a9..1e0e8368 100644 --- a/packages/docs-demos/src/demos/run-commands/async.tsx +++ b/packages/docs-demos/src/demos/run-commands/async.tsx @@ -1,4 +1,4 @@ -import { createEffect, createSignal, onCleanup } from "solid-js"; +import { createEffect, createSignal } from "solid-js"; import { Button, type CommandItem, CommandMenu } from "@codeui/kit"; const library = [ @@ -38,9 +38,8 @@ export default function AsyncDemo() { const [loading, setLoading] = createSignal(false); const [opened, setOpened] = createSignal(""); - createEffect(() => { - if (!open()) return; - const current = query(); + createEffect(() => open() ? query() : undefined, current => { + if (current === undefined) return; let stale = false; setLoading(true); // Wait for a pause in typing before the request. @@ -51,10 +50,10 @@ export default function AsyncDemo() { setLoading(false); }); }, 150); - onCleanup(() => { + return () => { stale = true; clearTimeout(timer); - }); + }; }); return ( diff --git a/packages/docs-demos/src/demos/run-commands/shortcut.tsx b/packages/docs-demos/src/demos/run-commands/shortcut.tsx index 2a1cd54a..ff23079c 100644 --- a/packages/docs-demos/src/demos/run-commands/shortcut.tsx +++ b/packages/docs-demos/src/demos/run-commands/shortcut.tsx @@ -1,4 +1,4 @@ -import { createSignal, onCleanup, onMount } from "solid-js"; +import { createSignal, onSettled } from "solid-js"; import { type CommandItem, CommandMenu, Kbd } from "@codeui/kit"; const commands: CommandItem[] = [ @@ -15,7 +15,7 @@ export default function ShortcutDemo() { // the demo acts only while the menu is open or focus is in the demo, and listens in the capture // phase to stop the event before the search sees it. let root!: HTMLDivElement; - onMount(() => { + onSettled(() => { const onKeyDown = (event: KeyboardEvent) => { if (event.isComposing || event.repeat) return; if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== "k") return; @@ -25,13 +25,13 @@ export default function ShortcutDemo() { setOpen(value => !value); }; window.addEventListener("keydown", onKeyDown, true); - onCleanup(() => window.removeEventListener("keydown", onKeyDown, true)); + return () => window.removeEventListener("keydown", onKeyDown, true); }); return (

    diff --git a/packages/docs-demos/src/demos/show-notifications/app-setup.tsx b/packages/docs-demos/src/demos/show-notifications/app-setup.tsx index 44586859..cd5b2e30 100644 --- a/packages/docs-demos/src/demos/show-notifications/app-setup.tsx +++ b/packages/docs-demos/src/demos/show-notifications/app-setup.tsx @@ -1,5 +1,6 @@ import { Button, createToaster, Toaster, type ToastController } from "@codeui/kit"; -import { createContext, type JSX, useContext } from "solid-js"; +import { createContext, useContext } from "solid-js"; +import { type JSX } from "@solidjs/web"; const NotificationsContext = createContext(); @@ -13,10 +14,10 @@ export function useNotifications() { function NotificationsProvider(props: { children: JSX.Element }) { const notifications = createToaster(); return ( - + {props.children} - + ); } diff --git a/packages/docs-demos/src/demos/showcase/icon-buttons.tsx b/packages/docs-demos/src/demos/showcase/icon-buttons.tsx index 2fd19b70..ed2457b1 100644 --- a/packages/docs-demos/src/demos/showcase/icon-buttons.tsx +++ b/packages/docs-demos/src/demos/showcase/icon-buttons.tsx @@ -1,5 +1,6 @@ import { IconButton, Tooltip } from "@codeui/kit"; -import { For, type JSX } from "solid-js"; +import { For } from "solid-js"; +import { type JSX } from "@solidjs/web"; import { ArchiveIcon, CopyIcon, DownloadIcon, MoreIcon, PinIcon, ShareIcon, TrashIcon } from "./icons"; import "./showcase.css"; diff --git a/packages/docs-demos/src/demos/showcase/icons.tsx b/packages/docs-demos/src/demos/showcase/icons.tsx index a3fdc8b0..945f3466 100644 --- a/packages/docs-demos/src/demos/showcase/icons.tsx +++ b/packages/docs-demos/src/demos/showcase/icons.tsx @@ -1,4 +1,4 @@ -import type { JSX } from "solid-js"; +import type { JSX } from "@solidjs/web"; // 16px outline icons for the homepage vignettes. An app brings its own icon set. function Icon(props: { children: JSX.Element }) { diff --git a/packages/docs-demos/src/demos/showcase/progress.tsx b/packages/docs-demos/src/demos/showcase/progress.tsx index ffe95f09..b8a02f53 100644 --- a/packages/docs-demos/src/demos/showcase/progress.tsx +++ b/packages/docs-demos/src/demos/showcase/progress.tsx @@ -21,7 +21,7 @@ export default function Upload() { return (

    `${value} of ${max}`} /> -
    +
    setLoading(!loading())}> {loading() ? "Reveal snippet" : "Load again"} -
    +
    Gradient editor.tsx diff --git a/packages/docs-demos/src/demos/text-field/input-attributes.tsx b/packages/docs-demos/src/demos/text-field/input-attributes.tsx index fb4cce06..cc8ee477 100644 --- a/packages/docs-demos/src/demos/text-field/input-attributes.tsx +++ b/packages/docs-demos/src/demos/text-field/input-attributes.tsx @@ -9,7 +9,7 @@ export default function TextFieldInputAttributes() { autocomplete="email" inputmode="email" spellcheck={false} - maxLength={120} + maxlength={120} placeholder="you@example.com" />
    diff --git a/packages/docs-demos/src/demos/toast/anatomy.tsx b/packages/docs-demos/src/demos/toast/anatomy.tsx index 2e7e780d..c1b91b0d 100644 --- a/packages/docs-demos/src/demos/toast/anatomy.tsx +++ b/packages/docs-demos/src/demos/toast/anatomy.tsx @@ -1,12 +1,12 @@ import { icons } from "@codeui/kit"; import * as T from "@codeui/kit/toast/parts"; import { toaster } from "@kobalte/core/toast"; -import { createUniqueId, onCleanup, onMount } from "solid-js"; +import { createUniqueId, onSettled } from "solid-js"; /** One toast that stays, in a region drawn inside the figure instead of at a viewport edge. */ export default function ToastAnatomy() { const region = `toast-anatomy-${createUniqueId()}`; - onMount(() => { + onSettled(() => { const id = toaster.show( props => ( @@ -24,7 +24,7 @@ export default function ToastAnatomy() { ), { region }, ); - onCleanup(() => toaster.dismiss(id)); + return () => toaster.dismiss(id); }); return (
    diff --git a/packages/docs-demos/src/demos/tokens/token-table.tsx b/packages/docs-demos/src/demos/tokens/token-table.tsx index 1eeb1aa9..904153e0 100644 --- a/packages/docs-demos/src/demos/tokens/token-table.tsx +++ b/packages/docs-demos/src/demos/tokens/token-table.tsx @@ -1,4 +1,5 @@ -import { For, Show, createSignal, onMount, type JSX } from "solid-js"; +import { For, Show, createSignal, onSettled } from "solid-js"; +import { type JSX } from "@solidjs/web"; /** How a row previews its token. */ export type SwatchKind = "color" | "shadow" | "radius" | "length" | "font-size" | "value"; @@ -129,7 +130,7 @@ export function TokenTable(props: { let dark!: HTMLDivElement; let light!: HTMLDivElement; let plain!: HTMLDivElement; - onMount(() => { + onSettled(() => { const read = (el: HTMLElement, mode: string) => { const style = getComputedStyle(el); return Object.fromEntries( diff --git a/packages/docs-demos/src/props/accordion.ts b/packages/docs-demos/src/props/accordion.ts index 1598f874..9728ca16 100644 --- a/packages/docs-demos/src/props/accordion.ts +++ b/packages/docs-demos/src/props/accordion.ts @@ -1,6 +1,6 @@ import type { AccordionProps } from "@codeui/kit"; import type * as Parts from "@codeui/kit/accordion/parts"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; export type Accordion = Pick; diff --git a/packages/docs-demos/src/props/avatar.ts b/packages/docs-demos/src/props/avatar.ts new file mode 100644 index 00000000..0d422a2d --- /dev/null +++ b/packages/docs-demos/src/props/avatar.ts @@ -0,0 +1,65 @@ +import type { AvatarProps } from "@codeui/kit"; +import type { RootProps } from "@codeui/kit/avatar/parts"; +import type { PropNotes } from "./notes"; + +/** Props that Avatar adds. Every other prop goes to the root span. */ +export type Avatar = Pick< + AvatarProps, + | "name" + | "identifier" + | "src" + | "initials" + | "size" + | "unassigned" + | "tooltip" + | "classes" + | "class" +>; + +/** Props of the Root part from @codeui/kit/avatar/parts. */ +export type AvatarRoot = Pick; + +export const notes = { + Avatar: { + name: { + description: + "The person's name: the accessible name and the tooltip. Initials come from it.", + }, + identifier: { + description: + "A stable id, such as a user id. The fill hue comes from it. Without it the fill is neutral.", + }, + src: { + description: + "URL of the picture. The initials show while it is missing or when it fails to load.", + }, + initials: { description: "Overrides the initials taken from name." }, + size: { + default: '"xs"', + description: + "Height on the shared control scale: xs, sm, md or lg. Follows density.", + }, + unassigned: { + default: "false", + description: "An empty dashed circle, named Unassigned unless name is set.", + }, + tooltip: { + default: "true", + description: "Shows the name in the kit Tooltip on hover.", + }, + classes: { description: "Classes keyed by part: root, image and fallback." }, + class: { description: "Class merged after the kit styles on the root." }, + }, + AvatarRoot: { + size: { default: '"xs"', description: "Height on the shared control scale." }, + unassigned: { + default: "false", + description: "Sets data-unassigned: the dashed empty circle.", + }, + hue: { + description: + "Fill hue in degrees. Without it the fill is neutral. Use avatarHue(id).", + }, + class: { description: "Class merged after the kit styles." }, + }, +} satisfies PropNotes; diff --git a/packages/docs-demos/src/props/button.ts b/packages/docs-demos/src/props/button.ts index 9f0a7ba4..c4b1f654 100644 --- a/packages/docs-demos/src/props/button.ts +++ b/packages/docs-demos/src/props/button.ts @@ -1,4 +1,4 @@ -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { Button as KitButton, ButtonProps } from "@codeui/kit"; import type { PropNotes } from "./notes"; diff --git a/packages/docs-demos/src/props/dropdown-menu.ts b/packages/docs-demos/src/props/dropdown-menu.ts index c5a0d65f..3dbea3df 100644 --- a/packages/docs-demos/src/props/dropdown-menu.ts +++ b/packages/docs-demos/src/props/dropdown-menu.ts @@ -1,4 +1,4 @@ -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { DropdownMenu as Root, DropdownMenuItem as Item, DropdownSubMenu as Sub, DropdownSubMenuTrigger as SubTrigger } from "@codeui/kit"; import type { PropNotes } from "./notes"; diff --git a/packages/docs-demos/src/props/hover-card.ts b/packages/docs-demos/src/props/hover-card.ts new file mode 100644 index 00000000..a2c79cd5 --- /dev/null +++ b/packages/docs-demos/src/props/hover-card.ts @@ -0,0 +1,120 @@ +import type { + HoverCardContentProps, + HoverCardGroupProps, + HoverCardItemProps, + HoverCardProps, +} from "@codeui/kit"; +import type { PropNotes } from "./notes"; + +/** Props that HoverCard adds or changes on Kobalte's popover root. */ +export type HoverCard = Pick< + HoverCardProps, + "openDelay" | "closeDelay" | "ignoreSafeArea" | "shared" +>; + +/** Props of the group that gives its hover cards a surface of their own. */ +export type HoverCardGroup = Pick; + +/** Kobalte popover root options that change behavior. The kit sets the gutter default. */ +export type HoverCardInherited = Pick< + HoverCardProps, + | "open" + | "defaultOpen" + | "onOpenChange" + | "placement" + | "gutter" + | "shift" + | "forceMount" +>; + +/** Props that HoverCardContent adds on top of Kobalte's popover content. */ +export type HoverCardContent = Pick; + +/** Kobalte content options that HoverCardContent passes through. */ +export type HoverCardContentInherited = Pick< + HoverCardContentProps, + "onEscapeKeyDown" | "onPointerDownOutside" +>; + +/** Props of one line in a HoverCardList. */ +export type HoverCardItem = Pick< + HoverCardItemProps, + "icon" | "iconLabel" | "identifier" | "depth" | "children" | "classes" +>; + +export const notes = { + HoverCard: { + openDelay: { + default: "500", + description: "Milliseconds of hover or focus before the card opens.", + }, + closeDelay: { + default: "150", + description: + "Milliseconds before it closes after the pointer leaves the trigger and the card.", + }, + ignoreSafeArea: { + default: "false", + description: "Closes as soon as the pointer leaves, even on its way to the card.", + }, + shared: { + default: "true", + description: + "Shares one card with the page or the nearest HoverCardGroup. With false, the card has its own.", + }, + }, + HoverCardGroup: { + skipDelayDuration: { + default: "400", + description: + "Milliseconds after a card of the group closes during which the next one opens at once.", + }, + }, + HoverCardInherited: { + open: { description: "Controlled open state." }, + defaultOpen: { description: "Open state on first render, when uncontrolled." }, + onOpenChange: { description: "Called when the card opens or closes." }, + placement: { + default: '"right-start"', + description: + "Side and alignment of the card against the trigger. It flips when there is no room.", + }, + gutter: { + default: "6", + description: "Distance between the trigger and the card, in pixels.", + }, + shift: { default: "0", description: "Offset along the trigger edge, in pixels." }, + forceMount: { + description: "Keeps the card in the DOM while it is closed. The card gets a surface of its own.", + }, + }, + HoverCardContent: { + mount: { default: "document.body", description: "Node the card is portaled into." }, + classes: { description: "Classes for the content, keyed by part name." }, + class: { description: "Class merged after the kit styles on the card." }, + }, + HoverCardContentInherited: { + onEscapeKeyDown: { + description: "Called on Escape. Call preventDefault to keep the card open.", + }, + onPointerDownOutside: { description: "Called on a pointer down outside the card." }, + }, + HoverCardItem: { + icon: { + description: "State icon, 16px. The slot stays empty without it, so entries align.", + }, + iconLabel: { + description: "Names the state, such as Running. Without it the icon is decorative.", + }, + identifier: { description: "Short id before the title, in secondary text." }, + depth: { + default: "0", + description: + "Nesting level. Each level indents by --cui-hovercard-item-indent (16px).", + }, + children: { description: "The title, on one line, truncated." }, + classes: { + description: "Classes keyed by part: item, itemIcon, itemId and itemTitle.", + }, + }, +} satisfies PropNotes; diff --git a/packages/docs-demos/src/props/icon-button.ts b/packages/docs-demos/src/props/icon-button.ts index 20eea00b..a4490454 100644 --- a/packages/docs-demos/src/props/icon-button.ts +++ b/packages/docs-demos/src/props/icon-button.ts @@ -1,5 +1,5 @@ import type { IconButton } from "@codeui/kit"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; export type IconButton = Pick, "variant" | "size" | "ghost" | "pill" | "block" | "loading" | "class" | "aria-label">; diff --git a/packages/docs-demos/src/props/link.ts b/packages/docs-demos/src/props/link.ts index 3d96cd77..d41f253d 100644 --- a/packages/docs-demos/src/props/link.ts +++ b/packages/docs-demos/src/props/link.ts @@ -1,5 +1,5 @@ import type { Link } from "@codeui/kit"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; export type Link = Pick, "variant" | "class">; diff --git a/packages/docs-demos/src/props/number-field.ts b/packages/docs-demos/src/props/number-field.ts index 3f4ba628..0942bba2 100644 --- a/packages/docs-demos/src/props/number-field.ts +++ b/packages/docs-demos/src/props/number-field.ts @@ -1,5 +1,5 @@ import type { NumberFieldLabel, NumberFieldProps } from "@codeui/kit"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; /** Props that NumberField adds or changes on top of Kobalte's text field root. */ diff --git a/packages/docs-demos/src/props/resizable.ts b/packages/docs-demos/src/props/resizable.ts new file mode 100644 index 00000000..c652dae8 --- /dev/null +++ b/packages/docs-demos/src/props/resizable.ts @@ -0,0 +1,77 @@ +import type { ResizableHandleProps, ResizablePanelProps, ResizableProps } from "@codeui/kit"; +import type { PropNotes } from "./notes"; + +/** Kobalte resizable root options, plus the kit classes. */ +export type Resizable = Pick< + ResizableProps, + "orientation" | "sizes" | "onSizesChange" | "initialSizes" | "keyboardDelta" | "handleCursorStyle" | "classes" | "class" +>; + +/** Kobalte panel options, plus the kit classes. */ +export type ResizablePanel = Pick< + ResizablePanelProps, + | "initialSize" + | "minSize" + | "maxSize" + | "collapsible" + | "collapsedSize" + | "collapseThreshold" + | "onResize" + | "onCollapse" + | "onExpand" + | "panelId" + | "classes" + | "class" +>; + +/** Kobalte handle options, plus the kit classes. */ +export type ResizableHandle = Pick< + ResizableHandleProps, + | "altKey" + | "startIntersection" + | "endIntersection" + | "onHandleDragStart" + | "onHandleDrag" + | "onHandleDragEnd" + | "disabled" + | "classes" + | "class" +>; + +export const notes = { + Resizable: { + orientation: { default: '"horizontal"', description: "Lays the panels out in a row or a column." }, + sizes: { description: "Controlled panel sizes, as fractions of the root that add up to 1." }, + onSizesChange: { description: "Called with the new fractions when a panel resizes." }, + initialSizes: { description: "Panel sizes on first render, by index. A panel's own initialSize wins." }, + keyboardDelta: { default: "0.1", description: 'Step of one arrow key press, as a fraction or a "40px" string.' }, + handleCursorStyle: { default: "true", description: "Sets the resize cursor on the whole page while a handle is hovered or dragged." }, + classes: { description: "Class for the root." }, + class: { description: "Class merged on the root." }, + }, + ResizablePanel: { + initialSize: { description: 'Size on first render, as a fraction or a "240px" string. Without it, the panel takes the space the others leave.' }, + minSize: { default: "0", description: 'Smallest size, as a fraction or a "200px" string.' }, + maxSize: { default: "1", description: 'Largest size, as a fraction or a "360px" string.' }, + collapsible: { default: "false", description: "Lets the panel collapse to collapsedSize." }, + collapsedSize: { default: "0", description: "Size of the collapsed panel." }, + collapseThreshold: { default: "0.05", description: "How far past minSize a drag must go to collapse the panel." }, + onResize: { description: "Called with the new size as a fraction." }, + onCollapse: { description: "Called when the panel collapses." }, + onExpand: { description: "Called when the panel expands." }, + panelId: { default: "createUniqueId()", description: "Panel id. The handle points at it with aria-controls." }, + classes: { description: "Class for the panel." }, + class: { description: "Class merged on the panel." }, + }, + ResizableHandle: { + altKey: { default: "true", description: 'With Alt held, resizes the panels on both sides of the next panel. "only" always does.' }, + startIntersection: { description: "A crossing handle at the start edge, to resize both directions at once." }, + endIntersection: { description: "A crossing handle at the end edge, to resize both directions at once." }, + onHandleDragStart: { description: "Called on pointer down. Call preventDefault to stop the drag." }, + onHandleDrag: { description: "Called while the handle moves." }, + onHandleDragEnd: { description: "Called when the drag ends." }, + disabled: { default: "false", description: "Stops dragging and keyboard resizing." }, + classes: { description: "Class for the handle." }, + class: { description: "Class merged after the kit styles on the handle." }, + }, +} satisfies PropNotes; diff --git a/packages/docs-demos/src/props/select.ts b/packages/docs-demos/src/props/select.ts index 29757c84..5caae778 100644 --- a/packages/docs-demos/src/props/select.ts +++ b/packages/docs-demos/src/props/select.ts @@ -1,4 +1,4 @@ -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { Select as KitSelect } from "@codeui/kit"; import type { PropNotes } from "./notes"; diff --git a/packages/docs-demos/src/props/sheet.ts b/packages/docs-demos/src/props/sheet.ts index cf198c42..51233ebb 100644 --- a/packages/docs-demos/src/props/sheet.ts +++ b/packages/docs-demos/src/props/sheet.ts @@ -1,6 +1,6 @@ import type { SheetProps } from "@codeui/kit"; import type * as Parts from "@codeui/kit/sheet/parts"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; export type Sheet = Pick; diff --git a/packages/docs-demos/src/props/stack.ts b/packages/docs-demos/src/props/stack.ts index 47953e93..aeaf7be6 100644 --- a/packages/docs-demos/src/props/stack.ts +++ b/packages/docs-demos/src/props/stack.ts @@ -1,5 +1,5 @@ import type { StackProps } from "@codeui/kit"; -import type { ValidComponent } from "solid-js"; +import type { ValidComponent } from "@solidjs/web"; import type { PropNotes } from "./notes"; /** Props that Stack adds. Every other prop goes to the element that `as` names. */ diff --git a/packages/docs-demos/src/props/text-area.ts b/packages/docs-demos/src/props/text-area.ts index 2be8e2fe..69392f9e 100644 --- a/packages/docs-demos/src/props/text-area.ts +++ b/packages/docs-demos/src/props/text-area.ts @@ -1,5 +1,5 @@ import type { TextAreaLabel, TextAreaProps } from "@codeui/kit"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; /** Props that TextArea adds on top of Kobalte's text field root. */ diff --git a/packages/docs-demos/src/props/text-field.ts b/packages/docs-demos/src/props/text-field.ts index dc594d32..e0a0e9e7 100644 --- a/packages/docs-demos/src/props/text-field.ts +++ b/packages/docs-demos/src/props/text-field.ts @@ -1,5 +1,5 @@ import type { TextFieldLabel, TextFieldProps } from "@codeui/kit"; -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { PropNotes } from "./notes"; /** Props that TextField adds on top of Kobalte's text field root. */ @@ -22,8 +22,8 @@ export type TextFieldInputAttributes = Pick< | "inputmode" | "enterkeyhint" | "spellcheck" - | "maxLength" - | "minLength" + | "maxlength" + | "minlength" | "pattern" | "autofocus" | "aria-label" @@ -57,5 +57,6 @@ export const notes = { }, TextFieldInputAttributes: { type: { type: '"text" | "email" | "password" | "search" | "url" | … | string', default: '"text"', description: "Input type, such as email, url, or password." }, + inputmode: { type: '"text" | "email" | "numeric" | …', description: "Keyboard layout requested on touch devices." }, }, } satisfies PropNotes; diff --git a/packages/docs-demos/src/props/text.ts b/packages/docs-demos/src/props/text.ts index 2aee2d3a..37289865 100644 --- a/packages/docs-demos/src/props/text.ts +++ b/packages/docs-demos/src/props/text.ts @@ -1,5 +1,5 @@ import type { TextProps } from "@codeui/kit"; -import type { ValidComponent } from "solid-js"; +import type { ValidComponent } from "@solidjs/web"; import type { PropNotes } from "./notes"; /** Props that Text adds. Every other prop goes to the element that `as` names. */ diff --git a/packages/docs-demos/src/props/tooltip.ts b/packages/docs-demos/src/props/tooltip.ts index c665ff71..5e9e537f 100644 --- a/packages/docs-demos/src/props/tooltip.ts +++ b/packages/docs-demos/src/props/tooltip.ts @@ -1,4 +1,4 @@ -import type { ComponentProps } from "solid-js"; +import type { ComponentProps } from "@solidjs/web"; import type { Tooltip as TooltipComponent } from "@codeui/kit"; import type { PropNotes } from "./notes"; diff --git a/packages/docs-demos/src/server.tsx b/packages/docs-demos/src/server.tsx index daa1e387..1de342ae 100644 --- a/packages/docs-demos/src/server.tsx +++ b/packages/docs-demos/src/server.tsx @@ -1,5 +1,5 @@ import type { Component } from "solid-js"; -import { generateHydrationScript, renderToString } from "solid-js/web"; +import { generateHydrationScript, renderToString } from "@solidjs/web"; const demos = import.meta.glob<{ default: Component }>(["./demos/*.tsx", "./demos/*/*.tsx"], { eager: true }); diff --git a/packages/docs-demos/tsconfig.json b/packages/docs-demos/tsconfig.json index 4b20d22f..7c0b6443 100644 --- a/packages/docs-demos/tsconfig.json +++ b/packages/docs-demos/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "jsx": "preserve", - "jsxImportSource": "solid-js", + "jsxImportSource": "@solidjs/web", "module": "esnext", "moduleResolution": "bundler", "target": "es2022", diff --git a/packages/docs-demos/vite.config.ts b/packages/docs-demos/vite.config.ts index d6b1692c..aa6f136d 100644 --- a/packages/docs-demos/vite.config.ts +++ b/packages/docs-demos/vite.config.ts @@ -1,5 +1,5 @@ import { defineConfig } from "vite"; -import solid from "vite-plugin-solid"; +import solid from "@solidjs/vite-plugin"; export default defineConfig(({ isSsrBuild }) => ({ plugins: [solid({ ssr: true })], diff --git a/packages/kit/DESIGN.md b/packages/kit/DESIGN.md index 92f86e54..cdb3d224 100644 --- a/packages/kit/DESIGN.md +++ b/packages/kit/DESIGN.md @@ -104,6 +104,11 @@ The accent is never a surface or a large fill. It has five uses: Danger, caution and success mark states the user must notice. They never decorate or label a category. Danger fills only the confirm button of a destructive dialog. Errors pair colour with an icon. +- A workflow state that needs nothing from the user (to do, in review, done) is neutral or uses the brand wash, never a status colour. Every state has a visible name, in a label or a tooltip, and its glyph changes shape as well as colour. +- A real warning always shows in the caution tone with an alert icon, and never folds into ordinary content or a collapsed group. +- A finished item shows no status icon and never decorates success in green. Its row keeps its time. See §9.11. + + Gosfuig generates the red, orange, and green ramps for danger, caution, and success. Each status fill uses step `500` for base, `600` for hover, and `700` for active. Error text uses `red.500` in Light and `red.300` in Dark. The hover and active colours follow a theme override of the base through CSS relative colours. `test/derived-palette.test.ts` checks the computed colours against `theme-values.ts`. @@ -145,6 +150,8 @@ Gosfuig generates one achromatic OKLCH ramp for both modes from `packages/inksto - A selected option may go from 500 to 600 only if its box reserves the 600 width. - Tracking `normal` up to 16px; `-0.01em` to `-0.02em` on display type. No uppercase labels. - Sentence case everywhere. A label is a noun or short verb phrase. A hint is one line. A badge is one word. +- A section heading is text, not a row. It has no fill, no row height and no capitals: Label or Meta at 600 in secondary text, with a count in tertiary text at 400. Every section heading in one list has the same height. + - Changing numbers use `font-variant-numeric: tabular-nums`. - Truncate values, never labels, to one line with an ellipsis, and keep the full text reachable (tooltip, accessible name). - **Proposed:** `text-wrap: balance` on titles and short descriptions, `text-wrap: pretty` on paragraphs. @@ -159,12 +166,15 @@ Gosfuig generates one achromatic OKLCH ramp for both modes from `packages/inksto | Measure | Value | | ---------------------------------------- | ------------------------------ | -| Page inset and gap between islands | 8px | +| Page inset and gap between islands | 6px (`--cui-space-1-5`) | | Island padding | 12–16px | | Header row | 36px; 40px at ≤768px | | Side panel | 360px | | First item inside a 22px corner | 16px from the edge | +The space of an island layout goes inside the islands. The page between them reads as a thin seam, the same width on every side. + + The header has no bar. It is the first row of islands, and its edges align with the islands below. ## 5. Shape @@ -215,6 +225,8 @@ Checkbox, Radio and Switch use their own geometry. Menu, listbox, select, combob - In settings, allow 84px per segmented option. - Icons: one outline set; 16px in controls and rows, 14px in segments, 20px in a rail or phone tab bar; 6–8px from their label. - A row has a fixed 20px leading slot, so text aligns with or without an icon. +- A list inside a listbox, menu or combobox resets the browser's `ul` and `ol` margin and padding. Its rows start at the surface's padding. + - An icon-only button has an accessible name and a kit Tooltip covering its whole hit area. ## 7. Motion @@ -272,11 +284,13 @@ Rules for every movement: - Illustrations play once, under 850ms, then rest. - Drags track the pointer 1:1 from where it was grabbed, hand their release velocity to the settle animation, and rubber-band at the edges. - Keyboard-only rules read the last input from `` (`keyboard` or `pointer`), not `:focus-visible`: a script focus after a click reports `:focus-visible` to a mouse user. +- Every spinner turns on one clock, so spinners that mount at different moments stay in phase and read as one activity. **Proposed:** the kit `Spinner` aligns its animation to the document timeline itself. + - Reduced motion keeps opacity and colour, drops movement and scale. - Hover styles only under `@media (hover: hover) and (pointer: fine)`. - **No materials.** Unlike Apple's design language, Inkstone has no translucency or `backdrop-filter` on the interface. Matte is a trait. -The kit's popover, menu, list popovers and tooltip follow Pop, and its toast follows Rise. They still use keyframes, because Kobalte unmounts the content when its exit animation ends. The rest of the kit's motion is slower than these rules today: buttons press in 200ms `ease`, and the focus ring transitions with `ease-in`. **Proposed:** move them to Press and a 120ms colour change. +The kit's popover, hover card, menu, list popovers and tooltip follow Pop, and its toast follows Rise. Pop uses CSS keyframes. The kit keeps each closing surface mounted until its exit finishes. The rest of the kit's motion is slower than these rules today: buttons press in 200ms `ease`, and the focus ring transitions with `ease-in`. **Proposed:** move them to Press and a 120ms colour change. The kit dialog follows Pop with keyframes: in from `scale(0.96)` over 200ms, out toward `scale(0.98)` over 120ms, and its scrim fades with it. Opened or closed from the keyboard, it does not move. Moving it to transitions is still proposed. @@ -292,12 +306,17 @@ The kit dialog follows Pop with keyframes: in from `scale(0.96)` over 200ms, out │ │ ( floating toolbar ) │ │ └─────────┘ │ │ │ └──────────────────────────────────────────┘ └─────────────┘ │ └──────────────────────────────────────────────────────────────┘ - 8px inset · 8px gap · 22px island radius + 6px inset · 6px gap · 22px island radius ``` -- Chrome has fixed sizes. The content takes the rest. -- A read-only view draws no container for controls it does not show. -- **Accordion:** one section open; header is icon, title, secondary summary on the right, chevron; 36px, Label 600, radius 12; icon turns accent when open; everything in an open section is visible. +- Chrome has fixed sizes. The content takes the rest. A side panel may be resizable with the kit `Resizable`, always between a minimum and a maximum width. + +- A view opens as a tab in an island, beside the content. Never replace the content with a full screen that needs a "Back to …" button. + +- A read-only view draws no container for controls it does not show. A list draws no row for an item with nothing in it. + +- **Accordion:** one section open; header is icon, title, secondary summary on the right, chevron; 36px, Label 600, radius 12; icon turns accent when open; everything in an open section is visible. The whole header row is the trigger. The chevron is an icon inside it, not a separate button, and row actions sit over the end of the row, inside its fill. + - **Floating bar:** takes no layout space; its menus open over it; labels keep a minimum width; rarely used actions go to the command menu. - **Modes** that change what the user is doing (CodeImage's Animate timeline) are the one open question: today the timeline takes canvas space and moves the frame. Until decided, a mode may take space, but entering and leaving it must not rezoom the content. - **Responsive:** `max-width: 768px` is a phone (`min-width: 769px` the reverse; nothing else). On a phone a panel becomes a bottom sheet with a 36×4 grip, sections become tabs, timelines become lists, and header actions must fit the width. @@ -337,6 +356,7 @@ No border; field fill, radius 12, padding 12; a 68px preview well (radius 8) ove | Overlay | When | Backdrop | Focus | | ------------ | -------------------------------------- | -------- | ------------------------------------ | | Tooltip | Name an icon, explain a value | None | Opens on hover and keyboard focus | +| Hover card | Show several facts or a description | None | Opens on hover, focus and click | | Popover | Pick a value for one row | None | Moves in, returns to the trigger | | Menu | Choose an action | None | Moves in, returns to the trigger | | Command menu | Find anything by name | None | Trapped, returns on close | @@ -345,6 +365,11 @@ No border; field fill, radius 12, padding 12; a 68px preview well (radius 8) ove - A picker opens anchored to its row, over the panel that holds it: 360px, radius 16, padding 16. - A dialog is for settings and for blocking decisions, not for confirming something undoable. +- A tooltip is one line that names one thing. A description, or more than one fact, goes in a hover card beside its trigger, on the right unless there is no room, wrapped at about 20rem. It opens on click too, so touch works. Never use the `title` attribute. Everything in a hover card is reachable another way. Use the kit `HoverCard`: `right-start` by default, a click or tap opens it at once, Pop motion, and the floating surface. Moving to the next trigger while a card is open moves that card: it slides to the new trigger and resizes to the new content in 200ms ease-out, with no second pop. From the keyboard it swaps in place. Hover cards share one card per page; a `HoverCardGroup` gives a set of triggers their own. A text trigger has a dotted underline in the hint tone that takes the text colour on hover and while open. + +- A list in a menu or hover card has one line per entry: state icon, identifier, title truncated. Show nesting by indent, and drop a prefix every entry shares. Two or more entries for one action go in a submenu labelled with the count. A long list caps at about 24rem and scrolls on its own. In a hover card, use `HoverCardList` and `HoverCardItem`; the icon slot stays when an entry has no icon. + + - Escape closes the innermost layer only. - Scrollbars inside overlays set `scrollbar-color`; never mix it with `::-webkit-scrollbar`. @@ -352,10 +377,19 @@ No border; field fill, radius 12, padding 12; a 68px preview well (radius 8) ove `Mod+K` everywhere. Bottom centre, 16px from the edge, `min(640px, …)`, radius 22, padding 8, six rows at the shared sm height, no scrim. Grouped under Meta 600 labels. The highlighted row has field fill, previews on the content, Enter applies, Escape restores. A one-line hint in the input row: `↑↓ preview · ↵ apply · esc cancel`. It lists every visible option, action and setting, read from the same data as the controls. +- A group label in a menu has about `--cui-space-2` above it and `--cui-space-1` below. The first label adds no space above. + +- The key hints sit in a footer row of keycaps (`↑↓ Navigate`, `↵ Run`, `esc Close`), not in the input row. + +- Rows are icon, name, then the description on the right. The highlighted row's full description opens in a hover card that follows the arrow keys. + ### 9.7 Actions in dialogs and toasts Close and Confirm on the right; a tertiary action is a small ghost icon button on the left. No full-width buttons on desktop. A toast action is an inline text action. On a phone the footer stacks. +An action at the end of a sentence or notice is a text link after `--cui-space-2`, in default text, underlined on hover. Never a button box pressed against the text. + + ### 9.8 Tag and keycap - **Tag:** `1px 6px`, radius 6, neutral fill, Micro 500, secondary tone, one word. @@ -369,12 +403,62 @@ A 6–7px accent dot on the new control, at most three in the app, never animate A loading control swaps its icon for a spinner and keeps its width. A loading region shows a skeleton of the content in place. An empty state names what is missing and offers the one action that fixes it. An error says what happened and what to do, where it happened. +Loading never shows the empty state, not even for one frame. While the next content loads, keep the previous content or show a skeleton. Keep recently viewed content cached so going back is instant. + + +### 9.11 Rows in a list + +- The leading slot holds what tells the item apart from its neighbours: its type, its source, its owner. Never a generic icon repeated on every row. A label that is the same on every row goes in the accessible description, not on screen. + +- The trailing slot has one meaning. It shows the time by default, and an icon only for live work, a failure, a stop or a request for the user. + +- Show ownership by nesting the item under its owner, not by a separate section that changes with the selection. Keep organising groups (pinned, archived) outside that tree. + +- A summary and its members are one row: the live member first, then the count that opens the rest. A fact every member shares goes once on the group row. + +- A large flat group gets a second level by the owner the user recognises, with an avatar and a count, instead of long paths on every row. + + +### 9.12 Background work + +Work that runs while the user does something else stays visible as one control near where the user acts. It shows a count and how many are still active, for example "3 tasks · 1 running". It opens the list, where each item shows what it runs and for how long. It stays until nothing is left. + + + +### 9.13 Data and technical values + +- Show data as what it is: lines of a file, a diff, or name and value rows. Raw JSON only for data with no known shape. + +- A technical value (command, path, query) shows itself, not a verb about it. The part that identifies it is primary text, the rest is tertiary mono, truncated. Opened, the full value is highlighted in the code font with a Copy button. + +- Running work shows its elapsed time at the end of its row, in tabular figures with a reserved width. The time stays once the work ends. + +- An author line is the author's mark in a rounded tile, the name in primary text, then facts in secondary text joined by " · ". + + +### 9.14 Avatar + +A person is an avatar: their picture when there is one, otherwise one or two initials on a hue derived from their id, never from their name. Full radius with the §2.5 ring. The name is in the tooltip and the accessible name. Sizes come from the shared control scale (`xs` by default) and follow density. An unassigned owner is an empty dashed circle in secondary text colour. The fill is OKLCH at lightness 0.48 in dark and 0.86 in light, so the initials reach 5.5:1 and 10:1 on every hue. Use the kit `Avatar`. + + +### 9.15 Forms and inputs + +- A setup form asks the main choice first and puts the advanced methods behind a disclosure. Each method has a one-line hint on where to find its value. An error sits under the field that caused it and clears when the method changes. + +- A suggested value is the field's placeholder with a Tab keycap to accept it, not a separate chip. + +- Context attached to an input is a chip above it: the source's mark, the key at 600, the title truncated, on `--cui-action-brand-soft-base`, with a remove button. Attaching never sends. + +- A text input has no formatting toolbar. Formatting comes from shortcuts and renders as you type. + + ## 10. Accessibility - Contrast 4.5:1 for text up to 18px; 3:1 for large text, icons, rings and control edges. Both themes. - The switch off track stays below 3:1 on some surfaces. It reaches 3.2:1 on the light page, 2.7:1 on a light field and 1.9:1 on a dark field. The thumb position and blue on track also indicate state. - Every control works from the keyboard. Pickers and cards open with Enter and Space. Lists preview on focus as on hover. -- One focus ring: 2px, 2px offset, `--cui-focus-color`, on `:focus-visible`. +- One focus ring: 2px, 2px offset, `--cui-focus-color`, on `:focus-visible`. In packed lists, trees and toolbars the ring sits inside the row (`outline-offset: calc(var(--cui-focus-width) * -1)`) and shows only for keyboard input, so it never covers a neighbour. + - Closing an overlay returns focus to its trigger. Closing a corner card moves focus to the next control, never into a text field. - A dialog on a phone does not focus a text field on open. - Every icon button and field has an accessible name. @@ -400,6 +484,11 @@ Do not propose these again without a new reason. | Draggable bezier handles | Read-only curve and a typed value | | A blocking "What's new" dialog; a "7 new things" toast | Corner card, dots, archive | | Native SVG `title` as a tooltip | The kit Tooltip | +| `title` attribute for a description | A hover card | +| A status footer for ambient state | A header control shown only when it needs action | +| A full screen with "Back to …" | A tab in an island | +| A formatting toolbar under a text input | Shortcuts that render as you type | +| A generic icon and the same label on every row | The item's own mark in the leading slot | | Glass, blur, dot grids as decoration | Matte surfaces | | Text under 11px | 11px minimum | diff --git a/packages/kit/README.md b/packages/kit/README.md index 639903db..6bc9548e 100644 --- a/packages/kit/README.md +++ b/packages/kit/README.md @@ -4,7 +4,7 @@ # CodeUI - [CodeImage](https://github.com/riccardoperra/codeimage) UI Kit -Install `@codeui/kit` and `solid-js`. Solid components import their compiled CSS and theme automatically. No CSS import or vanilla-extract plugin is required in your app. +Install `@codeui/kit`, `solid-js@^2`, and `@solidjs/web@^2`. Use `@solidjs/vite-plugin` to compile Solid JSX. Solid components import their compiled CSS and theme automatically. No CSS import or vanilla-extract plugin is required in your app. ```ts import { Button } from "@codeui/kit"; diff --git a/packages/kit/api/kit.api.md b/packages/kit/api/kit.api.md index 2cf2cc10..4e204e78 100644 --- a/packages/kit/api/kit.api.md +++ b/packages/kit/api/kit.api.md @@ -583,6 +583,14 @@ export { alertParts, type AlertPart, type AlertClasses, type AlertTone, type Ale export * from "./internal/generated-appearance/alert.js"; ``` +## @codeui/styles/avatar.d.ts + +```ts +export * from "./internal/components/Avatar/Avatar.css.js"; +export { avatarParts, type AvatarPart, type AvatarClasses, type AvatarSize, type AvatarVariants, type AvatarStyles, avatarStyles, avatarHue, avatarInitials } from "./internal/parts/avatar.js"; +export * from "./internal/generated-appearance/avatar.js"; +``` + ## @codeui/styles/badge.d.ts ```ts @@ -658,6 +666,13 @@ export * from "./internal/components/Field/FieldLabel/FieldLabel.css.js"; export * from "./internal/components/Field/FieldMessage/FieldMessage.css.js"; ``` +## @codeui/styles/hovercard.d.ts + +```ts +export * from "./internal/components/HoverCard/HoverCard.css.js"; +export { hoverCardParts, type HoverCardPart, type HoverCardClasses, type HoverCardStyles, hoverCardStyles } from "./internal/parts/hover-card.js"; +``` + ## @codeui/styles/icon.d.ts ```ts @@ -715,6 +730,9 @@ export * as fieldlabel from "./fieldlabel.js"; export * as fieldmessage from "./fieldmessage.js"; export * as fielderror from "./fielderror.js"; export * as icon from "./icon.js"; +export * as hovercard from "./hovercard.js"; +export * as resizable from "./resizable.js"; +export * as avatar from "./avatar.js"; export * from "./tokens.js"; export { applyStyleProps, type StyleProps } from "./internal/utils/applyStyleProps.js"; ``` @@ -744,6 +762,25 @@ export declare const root: () => string; export declare const title: string; ``` +## @codeui/styles/internal/components/Avatar/Avatar.css.d.ts + +```ts +export declare const root: () => string; +export declare const image: () => string; +export declare const fallback: () => string; +export declare const avatarVars: { + size: `var(--${string})`; + fontSize: `var(--${string})`; + hue: `var(--${string})`; + lightness: `var(--${string})`; + chroma: `var(--${string})`; + background: `var(--${string})`; + color: `var(--${string})`; + ring: `var(--${string})`; + unassignedColor: `var(--${string})`; +}; +``` + ## @codeui/styles/internal/components/Badge/Badge.css.d.ts ```ts @@ -981,6 +1018,30 @@ export declare function styleFieldMessage(sizesMap: Record string; +export declare const list: () => string; +export declare const item: () => string; +export declare const itemIcon: () => string; +export declare const itemId: () => string; +export declare const itemTitle: () => string; +export declare const hoverCardVars: { + contentBackground: `var(--${string})`; + contentBoxShadow: `var(--${string})`; + contentMaxWidth: `var(--${string})`; + contentRadius: `var(--${string})`; + contentPadding: `var(--${string})`; + contentFontSize: `var(--${string})`; + contentLineHeight: `var(--${string})`; + contentColor: `var(--${string})`; + listMaxHeight: `var(--${string})`; + itemIndent: `var(--${string})`; + itemDepth: `var(--${string})`; +}; +``` + ## @codeui/styles/internal/components/IconButton/IconButton.css.d.ts ```ts @@ -1128,6 +1189,19 @@ export declare const radioVars: { }; ``` +## @codeui/styles/internal/components/Resizable/Resizable.css.d.ts + +```ts +export declare const handle: () => string; +export declare const resizableVars: { + handleSize: `var(--${string})`; + handleLineColor: `var(--${string})`; + handleLineActiveColor: `var(--${string})`; + handleLineDraggingColor: `var(--${string})`; + handleLineWidth: `var(--${string})`; +}; +``` + ## @codeui/styles/internal/components/SegmentedControl/SegmentedControl.css.d.ts ```ts @@ -1718,6 +1792,22 @@ export declare const alertStyleProps: (options?: AlertStyleOptions) => { }; ``` +## @codeui/styles/internal/generated-appearance/avatar.d.ts + +```ts +export type AvatarStyleOptions = { + class?: string; + size?: "xs" | "sm" | "md" | "lg"; + unassigned?: boolean; +}; +export declare const avatarStyleProps: (options?: AvatarStyleOptions) => { + class: string; + "data-cui": "avatar"; + "data-size": "xs" | "sm" | "md" | "lg"; + "data-unassigned": string | undefined; +}; +``` + ## @codeui/styles/internal/generated-appearance/badge.d.ts ```ts @@ -2173,6 +2263,20 @@ export declare const radioListStyleProps: ((options?: Parameters[0 export {}; ``` +## @codeui/styles/internal/generated-appearance/resizable.d.ts + +```ts +export type ResizableStyleOptions = { + class?: string; + orientation?: "horizontal" | "vertical"; +}; +export declare const resizableStyleProps: (options?: ResizableStyleOptions) => { + class: string; + "data-cui": "resizable-handle"; + "data-orientation": "horizontal" | "vertical"; +}; +``` + ## @codeui/styles/internal/generated-appearance/segmentedcontrol.d.ts ```ts @@ -2695,6 +2799,32 @@ export type AlertStyles = { export declare const alertStyles: AlertStyles; ``` +## @codeui/styles/internal/parts/avatar.d.ts + +```ts +import type { AvatarStyleOptions } from "../generated-appearance/avatar.js"; +export declare const avatarParts: { + readonly root: "avatar"; + readonly image: "avatar-image"; + readonly fallback: "avatar-fallback"; +}; +export type AvatarPart = keyof typeof avatarParts; +export type AvatarClasses = Partial>; +export type AvatarSize = NonNullable; +export type AvatarVariants = { + size?: AvatarSize; + unassigned?: boolean; +}; +export type AvatarStyles = { + [P in AvatarPart]: () => string; +}; +export declare const avatarStyles: AvatarStyles; +/** FNV-1a hash of a stable id, folded to a hue in degrees. Never pass a display name. */ +export declare const avatarHue: (identifier: string) => number; +/** One or two initials from a name: the first letter of the first and last words. */ +export declare const avatarInitials: (name: string) => string; +``` + ## @codeui/styles/internal/parts/badge.d.ts ```ts @@ -2832,6 +2962,26 @@ export type DialogStyles = Record string>; export declare const dialogStyles: DialogStyles; ``` +## @codeui/styles/internal/parts/hover-card.d.ts + +```ts +export declare const hoverCardParts: { + readonly trigger: "hovercard-trigger"; + readonly content: "hovercard-content"; + readonly list: "hovercard-list"; + readonly item: "hovercard-item"; + readonly itemIcon: "hovercard-item-icon"; + readonly itemId: "hovercard-item-id"; + readonly itemTitle: "hovercard-item-title"; +}; +export type HoverCardPart = keyof typeof hoverCardParts; +export type HoverCardClasses = Partial>; +export type HoverCardStyles = { + [P in HoverCardPart]: () => string; +}; +export declare const hoverCardStyles: HoverCardStyles; +``` + ## @codeui/styles/internal/parts/kbd.d.ts ```ts @@ -2923,6 +3073,24 @@ export type ProgressStyles = Record string>; export declare const progressStyles: ProgressStyles; ``` +## @codeui/styles/internal/parts/resizable.d.ts + +```ts +import type { ResizableStyleOptions } from "../generated-appearance/resizable.js"; +export declare const resizableParts: { + readonly root: "resizable"; + readonly panel: "resizable-panel"; + readonly handle: "resizable-handle"; +}; +export type ResizablePart = keyof typeof resizableParts; +export type ResizableClasses = Partial>; +export type ResizableOrientation = NonNullable; +export type ResizableStyles = { + [P in ResizablePart]: () => string; +}; +export declare const resizableStyles: ResizableStyles; +``` + ## @codeui/styles/internal/parts/settings.d.ts ```ts @@ -3284,6 +3452,14 @@ export * from "./internal/components/RadioList/Radio.css.js"; export * from "./internal/generated-appearance/radiolist.js"; ``` +## @codeui/styles/resizable.d.ts + +```ts +export * from "./internal/components/Resizable/Resizable.css.js"; +export { resizableParts, type ResizablePart, type ResizableClasses, type ResizableOrientation, type ResizableStyles, resizableStyles } from "./internal/parts/resizable.js"; +export * from "./internal/generated-appearance/resizable.js"; +``` + ## @codeui/styles/segmentedcontrol.d.ts ```ts @@ -3421,7 +3597,8 @@ export * from "./internal/generated-appearance/tooltip.js"; ## components/Accordion/Accordion.d.ts ```ts -import { type Accessor, type JSX } from "solid-js"; +import { type Accessor } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as A from "../../parts/accordion.js"; export type AccordionEntry = { value: string; @@ -3443,7 +3620,7 @@ export type AccordionProps = { classes?: A.AccordionClasses; "aria-label"?: string; }; -export declare function createAccordionItems(accessor: Accessor): Accessor<{ +export declare function createAccordionItems(accessor: Accessor): import("solid-js").SourceAccessor<{ value: string; title: JSX.Element; icon?: JSX.Element; @@ -3457,7 +3634,7 @@ export declare function Accordion(props: AccordionProps): JSX.Element; ```ts import type { PolymorphicProps } from "@kobalte/core/polymorphic"; -import { type JSX, type ValidComponent } from "solid-js"; +import { type JSX, type ValidComponent } from "@solidjs/web"; import * as A from "../../parts/alert.js"; export type AlertProps = A.RootProps & { children?: JSX.Element; @@ -3476,11 +3653,37 @@ export type AlertProps = A.RootProps & { export declare function Alert(props: PolymorphicProps>): JSX.Element; ``` +## components/Avatar/Avatar.d.ts + +```ts +import { type JSX } from "@solidjs/web"; +import * as A from "../../parts/avatar.js"; +export type AvatarProps = Omit & { + /** The person's name. It is the accessible name and the tooltip. Defaults to "Unassigned" when `unassigned`. */ + name?: string; + /** A stable id, such as a user id. The fill hue comes from it, never from the name. Without it the fill is neutral. */ + identifier?: string; + /** URL of the picture. The initials show while it is missing or when it fails to load. */ + src?: string; + /** Override the initials. Defaults to the first letter of the first and last words of `name`. */ + initials?: string; + /** Show the name in the kit Tooltip on hover. Defaults to `true`. */ + tooltip?: boolean; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: A.AvatarClasses; +}; +/** + * A person: their picture, or one or two initials on a hue derived from their id. + * An unassigned avatar is an empty dashed circle. + */ +export declare function Avatar(props: AvatarProps): JSX.Element; +``` + ## components/Badge/Badge.d.ts ```ts import type { PolymorphicProps } from "@kobalte/core/polymorphic"; -import { type JSX, type ValidComponent } from "solid-js"; +import { type JSX, type ValidComponent } from "@solidjs/web"; import * as B from "../../parts/badge.js"; export type BadgeProps = B.RootProps & { children?: JSX.Element; @@ -3503,7 +3706,7 @@ export * from "@codeui/styles/internal/components/Button/Button.css"; ```ts import { ButtonRootProps as KButtonRootProps } from "@kobalte/core/button"; -import { JSX, ValidComponent } from "solid-js"; +import { JSX, ValidComponent } from "@solidjs/web"; import * as styles from "./Button.css.js"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; export type ButtonProps = KButtonRootProps & styles.ButtonVariants & { @@ -3518,7 +3721,8 @@ export declare function Button(props: Polym ```ts import type { CheckboxRootOptions } from "@kobalte/core/checkbox"; -import { type JSX, type Ref } from "solid-js"; +import { type Ref } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/checkbox.js"; import type { SlotProp } from "../../utils/component.js"; import type { FieldWithErrorMessageSupport } from "../Field/FieldError/createFieldErrorMessageProps.js"; @@ -3536,7 +3740,7 @@ export {}; ```ts import type { ComboboxRootOptions } from "@kobalte/core/combobox"; -import { type JSX } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/combobox.js"; import type { FieldContent } from "../Field/createBaseFieldProps.js"; type DistributiveOmit = T extends unknown ? Omit : never; @@ -3607,7 +3811,7 @@ export {}; ```ts import type { DialogContentProps } from "@kobalte/core/dialog"; -import { type JSX } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/command-menu.js"; export type CommandItem = { /** Unique across the items. */ @@ -3672,7 +3876,8 @@ export type { CommandMenuClasses, CommandMenuPart, CommandMenuStyles, } from ".. ```ts import type { DialogContentOptions as KDialogContentOptions, DialogRootOptions as KDialogRootOptions } from "@kobalte/core/dialog"; -import { type JSX, type ParentProps } from "solid-js"; +import { type ParentProps } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as D from "../../parts/dialog.js"; export type DialogProps = KDialogRootOptions & Pick & { size?: D.DialogSize; @@ -3685,7 +3890,7 @@ export type DialogProps = KDialogRootOptions & Pick; "aria-label"?: string; @@ -3707,26 +3912,27 @@ export * from "@codeui/styles/internal/components/Dropdown/Dropdown.css"; ```ts import { GetKobalteParams } from "../../utils/types.js"; import { DropdownMenu as KDropdownMenu, DropdownMenuContentProps as KDropdownMenuContentProps, DropdownMenuItemProps as KDropdownMenuItemProps, DropdownMenuRootProps as KDropdownMenuRootProps, DropdownMenuSeparatorProps as KDropdownMenuSeparatorProps, DropdownMenuSubContentProps as KDropdownMenuSubContentProps, DropdownMenuSubProps as KDropdownMenuSubProps, DropdownMenuSubTriggerProps as KDropdownMenuSubTriggerProps, DropdownMenuTriggerProps as KDropdownMenuTriggerProps } from "@kobalte/core/dropdown-menu"; -import { JSXElement, ValidComponent } from "solid-js"; +import { Element } from "solid-js"; +import { ValidComponent } from "@solidjs/web"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; -export declare function DropdownMenuContent(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function DropdownMenuPortal(props: GetKobalteParams): import("solid-js").JSX.Element; +export declare function DropdownMenuContent(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function DropdownMenuPortal(props: GetKobalteParams): import("@solidjs/web").JSX.Element; export interface DropdownMenuItemProps extends KDropdownMenuItemProps { - rightSlot?: JSXElement; + rightSlot?: Element; } -export declare function DropdownMenuItem(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function DropdownMenuItem(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; export interface DropdownSubMenuProps extends KDropdownMenuSubProps { - rightSlot?: JSXElement; + rightSlot?: Element; } -export declare function DropdownSubMenu(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function DropdownSubMenu(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; export interface DropdownSubMenuTriggerProps extends KDropdownMenuSubTriggerProps { - rightSlot?: JSXElement; + rightSlot?: Element; } -export declare function DropdownSubMenuTrigger(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function DropdownSubMenuContent(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function DropdownMenuSeparator(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function DropdownMenuTrigger(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function DropdownMenu(props: PolymorphicProps): import("solid-js").JSX.Element; +export declare function DropdownSubMenuTrigger(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function DropdownSubMenuContent(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function DropdownMenuSeparator(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function DropdownMenuTrigger(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function DropdownMenu(props: PolymorphicProps): import("@solidjs/web").JSX.Element; ``` ## components/Field/Field.css.d.ts @@ -3744,39 +3950,14 @@ export * from "@codeui/styles/internal/components/Field/FieldError/FieldError.cs ## components/Field/FieldError/createFieldErrorMessageProps.d.ts ```ts -import { JSX } from "solid-js"; +import { JSX } from "@solidjs/web"; export type FieldWithErrorMessageSupport = { errorMessage?: JSX.Element; }; -export declare function createFieldErrorMessageProps(props: T): ((Pick[number]> extends infer T_1 ? T_1 extends Pick[number]> ? T_1 extends any ? {} & { [K in keyof T_1]: K extends never ? T_1[K] extends infer T_2 ? T_2 extends T_1[K] ? T_2 extends undefined ? {}[K] : T_2 : never : never : T_1[K]; } : {} & T_1 : never : never) extends infer T_3 ? T_3 extends (Pick[number]> extends infer T_1 ? T_1 extends Pick[number]> ? T_1 extends any ? {} & { [K in keyof T_1]: K extends never ? T_1[K] extends infer T_2 ? T_2 extends T_1[K] ? T_2 extends undefined ? {}[K] : T_2 : never : never : T_1[K]; } : {} & T_1 : never : never) ? T_3 extends any ? { [K_1 in keyof T_3]: K_1 extends "class" ? { - readonly class: string; -}[K_1] extends infer T_4 ? T_4 extends { - readonly class: string; -}[K_1] ? T_4 extends undefined ? T_3[K_1] : T_4 : never : never : T_3[K_1]; } & { - readonly class: "class" extends infer T_5 ? T_5 extends "class" ? T_5 extends keyof T_3 ? { - readonly class: string; - }[T_5] extends infer T_6 ? T_6 extends { - readonly class: string; - }[T_5] ? T_6 extends undefined ? T_3[T_5] : T_6 : never : never : { - readonly class: string; - }[T_5] : never : never; -} : T_3 & { - readonly class: string; -} : never : never) extends infer T_7 ? T_7 extends ((Pick[number]> extends infer T_1 ? T_1 extends Pick[number]> ? T_1 extends any ? {} & { [K in keyof T_1]: K extends never ? T_1[K] extends infer T_2 ? T_2 extends T_1[K] ? T_2 extends undefined ? {}[K] : T_2 : never : never : T_1[K]; } : {} & T_1 : never : never) extends infer T_3 ? T_3 extends (Pick[number]> extends infer T_1 ? T_1 extends Pick[number]> ? T_1 extends any ? {} & { [K in keyof T_1]: K extends never ? T_1[K] extends infer T_2 ? T_2 extends T_1[K] ? T_2 extends undefined ? {}[K] : T_2 : never : never : T_1[K]; } : {} & T_1 : never : never) ? T_3 extends any ? { [K_1 in keyof T_3]: K_1 extends "class" ? { - readonly class: string; -}[K_1] extends infer T_4 ? T_4 extends { +export declare function createFieldErrorMessageProps(props: T): { + errorMessage?: T["errorMessage"] | undefined; readonly class: string; -}[K_1] ? T_4 extends undefined ? T_3[K_1] : T_4 : never : never : T_3[K_1]; } & { - readonly class: "class" extends infer T_5 ? T_5 extends "class" ? T_5 extends keyof T_3 ? { - readonly class: string; - }[T_5] extends infer T_6 ? T_6 extends { - readonly class: string; - }[T_5] ? T_6 extends undefined ? T_3[T_5] : T_6 : never : never : { - readonly class: string; - }[T_5] : never : never; -} : T_3 & { - readonly class: string; -} : never : never) ? T_7 extends any ? { [K_2 in keyof T_7]: T_7[K_2]; } : T_7 : never : never; +}; ``` ## components/Field/FieldLabel/FieldLabel.css.d.ts @@ -3788,7 +3969,7 @@ export * from "@codeui/styles/internal/components/Field/FieldLabel/FieldLabel.cs ## components/Field/FieldLabel/createFieldLabelProps.d.ts ```ts -import { ValidComponent } from "solid-js"; +import { ValidComponent } from "@solidjs/web"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; export declare function createFieldLabelProps(props: PolymorphicProps): ((PolymorphicProps extends infer T ? T extends PolymorphicProps ? T extends any ? {} & { [K in keyof T]: K extends never ? T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends undefined ? {}[K] : T_1 : never : never : T[K]; } : {} & T : never : never) extends infer T_2 ? T_2 extends (PolymorphicProps extends infer T ? T extends PolymorphicProps ? T extends any ? {} & { [K in keyof T]: K extends never ? T[K] extends infer T_1 ? T_1 extends T[K] ? T_1 extends undefined ? {}[K] : T_1 : never : never : T[K]; } : {} & T : never : never) ? T_2 extends any ? { [K_1 in keyof T_2]: K_1 extends "class" ? { readonly class: string; @@ -3824,7 +4005,8 @@ export declare function createFieldLabelProps, (typeof INPUT_KEYS)[number]>; +import { JSX } from "@solidjs/web"; +export declare const INPUT_KEYS: readonly ["aria-label", "aria-labelledby", "aria-describedby", "aria-details", "aria-autocomplete", "aria-controls", "aria-activedescendant", "aria-expanded", "aria-haspopup", "aria-keyshortcuts", "aria-invalid", "aria-required", "aria-busy", "aria-disabled", "aria-hidden", "aria-errormessage", "aria-live", "aria-atomic", "aria-relevant", "aria-roledescription", "aria-description", "aria-owns", "aria-flowto", "aria-current", "aria-pressed", "aria-checked", "aria-selected", "aria-multiline", "aria-multiselectable", "aria-orientation", "aria-readonly", "aria-placeholder", "aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-valuetext", "aria-posinset", "aria-setsize", "aria-level", "aria-modal", "aria-sort", "aria-rowcount", "aria-rowindex", "aria-rowspan", "aria-colcount", "aria-colindex", "aria-colspan", "autocomplete", "inputmode", "enterkeyhint", "spellcheck", "type", "maxlength", "minlength", "pattern", "autofocus"]; +export type FieldInputProps = { + [Key in (typeof INPUT_KEYS)[number]]?: Key extends "aria-describedby" | "aria-label" | "aria-labelledby" ? string : JSX.InputHTMLAttributes[Key]; +}; export type FieldClasses = Partial>; ``` +## components/HoverCard/HoverCard.d.ts + +```ts +import { type HoverCardClasses } from "@codeui/styles/hovercard"; +import { type PolymorphicProps } from "@kobalte/core/polymorphic"; +import type { PopoverAnchorProps as KPopoverAnchorProps, PopoverRootOptions as KPopoverRootOptions } from "@kobalte/core/popover"; +import { type ParentProps } from "solid-js"; +import { type JSX, type ValidComponent } from "@solidjs/web"; +import { type HoverCardDismissHandlers, type HoverCardPositioning } from "./HoverCardHost.js"; +export { hoverCardParts, hoverCardStyles, type HoverCardPart, type HoverCardClasses, type HoverCardStyles, } from "@codeui/styles/hovercard"; +export { HoverCardGroup, type HoverCardGroupProps } from "./HoverCardHost.js"; +export type HoverCardProps = HoverCardPositioning & Pick & { + /** Time in ms from when the pointer enters or the trigger gets focus until the card opens. Defaults to 500. */ + openDelay?: number; + /** Time in ms from when the pointer leaves the trigger and the card until it closes. Defaults to 150. */ + closeDelay?: number; + /** Close as soon as the pointer leaves, even on its way from the trigger to the card. */ + ignoreSafeArea?: boolean; + /** + * Share the card with the other hover cards of the page, or of the nearest `HoverCardGroup`. + * Defaults to true. With false, or with `forceMount`, the card has a surface of its own. + */ + shared?: boolean; +}; +/** + * Kobalte alpha.5's HoverCard root adds its pointer listener inside an effect + * callback, which Solid 2 rejects as soon as the card opens. The card is built + * on Kobalte's Popover instead, one popover shared by many cards (see + * `HoverCardHost`): Popper places it and its dismissable layer handles Escape + * and outside presses. The hover and focus timers below follow Kobalte's + * HoverCard. Return to `@kobalte/core/hover-card` once it registers the + * listener from an effect cleanup. + */ +export declare function HoverCard(props: ParentProps): JSX.Element; +export type HoverCardTriggerProps = KPopoverAnchorProps & { + class?: string; + onPointerEnter?: JSX.EventHandlerUnion; + onPointerLeave?: JSX.EventHandlerUnion; + onFocus?: JSX.EventHandlerUnion; + onBlur?: JSX.EventHandlerUnion; + onPointerDown?: JSX.EventHandlerUnion; + onClick?: JSX.EventHandlerUnion; +}; +/** + * The element that opens the card on hover, on keyboard focus and on click. Renders an `a`: + * give it an `href`, or render another focusable element with `as`. On a touch screen the + * first tap on a closed card opens it instead of following the link; the next tap follows it. + */ +export declare function HoverCardTrigger(props: PolymorphicProps>): JSX.Element; +export type HoverCardContentProps = Omit, "style"> & HoverCardDismissHandlers & { + class?: string; + style?: JSX.CSSProperties | string; + /** Node the card is portaled into. Defaults to `document.body`. */ + mount?: globalThis.Element; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: Pick; +}; +/** + * The card's content. It renders into the surface its `HoverCard` shares, which is portaled, + * placed beside the trigger (on the right unless there is no room), and never takes focus. + * Its class, style, ref, attributes and event handlers go on that surface while this card is + * the one shown. Hover cards inside the content get a surface of their own, so the card stays + * open beside them. + */ +export declare function HoverCardContent(props: HoverCardContentProps): JSX.Element; +export type HoverCardListProps = JSX.HTMLAttributes & { + /** Names the list for assistive technology, for example "Subtasks". */ + "aria-label"?: string; +}; +/** + * A list of entries inside a hover card. It caps near 24rem and scrolls on its own, + * so the card keeps its size however many entries it holds. + */ +export declare function HoverCardList(props: HoverCardListProps): JSX.Element; +export type HoverCardItemProps = Omit, "children"> & { + /** State icon, 16px. The slot stays empty without it, so entries align. A finished entry shows no icon. */ + icon?: JSX.Element; + /** Names the state the icon shows, such as "Running". Without it the icon is decorative. */ + iconLabel?: string; + /** Short identifier, such as `#142` or `T-3`. Shown before the title in secondary text. */ + identifier?: JSX.Element; + /** Nesting level, from 0. Each level indents the entry by `--cui-hovercard-item-indent`. */ + depth?: number; + /** The title. It stays on one line and truncates. */ + children?: JSX.Element; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: Pick; +}; +/** One line in a `HoverCardList`: state icon, identifier, then the title truncated. */ +export declare function HoverCardItem(props: HoverCardItemProps): JSX.Element; +``` + +## components/HoverCard/HoverCardHost.d.ts + +```ts +import { type HoverCardClasses } from "@codeui/styles/hovercard"; +import { type PopoverContentProps as KPopoverContentProps, type PopoverRootOptions as KPopoverRootOptions } from "@kobalte/core/popover"; +import { type Accessor, type ParentProps } from "solid-js"; +import { type JSX } from "@solidjs/web"; +export type HoverCardPositioning = Pick; +export type HoverCardDismissHandlers = Pick; +/** What the active card asks of the shared surface: its classes, attributes and handlers. */ +export type HoverCardSurfaceOptions = HoverCardDismissHandlers & { + class?: string; + classes?: Pick; + style?: JSX.CSSProperties | string; + mount?: globalThis.Element; + ref: (element: HTMLElement) => void; + /** Every other prop of `HoverCardContent`: attributes and event handlers. */ + attributes: Record; +}; +export type Point = { + x: number; + y: number; +}; +/** One `HoverCard` as the host sees it. */ +export type HoverCardEntry = { + trigger: Accessor; + positioning: HoverCardPositioning; + surface: Accessor; + /** True when the point is on the trigger, on the card, or on the way between them. */ + covers: (point: Point) => boolean; + /** The host showed another card or closed this one: update the card's own state. */ + dismiss: () => void; +}; +export declare const positioningKeys: (keyof HoverCardPositioning)[]; +type HostOptions = { + skipDelayDuration?: number; + forceMount?: boolean; + /** Renders the surface the first time a card opens. Hosts rendered in the tree leave it out. */ + mount?: (host: HoverCardHost) => void; +}; +type Size = { + width: number; + height: number; +}; +/** + * How the surface moves to the next card. A keyboard move swaps in place (Inkstone: nothing + * from the keyboard animates). Reduced motion keeps only the content fade. + */ +type Morph = { + kind: "move"; + from: Size; +} | { + kind: "fade"; +}; +/** + * One floating surface that every card of a group, or of the page, shares. + * Opening a card while another is open, or shortly after it closed, moves the + * surface to the new trigger and swaps the content instead of closing one card + * and opening another. + */ +export declare function createHoverCardHost(options?: HostOptions): { + current: import("solid-js").SourceAccessor; + open: import("solid-js").SourceAccessor; + surface: import("solid-js").SourceAccessor; + slot: import("solid-js").SourceAccessor; + setSlot: import("solid-js").Setter; + forceMount: () => boolean; + recentlyClosed: () => boolean; + setSurface(next: HTMLElement | undefined): void; + showing: (entry: HoverCardEntry) => boolean; + slotFor: (entry: HoverCardEntry) => HTMLElement | undefined; + /** 0 to open at once, or undefined to wait for the card's own `openDelay`. */ + openDelay(entry: HoverCardEntry, point?: Point): number | undefined; + /** Makes the entry the one whose content the surface holds, without opening it. */ + attach(entry: HoverCardEntry): void; + show(entry: HoverCardEntry): void; + hide(entry: HoverCardEntry): void; + /** Escape, a press outside, or a focus outside closed the surface. */ + dismiss(): void; + /** The card unmounted. Its content leaves with it, so the surface closes without an exit. */ + release(entry: HoverCardEntry): void; + takeMorph(): Morph | undefined; +}; +export type HoverCardHost = ReturnType; +/** The host of the nearest `HoverCardGroup`, or the one the whole page shares. */ +export declare function useHoverCardHost(): HoverCardHost; +export type HoverCardGroupProps = ParentProps<{ + /** Time in ms after a card closes during which the next card in the group opens at once. Defaults to 400. */ + skipDelayDuration?: number; +}>; +/** + * Gives the hover cards inside it their own surface. Moving between their triggers moves + * that card, and they never take over the surface of the cards outside the group. + */ +export declare function HoverCardGroup(props: HoverCardGroupProps): JSX.Element; +/** Makes `host` the surface of the hover cards below it, and renders that surface. */ +export declare function HoverCardHostProvider(props: ParentProps<{ + host: HoverCardHost; +}>): JSX.Element; +/** + * True when `target` is inside `element`, following portals back to where they were + * declared. A hover card opened from inside another card is portaled to the body, but + * Solid links its nodes to their declaration inside the outer card. + */ +export declare function withinPortal(target: EventTarget | null, element: Node | undefined): boolean; +/** The popover the host places next to the active trigger. */ +export declare function HoverCardSurface(props: { + host: HoverCardHost; +}): JSX.Element; +export {}; +``` + ## components/IconButton/IconButton.d.ts ```ts -import { ValidComponent } from "solid-js"; +import { ValidComponent } from "@solidjs/web"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; import { ButtonRootProps as KButtonRootProps } from "@kobalte/core/button"; import { type ButtonVariants } from "../Button/Button.css.js"; @@ -3887,7 +4275,7 @@ export type IconButtonProps = KButtonRootPr loading?: boolean; "aria-label": string; }; -export declare function IconButton(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function IconButton(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; ``` ## components/Kbd/Kbd.d.ts @@ -3899,7 +4287,7 @@ export type KbdProps = K.RootProps & { classes?: K.KbdClasses; }; /** One key or key label. Render a sequence as several Kbd elements. */ -export declare function Kbd(props: KbdProps): import("solid-js").JSX.Element; +export declare function Kbd(props: KbdProps): import("@solidjs/web").JSX.Element; ``` ## components/Link/Link.css.d.ts @@ -3912,11 +4300,11 @@ export * from "@codeui/styles/internal/components/Link/Link.css"; ```ts import { LinkRootProps as KLinkRootProps } from "@kobalte/core/link"; -import { ValidComponent } from "solid-js"; +import { ValidComponent } from "@solidjs/web"; import * as styles from "./Link.css.js"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; type LinkProps = KLinkRootProps & styles.LinkVariants; -export declare function Link(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function Link(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; export {}; ``` @@ -3924,7 +4312,8 @@ export {}; ```ts import type { PolymorphicProps } from "@kobalte/core/polymorphic"; -import { type JSXElement, type ValidComponent } from "solid-js"; +import { type Element } from "solid-js"; +import { type ValidComponent } from "@solidjs/web"; import * as P from "../../parts/listbox.js"; export type ListboxClasses = Partial>; export interface ListboxProps extends Omit, "renderItem"> { @@ -3932,17 +4321,17 @@ export interface ListboxProps classes?: ListboxClasses; size?: "xs" | "sm" | "md"; variant?: "primary" | "neutral"; - itemLabel?: (item: Option) => JSXElement; + itemLabel?: (item: Option) => Element; bordered?: boolean; } -export declare function Listbox(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function Listbox(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; export interface ListboxItemProps extends P.ItemProps { class?: string; classes?: ListboxClasses; size?: "xs" | "sm" | "md"; - itemLabel?: (item: Item) => JSXElement; + itemLabel?: (item: Item) => Element; } -export declare function ListboxItem(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function ListboxItem(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; ``` ## components/Listbox/VirtualizedListbox.d.ts @@ -3962,7 +4351,7 @@ interface Item { label: string; disabled?: boolean; } -export declare function VirtualizedListbox(props: VirtualizedListboxProps): import("solid-js").JSX.Element; +export declare function VirtualizedListbox(props: VirtualizedListboxProps): import("@solidjs/web").JSX.Element; export {}; ``` @@ -3970,7 +4359,8 @@ export {}; ```ts import type { TextFieldRootOptions as KTextFieldRootOptions } from "@kobalte/core/text-field"; -import { type JSX, type Ref } from "solid-js"; +import { type Ref } from "solid-js"; +import { type JSX } from "@solidjs/web"; import type { SlotProp } from "../../utils/component.js"; import type { FieldWithErrorMessageSupport } from "../Field/FieldError/createFieldErrorMessageProps.js"; import type { BaseFieldProps } from "../Field/createBaseFieldProps.js"; @@ -4000,7 +4390,7 @@ export { NumberFieldLabel } from "./NumberFieldLabel.js"; ```ts import { TextField as KTextField } from "@kobalte/core/text-field"; type TextFieldLabelProps = Parameters<(typeof KTextField)["Label"]>[0] & {}; -export declare function NumberFieldLabel(props: TextFieldLabelProps): import("solid-js").JSX.Element; +export declare function NumberFieldLabel(props: TextFieldLabelProps): import("@solidjs/web").JSX.Element; export {}; ``` @@ -4051,7 +4441,8 @@ export declare const defaultNumberFormat: NumberFormatSettings; ## components/OptionCard/OptionCard.d.ts ```ts -import { type Accessor, type JSX } from "solid-js"; +import { type Accessor } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/option-card.js"; export type OptionCardEntry = { value: T; @@ -4093,7 +4484,7 @@ export interface PaginationProps extends P.PaginationOptions { rounded?: boolean; size?: PaginationItemSize; } -export declare function Pagination(props: PaginationProps): import("solid-js").JSX.Element; +export declare function Pagination(props: PaginationProps): import("@solidjs/web").JSX.Element; export {}; ``` @@ -4108,7 +4499,8 @@ export * from "@codeui/styles/internal/components/Popover/Popover.css"; ```ts import type { PopoverRootOptions as KPopoverRootOptions } from "@kobalte/core/popover"; import type { PolymorphicProps } from "@kobalte/core/polymorphic"; -import { type JSX, type ParentProps, type ValidComponent } from "solid-js"; +import { type ParentProps } from "solid-js"; +import { type JSX, type ValidComponent } from "@solidjs/web"; import * as P from "../../parts/popover.js"; export declare const PopoverTrigger: typeof P.Trigger; export type PopoverProps = KPopoverRootOptions; @@ -4118,7 +4510,7 @@ export type PopoverContentProps = P.ContentPro /** Short text that describes the popover. It is linked with `aria-describedby`. */ description?: JSX.Element; /** Node the popover is portaled into. Defaults to `document.body`. */ - mount?: Node; + mount?: globalThis.Element; /** Classes for the parts this component renders, keyed by part name. */ classes?: Pick; }; @@ -4128,7 +4520,7 @@ export declare function PopoverContent(props: ## components/Progress/Progress.d.ts ```ts -import { type JSX } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/progress.js"; export type ProgressProps = Omit & { class?: string; @@ -4149,21 +4541,54 @@ export type { ProgressClasses, ProgressPart, ProgressVariants, ProgressStyles, } ```ts import type { PolymorphicProps } from "@kobalte/core/polymorphic"; import type { RadioGroupItemProps as KRadioGroupItemProps, RadioGroupRootProps as KRadioGroupRootProps } from "@kobalte/core/radio-group"; -import { type JSXElement, type ValidComponent } from "solid-js"; +import { type Element } from "solid-js"; +import { type ValidComponent } from "@solidjs/web"; import * as P from "../../parts/radio-list.js"; import type { FieldWithErrorMessageSupport } from "../Field/FieldError/createFieldErrorMessageProps.js"; export type RadioListProps = KRadioGroupRootProps & Pick & FieldWithErrorMessageSupport & { - label?: JSXElement; - description?: JSXElement; + label?: Element; + description?: Element; classes?: RadioListClasses; }; export type RadioListClasses = Partial>; export type RadioListItemProps = KRadioGroupItemProps & { - label?: JSXElement; + label?: Element; classes?: RadioListClasses; }; -export declare function RadioListItem(props: PolymorphicProps>): import("solid-js").JSX.Element; -export declare function RadioList(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function RadioListItem(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export declare function RadioList(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +``` + +## components/Resizable/Resizable.d.ts + +```ts +import { type ResizableClasses } from "@codeui/styles/resizable"; +import type { PolymorphicProps } from "@kobalte/core/polymorphic"; +import { type HandleProps as KHandleProps, type PanelProps as KPanelProps, type RootProps as KRootProps } from "@kobalte/core/resizable"; +import { type ValidComponent } from "@solidjs/web"; +export { resizableParts, resizableStyles, type ResizablePart, type ResizableClasses, type ResizableOrientation, type ResizableStyles, } from "@codeui/styles/resizable"; +export type { ResizableSize, ResizeStrategy } from "@kobalte/core/resizable"; +export type ResizableProps = KRootProps & { + class?: string; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: Pick; +}; +/** Lays out `ResizablePanel`s in a row or a column, split by `ResizableHandle`s. */ +export declare function Resizable(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export type ResizablePanelProps = KPanelProps & { + class?: string; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: Pick; +}; +/** A pane whose size is a fraction of the root or a `"240px"` string. */ +export declare function ResizablePanel(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; +export type ResizableHandleProps = KHandleProps & { + class?: string; + /** Classes for the parts this component renders, keyed by part name. */ + classes?: Pick; +}; +/** The separator between two panels. Drag it, or focus it and use the arrow keys. */ +export declare function ResizableHandle(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; ``` ## components/SegmentedControl/SegmentedControl.css.d.ts @@ -4185,25 +4610,26 @@ export type SegmentedControlProps = Omit & { } & SlotProp; export type SegmentedControlClasses = Partial>; type SegmentedControlSlot = "root" | "list" | "indicator"; -export declare function SegmentedControl(props: PolymorphicProps<"div", SegmentedControlProps>): import("solid-js").JSX.Element; +export declare function SegmentedControl(props: PolymorphicProps<"div", SegmentedControlProps>): import("@solidjs/web").JSX.Element; export {}; ``` ## components/SegmentedControl/SegmentedControlItem.d.ts ```ts -import { ValidComponent } from "solid-js"; +import { ValidComponent } from "@solidjs/web"; import { TabsTriggerProps } from "@kobalte/core/tabs"; import { PolymorphicProps } from "@kobalte/core/polymorphic"; export type SegmentedControlItemProps = TabsTriggerProps; -export declare function SegmentedControlItem(props: PolymorphicProps>): import("solid-js").JSX.Element; +export declare function SegmentedControlItem(props: PolymorphicProps>): import("@solidjs/web").JSX.Element; ``` ## components/Select/Select.d.ts ```ts import type { SelectItemProps as KSelectItemProps, SelectRootProps as KSelectRootProps } from "@kobalte/core/select"; -import { type Accessor, type JSX, type JSXElement, type ParentProps } from "solid-js"; +import { type Accessor, type Element, type ParentProps } from "solid-js"; +import { type JSX } from "@solidjs/web"; import * as P from "../../parts/select.js"; import type { BaseFieldProps } from "../Field/createBaseFieldProps.js"; import type { FieldWithErrorMessageSupport } from "../Field/FieldError/createFieldErrorMessageProps.js"; @@ -4222,14 +4648,14 @@ export type SelectProps = KSelectRootProps JSXElement; - valueComponent?: (state: Accessor