mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
fix(app): use consistent dialog sizes (#63432)
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@
|
||||
"dev:desktop": "bun --cwd packages/desktop dev",
|
||||
"dev:web": "bun --cwd packages/app dev",
|
||||
"dev:site": "bun run --cwd services/site dev",
|
||||
"lint": "oxlint && ast-grep scan -c script/ast-grep/gui-plugins/sgconfig.yml && bun script/sdk-docs.ts && bun script/check-greys.ts",
|
||||
"lint": "oxlint && ast-grep scan -c script/ast-grep/gui-plugins/sgconfig.yml && ast-grep scan --rule script/ast-grep/dialog-size.yml packages && bun script/sdk-docs.ts && bun script/check-greys.ts",
|
||||
"lint:changed": "bun script/lint-changed.ts",
|
||||
"lint:effect-patterns": "ast-grep scan -c script/ast-grep/sgconfig.yml packages/util/src packages/core/src packages/server/src packages/protocol/src packages/cli/src",
|
||||
"lint:effect-simplifications": "ast-grep scan -c script/ast-grep/effect-simplifications/sgconfig.yml --off=unused-suppression packages",
|
||||
|
||||
@@ -778,7 +778,7 @@ test("titlebar session search shrinks with results while its field stays anchore
|
||||
await expect(options).toHaveCount(23)
|
||||
const scroll = dialog.locator('[data-slot="search-list-scroll"]')
|
||||
await expect.poll(() => scroll.evaluate((element) => element.scrollHeight - element.clientHeight)).toBeGreaterThan(0)
|
||||
await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(480)
|
||||
await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(600)
|
||||
const last = dialog.getByRole("option", { name: /Compact keeper result 22/ })
|
||||
await expect(last).not.toBeInViewport()
|
||||
await scroll.hover()
|
||||
|
||||
@@ -456,7 +456,7 @@ test("the MCP list shrinks with matches and keeps its search anchored while scro
|
||||
const scroll = view.panel.locator('[data-slot="search-list-scroll"]')
|
||||
|
||||
await expect.poll(() => scroll.evaluate((element) => element.scrollHeight - element.clientHeight)).toBeGreaterThan(0)
|
||||
await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(480)
|
||||
await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(600)
|
||||
await input.press("End")
|
||||
const last = view.panel.getByRole("option", { name: "server-23", exact: true })
|
||||
|
||||
@@ -635,7 +635,8 @@ for (const surface of ["popover", "dialog"] as const) {
|
||||
for (const surface of ["popover", "dialog"] as const) {
|
||||
test(`long MCP names keep their status and controls visible in the ${surface}`, async ({ page }) => {
|
||||
const names = ["connected", "disabled", "failed", "needs_auth"].map(
|
||||
(status) => `long-${status}-mcp-server-for-the-internal-knowledge-base-search`,
|
||||
(status) =>
|
||||
`long-${status}-mcp-server-for-the-internal-knowledge-base-search-across-every-team-workspace-repository-and-shared-drive`,
|
||||
)
|
||||
|
||||
const actions: string[] = []
|
||||
|
||||
@@ -1154,7 +1154,7 @@ test("the location dialog separates added projects from server projects and tags
|
||||
await expect(options.nth(0)).toHaveCSS("height", "28px")
|
||||
await expect(dialog.locator(".palette-menu-search [data-component='text-input-v2']")).toHaveCSS("height", "28px")
|
||||
await expect(dialog.locator(".new-session-location-hints")).toHaveCount(0)
|
||||
await expect(dialog.locator("..")).toHaveCSS("width", "480px")
|
||||
await expect(dialog.locator("..")).toHaveCSS("width", "880px")
|
||||
await expect(options.nth(0)).toHaveCSS("display", "flex")
|
||||
await expect(names.nth(0).locator(".command-palette-title")).toHaveCSS("font-size", "13px")
|
||||
await expect(names.nth(0).locator(".command-palette-title")).toHaveCSS("white-space", "nowrap")
|
||||
|
||||
@@ -1929,7 +1929,7 @@ test("providers: the free tier upsell opens Go on its own, sized to its content"
|
||||
await expect(dialog.getByPlaceholder("API key")).toBeVisible()
|
||||
// Nothing to go back to: the upsell opened the dialog straight on Go.
|
||||
await expect(dialog.getByRole("navigation").getByRole("button")).toHaveCount(0)
|
||||
await expect.poll(async () => (await container.boundingBox())?.height).toBeLessThan(512)
|
||||
await expect.poll(async () => (await container.boundingBox())?.height).toBeLessThan(368)
|
||||
})
|
||||
|
||||
test("providers: the connect dialog lists connected providers and manages their accounts", async ({ page }) => {
|
||||
@@ -1981,7 +1981,8 @@ test("providers: the connect dialog lists connected providers and manages their
|
||||
await expect(dialog.locator('[data-provider-id="linear"]')).toHaveCount(0)
|
||||
await expect(dialog.getByText("MCP", { exact: true })).toHaveCount(0)
|
||||
const container = page.locator('[data-slot="dialog-container"]')
|
||||
await expect.poll(async () => (await container.boundingBox())?.height).toBe(512)
|
||||
await expect(container).toHaveCSS("width", "480px")
|
||||
await expect(container).toHaveCSS("max-height", "368px")
|
||||
const picker = await container.boundingBox()
|
||||
await openai.click()
|
||||
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
[data-component="dialog-v2"]:has(.new-session-location) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"]:has(.new-session-location) [data-slot="dialog-container"] {
|
||||
width: min(calc(100vw - 24px), 480px);
|
||||
height: auto;
|
||||
max-height: min(calc(100vh - 96px), 480px);
|
||||
min-height: 0;
|
||||
margin-top: max(48px, calc((100vh - 480px) / 2));
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
}
|
||||
|
||||
.new-session-location .palette-menu-search {
|
||||
padding: 6px 6px 0;
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ function NewSessionLocationDialog(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog class="command-palette new-session-location" size="large">
|
||||
<Dialog class="command-palette new-session-location" size="large" fit>
|
||||
<DialogBody class="command-palette-body">
|
||||
<div class="palette-menu-search">
|
||||
<TextInput
|
||||
|
||||
@@ -11,7 +11,7 @@ export function DialogChatGPTUsageLimit() {
|
||||
const platform = usePlatform()
|
||||
|
||||
return (
|
||||
<Dialog fit containerClass="!w-[min(calc(100vw_-_32px),390px)] !rounded-xl">
|
||||
<Dialog fit containerClass="!rounded-xl">
|
||||
<div class="flex w-full flex-col items-center px-8 pb-8 pt-9 text-center [font-family:var(--v2-font-family-sans)]">
|
||||
<ProviderIcon id="openai" class="!size-12 text-v2-icon-icon-base" aria-hidden="true" />
|
||||
<div class="mt-6 max-w-[270px] text-[20px] font-[530] leading-7 tracking-[-0.3px] text-v2-text-text-base">
|
||||
@@ -34,12 +34,7 @@ export function DialogChatGPTUsageLimit() {
|
||||
>
|
||||
{language.t("provider.connect.chatgptUsageLimit.manage")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="large"
|
||||
class="mt-2 w-full"
|
||||
onClick={() => dialog.close()}
|
||||
>
|
||||
<Button variant="ghost" size="large" class="mt-2 w-full" onClick={() => dialog.close()}>
|
||||
{language.t("provider.connect.chatgptUsageLimit.close")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ export function DialogChatGPTPlanWelcome() {
|
||||
const language = useLanguage()
|
||||
|
||||
return (
|
||||
<Dialog fit containerClass="!w-[min(calc(100vw_-_32px),390px)] !rounded-xl">
|
||||
<Dialog fit containerClass="!rounded-xl">
|
||||
<div class="flex w-full flex-col items-center px-8 pb-8 pt-9 text-center [font-family:var(--v2-font-family-sans)]">
|
||||
<ProviderIcon id="openai" class="!size-12 text-v2-icon-icon-base" aria-hidden="true" />
|
||||
<div class="mt-6 max-w-[270px] text-[20px] font-[530] leading-7 tracking-[-0.3px] text-v2-text-text-base">
|
||||
|
||||
@@ -27,7 +27,7 @@ import { Persistence } from "@/runtime/persistence/schema"
|
||||
import { Schema } from "effect"
|
||||
import type { FormField, IntegrationInfo } from "@opencode/client/promise"
|
||||
import { createProviderDialogController, modelKey } from "./controller"
|
||||
import { CONSOLE_INTEGRATION, type ProviderDialogBody, type ProviderDialogFrame } from "./dialog-machine"
|
||||
import { CONSOLE_INTEGRATION, type ProviderDialogBody } from "./dialog-machine"
|
||||
import { connectMethods, selectProviderConnectView, type ProviderConnectMethod } from "./machine"
|
||||
import type { ProviderFormInput, ProviderFormView } from "./form-machine"
|
||||
import { ConsoleAuthorization } from "./console"
|
||||
@@ -59,14 +59,6 @@ type ProviderDialogController = ReturnType<typeof createProviderDialogController
|
||||
// What a step without a sign-in reads, so the sign-in views never branch on a missing one.
|
||||
const NO_CONNECT = selectProviderConnectView({ status: "disposed" })
|
||||
|
||||
// A provider step fits its content; the list and the models keep a fixed height.
|
||||
const FRAME_HEIGHT = {
|
||||
picker: "!h-[min(calc(100vh_-_16px),512px)]",
|
||||
models: "!h-[min(calc(100vh_-_8px_-_var(--connect-top)),560px)]",
|
||||
accounts: "!h-auto !max-h-[min(calc(100vh_-_8px_-_var(--connect-top)),560px)]",
|
||||
provider: "!h-auto !max-h-[min(calc(100vh_-_8px_-_var(--connect-top)),560px)]",
|
||||
} satisfies Record<ProviderDialogFrame, string>
|
||||
|
||||
export const DialogConnectProvider: Component<{
|
||||
directory?: string
|
||||
/** Connects at the server's default Location instead of the current route's directory. */
|
||||
@@ -115,11 +107,10 @@ export const DialogConnectProvider: Component<{
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
size="normal"
|
||||
fit
|
||||
anchored
|
||||
preventBackdropDismiss={view().preventBackdropDismiss}
|
||||
// The top edge stays where the provider list puts it, so a step that fits its content only moves the bottom edge.
|
||||
containerClass={`!self-start !rounded-[12px] !bg-v2-background-bg-base [--connect-top:max(8px,calc((100vh_-_512px)/2))] !mt-[var(--connect-top)] !w-[min(calc(100vw_-_16px),640px)] ${
|
||||
FRAME_HEIGHT[frame()]
|
||||
}`}
|
||||
onCloseAutoFocus={(event) => {
|
||||
if (view().completed && props.selection && props.onDone) {
|
||||
event.preventDefault()
|
||||
@@ -405,8 +396,8 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="relative min-h-0 flex-1">
|
||||
<div class="flex size-full min-h-0 flex-col gap-0.5 overflow-y-auto pb-8 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
<div class="relative flex min-h-0 flex-1 flex-col">
|
||||
<div class="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto pb-8 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
<For each={groups()}>
|
||||
{(group) => (
|
||||
<Show when={group.items().length > 0}>
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
padding: 0 6px 8px;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"]:has(.settings-manage-models-dialog) [data-slot="dialog-container"] {
|
||||
border-radius: 12px;
|
||||
background: var(--v2-background-bg-base);
|
||||
}
|
||||
|
||||
.settings-manage-models-dialog .settings-panel.settings-models {
|
||||
height: 100%;
|
||||
gap: 0;
|
||||
|
||||
@@ -37,13 +37,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"]:has(.model-dialog) [data-slot="dialog-container"] {
|
||||
width: min(calc(100vw - 24px), 480px);
|
||||
min-height: 0;
|
||||
border-radius: 12px;
|
||||
background: var(--v2-background-bg-base);
|
||||
}
|
||||
|
||||
.model-dialog {
|
||||
/* The inset lives on the field and the rows, so the scroll area and its scrollbar reach the dialog's edges. */
|
||||
[data-component="search-list"] {
|
||||
|
||||
@@ -979,7 +979,7 @@ export function DialogSelectModel(props: { provider?: string; model?: ModelState
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog class="command-palette model-dialog" size="large">
|
||||
<Dialog class="command-palette model-dialog" size="large" fit>
|
||||
<div class="sr-only">
|
||||
<DialogTitle>{language.t("dialog.model.select.title")}</DialogTitle>
|
||||
</div>
|
||||
|
||||
@@ -82,14 +82,14 @@ export const DialogSelectModelUnpaid: Component<{ model?: ModelState }> = (props
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
size="large"
|
||||
fit
|
||||
containerClass="!h-auto max-h-[calc(100vh_-_16px)] !w-[min(calc(100vw_-_16px),640px)]"
|
||||
class="[font-family:var(--v2-font-family-sans)] [&_[data-slot=dialog-header]]:!px-5 [&_[data-slot=dialog-header-title]]:!text-[15px] [&_[data-slot=dialog-header-title]]:!tracking-[-0.13px]"
|
||||
>
|
||||
<DialogHeader closeLabel={language.t("common.close")}>
|
||||
<DialogTitle>{language.t("dialog.model.select.title")}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<DialogBody class="max-h-[calc(100vh_-_68px)] min-h-0 flex-none gap-0">
|
||||
<DialogBody class="min-h-0 gap-0">
|
||||
<MenuScroll viewportClass="px-2 pb-2">
|
||||
<div ref={listEl} class="flex min-h-0 flex-col">
|
||||
<div data-section="free-models" class="flex w-full flex-col items-start pb-3">
|
||||
|
||||
@@ -118,7 +118,7 @@ export function ForkDialog(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog class="command-palette command-palette-compact fork-dialog" fit>
|
||||
<Dialog class="command-palette command-palette-compact fork-dialog" size="large" fit>
|
||||
<div class="sr-only">
|
||||
<DialogTitle>{language.t("command.session.fork")}</DialogTitle>
|
||||
</div>
|
||||
|
||||
@@ -82,7 +82,7 @@ export function JumpToMessage(props: {
|
||||
let list!: SearchListHandle<ReturnType<typeof rows>[number]>
|
||||
|
||||
return (
|
||||
<Dialog class="command-palette command-palette-compact fork-dialog" fit>
|
||||
<Dialog class="command-palette command-palette-compact fork-dialog" size="large" fit>
|
||||
<div class="sr-only">
|
||||
<DialogTitle>{language.t("dialog.jump.title")}</DialogTitle>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function DialogThirdPartyNotices() {
|
||||
const language = useLanguage()
|
||||
|
||||
return (
|
||||
<Dialog size="large">
|
||||
<Dialog size="x-large">
|
||||
<DialogHeader>
|
||||
<DialogTitleGroup
|
||||
title={language.t("settings.about.notices.title")}
|
||||
|
||||
@@ -579,10 +579,6 @@
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"][data-variant="settings"] [data-slot="dialog-container"] {
|
||||
background: var(--v2-background-bg-base);
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"][data-variant="settings"] [data-slot="dialog-body"] {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
@@ -2164,17 +2160,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-container"] {
|
||||
width: 480px;
|
||||
max-width: calc(100vw - 32px);
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-content"] {
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-header"] {
|
||||
|
||||
@@ -2,15 +2,6 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Keep a fixed height so the dialog does not resize as results change while typing. */
|
||||
[data-component="dialog-v2"]:has(.command-palette) [data-slot="dialog-container"] {
|
||||
width: min(calc(100vw - 24px), 640px);
|
||||
height: min(calc(100vh - 96px), 480px);
|
||||
border-radius: 12px;
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-floating);
|
||||
}
|
||||
|
||||
.command-palette-body {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
@@ -137,21 +128,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Like the project picker, results grow down from a stable search-field anchor. Other picker dialogs keep their layout. */
|
||||
[data-component="dialog-v2"]:has(.command-palette-compact) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"]:has(.command-palette-compact) [data-slot="dialog-container"] {
|
||||
width: min(calc(100vw - 24px), 480px);
|
||||
height: auto;
|
||||
max-height: min(calc(100vh - 96px), 480px);
|
||||
min-height: 0;
|
||||
margin-top: max(48px, calc((100vh - 480px) / 2));
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
}
|
||||
|
||||
.command-palette-compact {
|
||||
[data-slot="search-list-search"] {
|
||||
position: relative;
|
||||
|
||||
@@ -446,7 +446,7 @@ function UsageFrame(props: { children: JSX.Element; footer?: JSX.Element }) {
|
||||
const language = useLanguage()
|
||||
|
||||
return (
|
||||
<Dialog fit containerClass="w-[min(calc(100vw-32px),512px)]!">
|
||||
<Dialog fit>
|
||||
<div data-component="usage-dialog" class="flex flex-col self-stretch">
|
||||
<DialogHeader>
|
||||
<DialogTitleGroup title={language.t("usage.title")} />
|
||||
|
||||
@@ -383,7 +383,7 @@ function DialogPairing(props: {
|
||||
const frame = "mx-auto aspect-square w-full max-w-[calc(100dvh-360px)] shrink-0 rounded-[6px]"
|
||||
|
||||
return (
|
||||
<Dialog fit containerClass="max-w-[min(400px,calc(100vw-32px))]">
|
||||
<Dialog fit>
|
||||
<DialogHeader>
|
||||
<DialogTitleGroup title={ctx.t("pair.title")} description={ctx.t("dialog.description")} />
|
||||
</DialogHeader>
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
/* The same rules as the app's server dialog in settings.css, which may not be loaded when the palette opens this one. */
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-container"] {
|
||||
width: 480px;
|
||||
max-width: calc(100vw - 32px);
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-content"] {
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-server-dialog [data-slot="dialog-header"] {
|
||||
|
||||
@@ -217,11 +217,7 @@ function DialogReleaseNotes(props: { highlights: readonly Highlight[]; dialog: D
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
size="large"
|
||||
fit
|
||||
class="w-[min(calc(100vw-40px),720px)] h-[min(calc(100vh-40px),400px)] -mt-20 min-h-0 overflow-hidden"
|
||||
>
|
||||
<Dialog size="large" class="min-h-0 overflow-hidden">
|
||||
<div class="flex flex-1 min-w-0 min-h-0" tabIndex={0} autofocus onKeyDown={handleKeyDown}>
|
||||
{/* Left side - Text content */}
|
||||
<div class="flex flex-col flex-1 min-w-0 p-8">
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
[data-component="dialog-v2"].settings-wsl-dialog [data-slot="dialog-container"] {
|
||||
width: 480px;
|
||||
max-width: calc(100vw - 32px);
|
||||
height: auto;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-wsl-dialog [data-slot="dialog-content"] {
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -42,19 +34,8 @@
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-wsl-not-installed-dialog [data-slot="dialog-container"] {
|
||||
width: 480px;
|
||||
max-width: calc(100vw - 32px);
|
||||
min-height: 264px;
|
||||
height: auto;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"].settings-wsl-not-installed-dialog [data-slot="dialog-content"] {
|
||||
align-items: stretch;
|
||||
min-height: 264px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -2041,7 +2041,7 @@ function ExecuteDetails(props: { code: string; output: string; error?: string; c
|
||||
String(Math.max(lineCount(props.code), props.output && !props.error ? lineCount(output().text) : 0)).length
|
||||
|
||||
return (
|
||||
<Dialog fit containerClass="!w-[min(calc(100vw_-_32px),720px)] max-h-[calc(100vh_-_92px)]">
|
||||
<Dialog size="large" fit>
|
||||
<DialogHeader>
|
||||
<div data-slot="execute-details-title">
|
||||
<DialogTitle>{i18n.t("ui.tool.execute")}</DialogTitle>
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
width: 480px;
|
||||
height: 368px;
|
||||
width: min(calc(100vw - 32px), 480px);
|
||||
--dialog-height: min(calc(100vh - 32px), 368px);
|
||||
height: var(--dialog-height);
|
||||
max-height: calc(100vh - 32px);
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
border-radius: 6px;
|
||||
@@ -158,23 +160,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
&[data-fit] {
|
||||
[data-slot="dialog-container"] {
|
||||
height: auto;
|
||||
&:is([data-anchored], [data-size="large"], [data-size="x-large"]) {
|
||||
align-items: flex-start;
|
||||
|
||||
[data-slot="dialog-content"] {
|
||||
min-height: 0;
|
||||
}
|
||||
[data-slot="dialog-container"] {
|
||||
max-height: var(--dialog-height);
|
||||
margin-top: calc((100vh - var(--dialog-height)) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
&[data-size="large"] [data-slot="dialog-container"] {
|
||||
width: 640px;
|
||||
height: 480px;
|
||||
&:is([data-size="large"], [data-size="x-large"]) [data-slot="dialog-container"] {
|
||||
--dialog-height: min(calc(100vh - 96px), 600px);
|
||||
width: min(calc(100vw - 32px), 880px);
|
||||
background: var(--v2-background-bg-base);
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
&[data-size="x-large"] [data-slot="dialog-container"] {
|
||||
width: min(calc(100vw - 32px), 980px);
|
||||
height: min(calc(100vh - 92px), 600px);
|
||||
--dialog-height: min(calc(100vh - 96px), 680px);
|
||||
width: min(calc(100vw - 32px), 1040px);
|
||||
}
|
||||
|
||||
&[data-fit] [data-slot="dialog-container"] {
|
||||
height: auto;
|
||||
|
||||
[data-slot="dialog-content"] {
|
||||
min-height: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@ Dialog content wrapper built on Kobalte's dialog primitive with v2 styling.
|
||||
Compose with \`DialogHeader\`, \`DialogTitle\`, \`DialogTitleGroup\`, \`DialogBody\`, and \`DialogFooter\`.
|
||||
|
||||
### API
|
||||
- \`Dialog\`: \`size\` (normal | large | x-large), \`variant\`, \`fit\`.
|
||||
- \`Dialog\`: \`size\`, \`variant\`, \`fit\`.
|
||||
- \`normal\`: 480px wide, for confirmations, sign-ins and small forms.
|
||||
- \`large\`: 880×600, for palettes, pickers and lists.
|
||||
- \`x-large\`: 1040×680, for long documents and settings-like panels.
|
||||
- Sizes clamp to the window. \`fit\` makes the height follow the content up to the size's height; large sizes keep their top edge, so only the bottom edge moves.
|
||||
- Dialogs don't set their own container width or height: pick the size that fits.
|
||||
- \`DialogHeader\`: row container with optional \`closeLabel\` and \`hideClose\`.
|
||||
- \`DialogTitle\`: accessible single-line header title.
|
||||
- \`DialogTitleGroup\`: column with \`title\` and required \`description\`.
|
||||
|
||||
@@ -20,12 +20,19 @@ const TEXT_FIELD = [
|
||||
].join(", ")
|
||||
|
||||
export interface DialogProps extends ParentProps {
|
||||
/**
|
||||
* normal: 480px wide, for confirmations and small forms. large: 880×600, for palettes, pickers and lists.
|
||||
* x-large: 1040×680, for long documents and settings-like panels. Each clamps to the window.
|
||||
*/
|
||||
size?: "normal" | "large" | "x-large"
|
||||
/** Height follows the content, up to the size's height. Large sizes grow down from a fixed top edge. */
|
||||
fit?: boolean
|
||||
/** Fit within the preset's height and keep its top edge as content changes. */
|
||||
anchored?: boolean
|
||||
variant?: "default" | "settings"
|
||||
class?: ComponentProps<"div">["class"]
|
||||
containerClass?: ComponentProps<"div">["class"]
|
||||
classList?: ComponentProps<"div">["classList"]
|
||||
fit?: boolean
|
||||
onCloseAutoFocus?: ComponentProps<typeof Content>["onCloseAutoFocus"]
|
||||
preventBackdropDismiss?: boolean
|
||||
}
|
||||
@@ -108,6 +115,7 @@ export function Dialog(props: DialogProps) {
|
||||
"containerClass",
|
||||
"classList",
|
||||
"fit",
|
||||
"anchored",
|
||||
"children",
|
||||
"onCloseAutoFocus",
|
||||
"preventBackdropDismiss",
|
||||
@@ -123,6 +131,7 @@ export function Dialog(props: DialogProps) {
|
||||
data-component="dialog-v2"
|
||||
data-variant={local.variant === "settings" ? "settings" : undefined}
|
||||
data-fit={local.fit ? true : undefined}
|
||||
data-anchored={local.anchored ? true : undefined}
|
||||
data-size={local.size || "normal"}
|
||||
>
|
||||
<div data-slot="dialog-container" class={local.containerClass}>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
id: dialog-size
|
||||
language: css
|
||||
severity: error
|
||||
message: Choose a Dialog size preset instead of sizing its container or content here.
|
||||
ignores:
|
||||
- packages/ui/src/overlays/dialog/dialog.css
|
||||
rule:
|
||||
kind: declaration
|
||||
has:
|
||||
kind: property_name
|
||||
regex: '^(min-|max-)?(width|height|inline-size|block-size)$'
|
||||
inside:
|
||||
kind: block
|
||||
inside:
|
||||
kind: rule_set
|
||||
has:
|
||||
kind: selectors
|
||||
regex: '\[data-slot=["'']dialog-(container|content)["'']\][^\s>+~]*\s*(,|$)'
|
||||
Reference in New Issue
Block a user