feat(ui): show dialogs in the page as sheets without window buttons on macOS

The title heads the content instead of a title bar with drawn traffic
lights; Esc and Cancel close the dialog, and the title dims while the
window is inactive.
Цей коміт міститься в:
l0ng-ai committed 2026-11-27 08:37:23 +08:00
1 джерело d3c5055954
коміт 44338541b1
4 files changed
+15 -72

No files matched your search

+1 -1
Переглянути файл
@@ -172,7 +172,7 @@ describe("Commit dialog diff window (#1863)", () => {
? "[data-testid='diff-view']"
: location === "footer"
? "[data-dialog-footer] button"
: "[data-dialog-titlebar] button",
: "[data-dialog-titlebar]",
)!;
fireEvent.keyDown(target, { key: "w", code: "KeyW", metaKey: true });
expect(closeTab).not.toHaveBeenCalled();
+9 -51
Переглянути файл
@@ -83,9 +83,8 @@
touch-action: none;
}
.macTitleBar {
height: var(--h-dialog-titlebar-mac, 28px);
padding: 0 12px 0 8px;
gap: var(--space-3);
height: var(--h-dialog-titlebar-mac, 40px);
padding: 0 var(--space-4);
}
.popupHeader {
height: 32px;
@@ -107,54 +106,9 @@
.macTitleBar .title {
font-size: var(--fs-ui);
}
/* NSWindow standard buttons: 12px, 8px apart; close red, minimise / zoom disabled (modal). */
.lights {
flex: none;
display: inline-flex;
gap: var(--space-2);
}
.light {
position: relative;
width: 12px;
height: 12px;
padding: 0;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: var(--traffic-off);
box-shadow: inset 0 0 0 0.5px var(--traffic-off-border);
cursor: default;
}
.lightClose {
background: var(--traffic-close);
box-shadow: inset 0 0 0 0.5px var(--traffic-close-border);
}
[data-inactive] .lightClose {
background: var(--traffic-off);
box-shadow: inset 0 0 0 0.5px var(--traffic-off-border);
}
.lightGlyph {
--icon-color: var(--traffic-glyph);
color: var(--traffic-glyph);
opacity: 0;
}
.lights:hover .lightClose,
.lightClose:focus-visible {
background: var(--traffic-close);
box-shadow: inset 0 0 0 0.5px var(--traffic-close-border);
}
.lights:hover .lightGlyph,
.lightClose:focus-visible .lightGlyph {
opacity: 1;
}
.lightClose:active {
background: var(--traffic-close-pressed);
}
.lightClose:focus-visible {
outline: 2px solid var(--focus-ring);
outline-offset: 1px;
/* An inactive window's title dims, as AppKit's does. */
[data-inactive] .macTitleBar .title {
color: var(--fg-muted);
}
.body {
@@ -187,6 +141,10 @@
gap: var(--space-3);
padding: 12px 16px;
}
/* macOS: the buttons sit in the content's corner, as in the dialog windows. */
[data-platform="mac"] > .footer:not(.messageFooter) {
padding-bottom: var(--space-4);
}
.footerStart {
flex: 1 1 0;
min-width: fit-content;
+3 -6
Переглянути файл
@@ -64,17 +64,14 @@ describe("Dialog chrome", () => {
</Dialog>,
);
it("macOS: traffic lights (only close enabled), title after them, Cancel … default rightmost", () => {
it("macOS: a sheet titled in its content, no window buttons, Cancel … default rightmost", () => {
const onClose = vi.fn();
show("mac", onClose);
const bar = document.querySelector("[data-dialog-titlebar]") as HTMLElement;
const lights = within(bar).getAllByRole("button");
expect(lights.map((b) => b.getAttribute("aria-label"))).toEqual(["Close", "Minimize", "Zoom"]);
expect(lights[1]).toBeDisabled();
expect(lights[2]).toBeDisabled();
expect(within(bar).queryAllByRole("button")).toEqual([]);
expect(bar.textContent).toBe("Usages Detected");
expect(footerLabels()).toEqual(["Cancel", "Delete Anyway", "View Usages"]);
fireEvent.click(lights[0]!);
fireEvent.keyDown(document.activeElement ?? document.body, { key: "Escape" });
expect(onClose).toHaveBeenCalledTimes(1);
});
+2 -14
Переглянути файл
@@ -3,7 +3,6 @@ import { createPortal } from "react-dom";
import clsx from "clsx";
import { usePlatform } from "@/platform/platformInfo";
import { Button, IconButton } from "./Button";
import { Icon } from "./icons";
import { FOCUSABLE, dismissPopups, onWindowDeactivate, openLayer, trapTab } from "./popupState";
import { PopupAncestry } from "./Popup";
import { tx, useGivenTx } from "@/platform/i18n";
@@ -462,20 +461,9 @@ function DialogInner({
</div>
)
) : platform === "mac" ? (
// A sheet over the window, as the dialog windows look: the title heads the content, no
// window buttons of its own (Esc and Cancel close it).
<div className={clsx(styles.titleBar, styles.macTitleBar)} data-dialog-drag="" data-dialog-titlebar="">
<span className={styles.lights}>
<button
type="button"
tabIndex={-1}
className={clsx(styles.light, styles.lightClose)}
aria-label={tx("Close")}
onClick={onClose}
>
<Icon name="close" size={10} className={styles.lightGlyph} />
</button>
<button type="button" tabIndex={-1} disabled className={styles.light} aria-label={tx("Minimize")} />
<button type="button" tabIndex={-1} disabled className={styles.light} aria-label={tx("Zoom")} />
</span>
<span className={styles.title}>{title}</span>
</div>
) : (