mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
feat(appearance): make Compact Mode match IntelliJ's compact density (#4593)
Compact Mode only lowered the title bar and narrowed the stripes: row heights, toolbar widgets and icons were fixed in code, and nothing in JS (where virtualised list row heights are set) could tell whether the mode was on. A small density store now mirrors the setting for JS, and Compact Mode uses IntelliJ's *.compact theme values: tree/list rows 22 (VCS log 24), toolbar widgets 26, toolbar and stripe icons 16, status bar 24, island gap 4, and chrome text 1px smaller. Co-authored-by: ChildishForces <40196330+ChildishForces@users.noreply.github.com>
This commit is contained in:
@@ -26,7 +26,7 @@ The same page also has:
|
||||
- **Different tool window background**: set tool windows apart from the editor.
|
||||
- **Background Image**: an image shown through the project window, with its **Opacity**, **Fill** (scale, original size or tile) and **Anchor**.
|
||||
- **Accessibility**: **Use contrast scrollbars** and **Adjust colors for red-green vision deficiency** (for protanopia and deuteranopia).
|
||||
- **Compact mode** under **UI Options**.
|
||||
- **Compact mode** under **UI Options**, also in **View › Appearance**. As in IntelliJ IDEA, it uses shorter tree and list rows, a smaller main toolbar, tool window stripes and status bar, 16px toolbar and stripe icons, and 1px smaller text in the toolbar, status bar, editor tabs and tool window headers.
|
||||
|
||||
## Editor color scheme
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ description: "选择界面主题和编辑器配色方案,导入 IntelliJ 主
|
||||
- **不同的工具窗口背景**:让工具窗口与编辑器区分开。
|
||||
- **背景图像**:透过项目窗口显示的图像,可设置 **不透明度**、**填充**(缩放、原始大小或平铺)和 **位置**。
|
||||
- **辅助功能**:**使用对比度滚动条** 和 **针对红绿色觉缺陷调整颜色**(适用于红色盲和绿色盲)。
|
||||
- **UI 选项** 下的 **紧凑模式**。
|
||||
- **UI 选项** 下的 **紧凑模式**,也可在 **视图 › 外观** 中切换。与 IntelliJ IDEA 一致:树和列表的行更矮,主工具栏、工具窗口栏和状态栏更紧凑,工具栏和工具窗口栏图标为 16px,工具栏、状态栏、编辑器标签页和工具窗口标题的文字小 1px。
|
||||
|
||||
## 编辑器配色方案
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
/** Heights IDEA's Islands theme uses in compact mode (`*.compact` keys), against the defaults. */
|
||||
const SIZES = {
|
||||
normal: { titleBar: 40, treeRow: 24, stripeIcon: 20, statusBar: 34, runButton: 30 },
|
||||
compact: { titleBar: 32, treeRow: 22, stripeIcon: 16, statusBar: 24, runButton: 26 },
|
||||
};
|
||||
|
||||
async function measure(page: import("@playwright/test").Page) {
|
||||
return page.evaluate(() => {
|
||||
const height = (selector: string) => document.querySelector(selector)?.getBoundingClientRect().height ?? null;
|
||||
return {
|
||||
titleBar: height("header"),
|
||||
treeRow: height('[role="tree"][aria-label="Project"] [role="treeitem"]'),
|
||||
stripeIcon: height("[data-stripe-button] svg"),
|
||||
statusBar: height('footer[aria-label="Status bar"]'),
|
||||
runButton: height("[data-run-chooser] + * button"),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
test("Compact Mode shrinks rows, toolbars, stripes and the status bar like IDEA", async ({ workbench: page }, info) => {
|
||||
// Plain-browser mode has no settings backend: set what the toggle action would store.
|
||||
const setCompact = (compactMode: boolean) =>
|
||||
page.evaluate(async (compactMode) => {
|
||||
const projectPath = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectPath);
|
||||
const settings = useProject.getState().settings;
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
appearance: { ...settings?.appearance, theme: "dark", syncWithOs: false, compactMode },
|
||||
},
|
||||
});
|
||||
}, compactMode);
|
||||
|
||||
await setCompact(false);
|
||||
await expect.poll(() => measure(page)).toEqual(SIZES.normal);
|
||||
await info.attach("normal", { body: await page.screenshot({ animations: "disabled" }), contentType: "image/png" });
|
||||
|
||||
await setCompact(true);
|
||||
await expect(page.locator("html")).toHaveAttribute("data-compact", "");
|
||||
await expect.poll(() => measure(page)).toEqual(SIZES.compact);
|
||||
await info.attach("compact", { body: await page.screenshot({ animations: "disabled" }), contentType: "image/png" });
|
||||
|
||||
await setCompact(false);
|
||||
await expect.poll(() => measure(page)).toEqual(SIZES.normal);
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Import Sessions from Other Apps: pick sessions a scan found now, and import them as tasks. */
|
||||
import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent } from "react";
|
||||
import { Button, Dialog, Icon, List, SearchField, Spinner, T, listNavigate, rowSelectionMode, selectRow } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { hasPrimaryModifier } from "@/platform/keymap";
|
||||
import { relativePath, useProject } from "@/platform/project";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
@@ -41,6 +42,7 @@ function folderOf(cwd: string | null, root: string | undefined): string {
|
||||
|
||||
function ImportSessionsDialog() {
|
||||
const tx = useTx();
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const listId = useId();
|
||||
const root = useProject((s) => s.project?.root);
|
||||
const external = useAgents((s) => s.external);
|
||||
@@ -216,7 +218,7 @@ function ImportSessionsDialog() {
|
||||
activeIndex={lead}
|
||||
onSelect={select}
|
||||
isSelected={(r) => !!sel.keys?.has(r.key)}
|
||||
rowHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
aria-label={tx("Sessions from other apps")}
|
||||
empty={
|
||||
<div className={styles.empty}>
|
||||
|
||||
@@ -176,7 +176,6 @@ function ExecutePopup({ tool }: { tool: BuildTool }) {
|
||||
}}
|
||||
focusable={false}
|
||||
hoverSelects={false}
|
||||
rowHeight={24}
|
||||
sectionHeight={28}
|
||||
className={styles.completions}
|
||||
aria-label="Completions"
|
||||
|
||||
@@ -12,6 +12,7 @@ import { codePreviewExtensions } from "@/editor/api";
|
||||
import { basename } from "@/platform/project";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { Icon, IconButton, List, Popup, Select, Spinner, fileIconName, listNavigate } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { openLocation, readFileLines } from "./ipc";
|
||||
import {
|
||||
dismissUsagesPopup,
|
||||
@@ -83,6 +84,7 @@ const ROW = 24;
|
||||
function UsagesPopupInner() {
|
||||
const { anchor, symbol, groups, note, loading, scope } = useUsagesPopup();
|
||||
const preview = useUsagesPopupPreview((s) => s.preview);
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const all = useMemo<Usage[]>(() => groups.flatMap((g) => g.usages), [groups]);
|
||||
const [filter, setFilter] = useState("");
|
||||
const accessOptions = useUsageAccessOptions();
|
||||
@@ -210,7 +212,7 @@ function UsagesPopupInner() {
|
||||
)}
|
||||
<div
|
||||
className={styles.body}
|
||||
style={{ height: rowCount * ROW, minHeight: `min(${Math.min(rowCount, 3) * ROW}px, 18vh)` }}
|
||||
style={{ height: rowCount * rowHeight, minHeight: `min(${Math.min(rowCount, 3) * rowHeight}px, 18vh)` }}
|
||||
>
|
||||
<List
|
||||
items={items}
|
||||
@@ -221,7 +223,7 @@ function UsagesPopupInner() {
|
||||
onActiveChange={setActive}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Usages"
|
||||
onActivate={pick}
|
||||
empty={
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Icon, Input, List, Popup, listNavigate } from "@/ui";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import type { GridColumn } from "./Grid";
|
||||
import styles from "./Database.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
export function filterColumns(columns: readonly GridColumn[], query: string): number[] {
|
||||
const q = query.trim().toLowerCase();
|
||||
@@ -24,6 +25,7 @@ export function ColumnsPopup(props: {
|
||||
onPick: (col: number) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const [query, setQuery] = useState("");
|
||||
const [active, setActive] = useState(0);
|
||||
const shown = filterColumns(props.columns, query);
|
||||
@@ -72,7 +74,7 @@ export function ColumnsPopup(props: {
|
||||
onActivate={(_, i) => pick(i)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label={tx("Columns")}
|
||||
className={styles.columnsList}
|
||||
empty={<span>{tx("No matching columns")}</span>}
|
||||
|
||||
@@ -30,6 +30,7 @@ vi.mock("@tanstack/react-virtual", () => ({
|
||||
getTotalSize: () => count * 24,
|
||||
getVirtualItems: () => Array.from({ length: count }, (_, index) => ({ index, start: index * 24, key: index })),
|
||||
scrollToIndex: () => {},
|
||||
measure: () => {},
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type ClassSort,
|
||||
} from "./editor/classRows";
|
||||
import styles from "./HeapSnapshotEditor.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
const COLUMNS: ReadonlyArray<{ key: ClassSort; label: string; numeric: boolean; diff?: boolean }> = [
|
||||
{ key: "name", label: "Class", numeric: false },
|
||||
@@ -66,6 +67,7 @@ export function HeapClasses({
|
||||
selected: number | null;
|
||||
onSelect: (row: HeapClassRow | null) => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const tx = useTx();
|
||||
const [query, setQuery] = useState<ClassQuery>(DEFAULT_CLASS_QUERY);
|
||||
const compared = changes !== null;
|
||||
@@ -124,7 +126,7 @@ export function HeapClasses({
|
||||
renderItem={(r) => <ClassRow row={r} changes={changes} />}
|
||||
activeIndex={selected === null ? -1 : rows.findIndex((r) => r.classIndex === selected)}
|
||||
onActiveChange={(i) => onSelect(rows[i] ?? null)}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
tableBody={{ headerRows: 1 }}
|
||||
empty={<span className={styles.note}>{tx("No matches")}</span>}
|
||||
/>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { formatBytes } from "../../memory/rows";
|
||||
import { useHeapQuery } from "./heapQuery";
|
||||
import { ObjectText } from "./ObjectText";
|
||||
import styles from "../HeapSnapshotEditor.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
const LIMIT = 100;
|
||||
|
||||
@@ -21,6 +22,7 @@ export function BiggestObjects({
|
||||
selected: number | null;
|
||||
onSelect: (object: HeapObjectRow) => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const tx = useTx();
|
||||
const page = useHeapQuery(`${snapshot}:${cls.classIndex}`, () =>
|
||||
call(commands.debugHeapDominators(snapshot, null, cls.classIndex, 0, LIMIT)),
|
||||
@@ -70,7 +72,7 @@ export function BiggestObjects({
|
||||
)}
|
||||
activeIndex={selected === null ? -1 : rows.findIndex((o) => o.object === selected)}
|
||||
onActiveChange={(i) => rows[i] && onSelect(rows[i])}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
tableBody={{ headerRows: 1 }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,7 @@ import { keepKeysOnButton } from "./rowButtonKeys";
|
||||
import { columnsOf, formatBytes, formatCount, formatDelta, queryFor, visibleRows, type SortKey } from "./rows";
|
||||
import { unavailableText } from "./unavailableText";
|
||||
import styles from "./MemoryView.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
const COLUMNS: ReadonlyArray<{ key: SortKey; label: string; numeric: boolean }> = [
|
||||
{ key: "name", label: "Class", numeric: false },
|
||||
@@ -105,6 +106,7 @@ function ClassRow({
|
||||
}
|
||||
|
||||
export function MemoryView({ session }: { session: DebugSession }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
// Also re-renders the reason text, which reads the catalog when called.
|
||||
const tx = useTx();
|
||||
const id = session.id;
|
||||
@@ -248,7 +250,7 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
onActivate={(r, _i, e) => {
|
||||
if (e.type === "keydown" && listsInstances && paused) showInstancesOf(r.name);
|
||||
}}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
tableBody={{ headerRows: 1 }}
|
||||
empty={<span className={styles.note}>{tx("No matches")}</span>}
|
||||
/>
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import type { CloneSourceProps } from "@/workbench/contributions";
|
||||
import { openInBrowser } from "../data/local";
|
||||
import styles from "./GitHubCloneSource.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
type Row = { repo: GhAccountRepo; indices: number[] | null };
|
||||
|
||||
@@ -32,6 +33,7 @@ export function matchRepos(repos: readonly GhAccountRepo[], query: string): Row[
|
||||
}
|
||||
|
||||
export function GitHubCloneSource({ url, onUrl, onClone, disabled }: CloneSourceProps) {
|
||||
const rowHeight = useRowHeight(26);
|
||||
const [state, setState] = useState<GhAccountRepos | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [attempt, setAttempt] = useState(0);
|
||||
@@ -140,7 +142,7 @@ export function GitHubCloneSource({ url, onUrl, onClone, disabled }: CloneSource
|
||||
activeIndex={active}
|
||||
onActiveChange={pick}
|
||||
focusable={false}
|
||||
rowHeight={26}
|
||||
rowHeight={rowHeight}
|
||||
empty={
|
||||
<span className={styles.muted}>
|
||||
<T>{state.repos.length ? "No matching repositories" : "No repositories"}</T>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { prettyDate } from "../ui/prettyDate";
|
||||
import { commitDescription } from "./model";
|
||||
import { selectCommit, useCreatePr, type CreateChange } from "./store";
|
||||
import styles from "./Create.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
function Centered({ children, error }: { children: ReactNode; error?: boolean }) {
|
||||
return <div className={error ? `${styles.centered} ${styles.errorText}` : styles.centered}>{children}</div>;
|
||||
@@ -170,6 +171,7 @@ function showDiff(all: readonly CreateChange[], first: CreateChange) {
|
||||
}
|
||||
|
||||
function ChangesTree() {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const changes = useCreatePr((s) => s.changes);
|
||||
const files = changes?.state === "ok" ? changes.value : null;
|
||||
const roots = useMemo(() => (files ? buildFileTree(files, (f) => f.path) : []), [files]);
|
||||
@@ -219,7 +221,7 @@ function ChangesTree() {
|
||||
selected={selection}
|
||||
onSelectionChange={setSelection}
|
||||
multiSelect
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Changes"
|
||||
speedSearch
|
||||
onActivate={(n) => n.file && showDiff(ordered, n.file)}
|
||||
|
||||
@@ -178,7 +178,6 @@ function HeadPopup(props: { anchor: HTMLElement; initialRepo: GHRemote; onClose:
|
||||
onActivate={(r) => choose(r)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
className={styles.headList}
|
||||
aria-label="Branches"
|
||||
empty={<div className={styles.hint}>{tx("Nothing to show")}</div>}
|
||||
|
||||
@@ -78,7 +78,6 @@ export function BranchWidget({
|
||||
getKey={(a) => a}
|
||||
onActivate={(a) => run(a)}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
aria-label={tx("Branches")}
|
||||
renderItem={(a, state) => (
|
||||
<div className={styles.popupRow} data-active={state.active || undefined}>
|
||||
|
||||
@@ -86,7 +86,6 @@ function EditMacrosDialog({ onClose }: { onClose: () => void }) {
|
||||
getKey={(m) => m.name}
|
||||
activeIndex={Math.min(active, saved.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
rowHeight={24}
|
||||
className={styles.list}
|
||||
aria-label="Macros"
|
||||
empty={
|
||||
|
||||
@@ -79,7 +79,6 @@ function NewPopup({ at, items }: { at: { x: number; y: number }; items: MenuItem
|
||||
onActivate={(r) => pick(r)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
className={styles.list}
|
||||
aria-label="File types"
|
||||
empty={
|
||||
|
||||
@@ -149,7 +149,6 @@ function RunAnythingPopup({ root }: { root: string }) {
|
||||
onActivate={(r) => run(r)}
|
||||
focusable={false}
|
||||
hoverSelects={false}
|
||||
rowHeight={24}
|
||||
className={styles.rows}
|
||||
aria-label="Run Anything entries"
|
||||
empty={
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMemo, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { HighlightedText, Icon, List, Popup, SearchField, fuzzyMatch, listNavigate, T, type PopupAnchor } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useRunConfigTypes, runConfigTypes, type RunConfigTypeContribution } from "@/workbench/contributions";
|
||||
import styles from "./Run.module.css";
|
||||
|
||||
@@ -59,6 +60,7 @@ export function AddConfigPopup({
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const types = useRunConfigTypes((s) => s.types);
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const [query, setQuery] = useState("");
|
||||
const rows = useMemo(() => typeRows(runConfigTypes(types), query), [types, query]);
|
||||
const isSection = (r: TypeRow) => r.kind === "group";
|
||||
@@ -115,7 +117,7 @@ export function AddConfigPopup({
|
||||
variant="bare"
|
||||
/>
|
||||
</div>
|
||||
<div style={{ height: Math.max(ROW, Math.min(rows.length * ROW, 14 * ROW)) }}>
|
||||
<div style={{ height: Math.max(rowHeight, Math.min(rows.length * rowHeight, 14 * rowHeight)) }}>
|
||||
<List<TypeRow>
|
||||
aria-label="Configuration types"
|
||||
className={styles.chooserList}
|
||||
@@ -127,7 +129,7 @@ export function AddConfigPopup({
|
||||
onActiveChange={setActive}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
onActivate={(r) => pick(r)}
|
||||
empty={
|
||||
<span className={styles.chooserMuted}>
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
T,
|
||||
type MenuItem,
|
||||
} from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import type { RunConfig } from "@/platform/ipc";
|
||||
import { useWorkflowSettings } from "@/platform/workflowSettings";
|
||||
import { useDebugRunSessions } from "@/workbench/contributions";
|
||||
@@ -99,7 +100,7 @@ export function buildRows(
|
||||
return rows;
|
||||
}
|
||||
|
||||
const rowHeight = (r: Row) => (r.type === "section" && !r.label ? SEPARATOR : ROW);
|
||||
const heightOf = (r: Row, rowHeight: number) => (r.type === "section" && !r.label ? SEPARATOR : rowHeight);
|
||||
|
||||
let closedAt = 0;
|
||||
/** The chooser closed within the last moment (a click on its own anchor shouldn't reopen it). */
|
||||
@@ -145,6 +146,7 @@ export function mnemonics(rows: readonly Row[]): Map<string, number> {
|
||||
|
||||
function ConfigChooser() {
|
||||
const mode = useRun((s) => s.chooserMode);
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const configs = useRun((s) => s.configs);
|
||||
const selectedId = useRun((s) => s.selectedId);
|
||||
const temporary = useRun((s) => s.temporary);
|
||||
@@ -285,8 +287,8 @@ function ConfigChooser() {
|
||||
};
|
||||
|
||||
const height = Math.min(
|
||||
rows.reduce((sum, r) => sum + rowHeight(r), 0),
|
||||
14 * ROW,
|
||||
rows.reduce((sum, r) => sum + heightOf(r, rowHeight), 0),
|
||||
14 * rowHeight,
|
||||
);
|
||||
|
||||
// IDEA: a configuration's submenu lists its executors, then Edit and Pin.
|
||||
@@ -366,7 +368,7 @@ function ConfigChooser() {
|
||||
onActiveChange={setActive}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
onActivate={(r) => activate(r)}
|
||||
renderItem={(r, { active: isActive }) => {
|
||||
if (r.type === "save") {
|
||||
|
||||
@@ -338,17 +338,17 @@
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
max-width: 260px;
|
||||
height: 30px;
|
||||
border-radius: 6px;
|
||||
height: var(--h-toolbar-widget);
|
||||
border-radius: var(--radius-toolbar-dropdown);
|
||||
}
|
||||
.widgetDevice {
|
||||
composes: widgetChooser;
|
||||
max-width: 180px;
|
||||
}
|
||||
.widgetButton {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 6px;
|
||||
width: var(--titlebar-tool-button);
|
||||
height: var(--titlebar-tool-button);
|
||||
border-radius: var(--radius-toolbar-button);
|
||||
}
|
||||
.widgetLoading {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -12,9 +12,11 @@ import { CURRENT_FILE, useRun, isLive } from "./store";
|
||||
import { compoundTargets, selectedTarget } from "./sessionTargets";
|
||||
import { isDebugOnly } from "./types";
|
||||
import styles from "./Run.module.css";
|
||||
import { useChromeIconSize } from "@/ui/density";
|
||||
|
||||
/** Title bar: configuration chooser, Run / Debug, and Rerun / Stop while running. */
|
||||
export function RunWidget() {
|
||||
const iconSize = useChromeIconSize();
|
||||
const tx = useTx();
|
||||
const label = useRemoteLabel();
|
||||
const configs = useRun((s) => s.configs);
|
||||
@@ -92,20 +94,20 @@ export function RunWidget() {
|
||||
<IconButton
|
||||
icon="run"
|
||||
size="large"
|
||||
iconSize={18}
|
||||
iconSize={iconSize - 2}
|
||||
className={clsx(styles.widgetButton, styles.widgetRun)}
|
||||
title="Run"
|
||||
disabled
|
||||
/>
|
||||
)}
|
||||
<span className={clsx(styles.widgetButton, styles.widgetLoading)}>
|
||||
<Spinner variant="spokes" size={18} label={tx("Starting…")} />
|
||||
<Spinner variant="spokes" size={iconSize - 2} label={tx("Starting…")} />
|
||||
</span>
|
||||
{!debugging && (
|
||||
<IconButton
|
||||
icon="debug"
|
||||
size="large"
|
||||
iconSize={18}
|
||||
iconSize={iconSize - 2}
|
||||
className={styles.widgetButton}
|
||||
title="Debug"
|
||||
disabled
|
||||
@@ -118,7 +120,7 @@ export function RunWidget() {
|
||||
<IconButton
|
||||
icon="resume"
|
||||
size="large"
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={styles.widgetButton}
|
||||
title="Resume Program"
|
||||
shortcut={shortcutLabel("debug.resume")}
|
||||
@@ -141,7 +143,7 @@ export function RunWidget() {
|
||||
<IconButton
|
||||
icon="run"
|
||||
size="large"
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={clsx(styles.widgetButton, styles.widgetRun)}
|
||||
title={
|
||||
selected
|
||||
@@ -159,7 +161,7 @@ export function RunWidget() {
|
||||
<IconButton
|
||||
icon="debug"
|
||||
size="large"
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={styles.widgetButton}
|
||||
title={selected ? tx`Debug '${selected.name}'` : currentFile ? "Debug Current File" : "Debug"}
|
||||
shortcut={shortcutLabel("run.debug")}
|
||||
@@ -196,7 +198,7 @@ export function RunWidget() {
|
||||
ref={moreRef}
|
||||
icon="more"
|
||||
size="large"
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={styles.widgetButton}
|
||||
title="More Actions"
|
||||
aria-haspopup="menu"
|
||||
|
||||
@@ -85,7 +85,6 @@ function ScratchChooser({ languages }: { languages: readonly ScratchLanguage[] }
|
||||
onActivate={(r) => pick(r)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
className={styles.list}
|
||||
aria-label="Languages"
|
||||
empty={
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
type PathBookmark,
|
||||
} from "./store";
|
||||
import styles from "./BookmarkPopups.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
export function BookmarkPopupsOverlay() {
|
||||
const chooser = useBookmarkPopups((s) => s.chooser);
|
||||
@@ -186,6 +187,7 @@ export function bookmarkRows(
|
||||
const isSectionRow = (r: Row) => r.kind === "file" || r.kind === "list";
|
||||
|
||||
function BookmarksPopup() {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const items = useBookmarks((s) => s.items);
|
||||
const paths = useBookmarks((s) => s.paths);
|
||||
const lists = useBookmarks((s) => s.lists);
|
||||
@@ -247,8 +249,7 @@ function BookmarksPopup() {
|
||||
jump(r);
|
||||
}}
|
||||
aria-label="Bookmarks"
|
||||
rowHeight={22}
|
||||
sectionHeight={24}
|
||||
rowHeight={rowHeight}
|
||||
empty={<span>{items.length || paths.length ? null : <T>No bookmarks</T>}</span>}
|
||||
renderSection={(r) =>
|
||||
r.kind === "file" ? (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { onSearchCategoriesChanged, onEndpointsChanged } from "@/workbench/contributions";
|
||||
import { useFilePresentation } from "@/ui/filePresentation";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { actionToggled, executeAction, executeActionFrom, getAction } from "@/platform/actions";
|
||||
@@ -87,7 +88,7 @@ export function claimSearchKeys(input: () => HTMLElement | null): () => void {
|
||||
return registerKeyClaim((e) => e.target === input() && SEARCH_KEYS.has(e.key));
|
||||
}
|
||||
const ROW = 24;
|
||||
const MIN_LIST = 10 * ROW;
|
||||
const MIN_LIST_ROWS = 10;
|
||||
const DEBOUNCE_MS = 60;
|
||||
|
||||
export function SearchEverywhereOverlay() {
|
||||
@@ -100,6 +101,7 @@ const INITIAL_SELECTION: Selection = { key: null, anchorKey: null, lead: -1, anc
|
||||
|
||||
function SearchEverywhereDialog() {
|
||||
const tx = useTx();
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const tab = useSearchEverywhere((s) => s.tab);
|
||||
const hint = hintFor(tab, tx);
|
||||
const [tabs, setTabs] = useState(searchTabs);
|
||||
@@ -472,8 +474,8 @@ function SearchEverywhereDialog() {
|
||||
};
|
||||
|
||||
// While a query is typed the list keeps a minimum height so the popup doesn't jump with every keystroke.
|
||||
const minList = parsed.text.trim() && !listing ? MIN_LIST : 0;
|
||||
const listHeight = Math.max(minList, rows.length * ROW);
|
||||
const minList = parsed.text.trim() && !listing ? MIN_LIST_ROWS * rowHeight : 0;
|
||||
const listHeight = Math.max(minList, rows.length * rowHeight);
|
||||
const previewTarget = previewOf(activeRow);
|
||||
const emptyQuery = !parsed.text.trim();
|
||||
const showEmpty = !rows.length && snap && !snap.loading && (!emptyQuery || tab !== "all");
|
||||
@@ -521,8 +523,8 @@ function SearchEverywhereDialog() {
|
||||
isSelected={(r) => !!sel.keys?.has(r.key)}
|
||||
onActivate={(r, _i, e) => activate(r, (e as MouseEvent).shiftKey)}
|
||||
focusable={false}
|
||||
rowHeight={ROW}
|
||||
sectionHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
sectionHeight={rowHeight}
|
||||
className={styles.list}
|
||||
aria-label={tx("Results")}
|
||||
renderItem={(r, state) => (
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
type MenuItem,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { maybeEditorService, notifications } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { basename, dirname, openLocation } from "../common/open";
|
||||
@@ -144,6 +145,7 @@ function displayDirectory(dir: string, root: string | null): string {
|
||||
|
||||
function FindInFilesDialog() {
|
||||
const s = useFindPopup();
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const txt = useTxTemplate();
|
||||
const project = useProject((p) => p.project);
|
||||
const root = project?.workspace?.projects[0] ?? (project?.workspace ? null : (project?.root ?? null));
|
||||
@@ -591,7 +593,7 @@ function FindInFilesDialog() {
|
||||
openRow(r, e.shiftKey);
|
||||
}}
|
||||
focusable={false}
|
||||
rowHeight={ROW}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Matches"
|
||||
empty={
|
||||
query ? (
|
||||
@@ -864,7 +866,7 @@ function FindInFilesDialog() {
|
||||
<div className={styles.split}>
|
||||
{rows.length ? (
|
||||
<SplitGroup orientation="vertical" id="find-popup-split" storageKey={FIND_POPUP_SPLIT_KEY}>
|
||||
<SplitPanel id="results" minSize={ROW * 3} defaultSize="33%">
|
||||
<SplitPanel id="results" minSize={rowHeight * 3} defaultSize="33%">
|
||||
{resultsBox}
|
||||
</SplitPanel>
|
||||
<SplitHandle hairline={false} />
|
||||
|
||||
@@ -387,7 +387,6 @@ function RecentFilesDialog() {
|
||||
}}
|
||||
onActivate={(t) => openTool(t.tw)}
|
||||
focusable={false}
|
||||
rowHeight={24}
|
||||
aria-label="Tool windows"
|
||||
renderItem={(t) => <ToolRow tw={t.tw} title={t.title} indices={t.indices} />}
|
||||
/>
|
||||
@@ -414,7 +413,6 @@ function RecentFilesDialog() {
|
||||
isSelected={(f) => effectiveColumn === "files" && !!fileSelection.keys?.has(f.path)}
|
||||
onActivate={(f, _i, e) => openFile(f, e.shiftKey)}
|
||||
focusable={false}
|
||||
rowHeight={24}
|
||||
aria-label={switcher ? "Open files" : "Recent files"}
|
||||
empty={
|
||||
paths && (
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
type TreeHandle,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import type { OutlineItem } from "@/platform/ipc";
|
||||
import { useShownLine } from "@/editor/api";
|
||||
import { badgeKind, basename, openLocation } from "../common/open";
|
||||
@@ -364,6 +365,7 @@ const POPUP_ROW = 22;
|
||||
|
||||
function FileStructureDialog() {
|
||||
useLiveOutline();
|
||||
const rowHeight = useRowHeight(POPUP_ROW);
|
||||
const path = useOutline((s) => s.path);
|
||||
const items = useOutline((s) => s.items);
|
||||
const loading = useOutline((s) => s.loading);
|
||||
@@ -466,7 +468,7 @@ function FileStructureDialog() {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
const height = Math.min(420, Math.max(1, visibleCount(filter.nodes, collapsed)) * POPUP_ROW + 8);
|
||||
const height = Math.min(420, Math.max(1, visibleCount(filter.nodes, collapsed)) * rowHeight + 8);
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
@@ -553,7 +555,7 @@ function FileStructureDialog() {
|
||||
speedSearch={false}
|
||||
activateExpandable
|
||||
onActivate={(n) => choose(n)}
|
||||
rowHeight={POPUP_ROW}
|
||||
rowHeight={rowHeight}
|
||||
indent={16}
|
||||
empty={
|
||||
<span className={styles.popupEmpty}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatPattern, formatTimestamp } from "@/platform/dateFormat";
|
||||
import { resolveThemeId } from "@/workbench/theme";
|
||||
import { useCompactMode } from "@/ui/density";
|
||||
import { applyAppearanceOptions, nextZoom, SMALL_TREE_INDENT } from "../appearanceRuntime";
|
||||
import { validateSettings } from "../model/schema";
|
||||
import { validateGeneralExtras, validateAppearanceExtras, validateNotifications } from "../model/behaviorSchema";
|
||||
@@ -106,6 +107,16 @@ describe("appearance & behavior settings", () => {
|
||||
expect(validateAppearanceExtras({ navigationBar: "everywhere" }).navigationBar).toBe("statusBar");
|
||||
});
|
||||
|
||||
it("applies Compact mode to the root attribute and the JS density store", () => {
|
||||
const root = document.createElement("div");
|
||||
applyAppearanceOptions(validateSettings({ appearance: { compactMode: true } }), root);
|
||||
expect(root.dataset.compact).toBe("");
|
||||
expect(useCompactMode.getState()).toBe(true);
|
||||
applyAppearanceOptions(validateSettings({}), root);
|
||||
expect(root.dataset.compact).toBeUndefined();
|
||||
expect(useCompactMode.getState()).toBe(false);
|
||||
});
|
||||
|
||||
it("defaults Use smaller indents in trees to off and applies the indent variable", () => {
|
||||
expect(validateAppearanceExtras({}).smallTreeIndents).toBe(false);
|
||||
expect(validateAppearanceExtras({ smallTreeIndents: true }).smallTreeIndents).toBe(true);
|
||||
|
||||
@@ -13,6 +13,7 @@ import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { loadSystemFonts, useSystemFontStore } from "@/platform/systemFonts";
|
||||
import { setDragRequiresAlt } from "@/ui";
|
||||
import { setCompactMode } from "@/ui/density";
|
||||
import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
import { DEFAULT_SETTINGS, validateSettings, type ValidSettings } from "./model/schema";
|
||||
import type { BackgroundImageValid } from "./model/behaviorSchema";
|
||||
@@ -45,6 +46,7 @@ export function applyAppearanceOptions(s: ValidSettings, root: HTMLElement = doc
|
||||
} else root.style.removeProperty("--font-ui");
|
||||
|
||||
flag(root, "compact", a.compactMode);
|
||||
setCompactMode(a.compactMode);
|
||||
flag(root, "contrastScrollbars", a.contrastScrollbars);
|
||||
flag(root, "redGreen", a.redGreenVision);
|
||||
flag(root, "toolWindowBg", a.differentToolWindowBackground, "different");
|
||||
|
||||
@@ -356,7 +356,6 @@ export function SettingsLayout() {
|
||||
onSelectionChange={(_sel, node) => node && selectPage(node.key)}
|
||||
multiSelect={false}
|
||||
speedSearch={false}
|
||||
rowHeight={24}
|
||||
empty={
|
||||
<div className={styles.noMatch}>
|
||||
<T>No matches</T>
|
||||
|
||||
@@ -93,7 +93,6 @@ function TemplateStep({
|
||||
onActivate={(t) => onPick(t)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
className={styles.templateList}
|
||||
aria-label="File templates"
|
||||
renderItem={(t) => (
|
||||
|
||||
@@ -4,6 +4,7 @@ import { HighlightedText, List, Popup, fuzzyMatch, listNavigate } from "@/ui";
|
||||
import { closeChooser, useChooser, type ChooserItem, type ChooserRequest } from "./store";
|
||||
import styles from "./Chooser.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/** Overlay contribution: renders the pending chooser, if any. */
|
||||
export function ChooserHost() {
|
||||
@@ -57,6 +58,7 @@ function MnemonicLabel({ item }: { item: ChooserItem }) {
|
||||
}
|
||||
|
||||
function ChooserPopup({ request }: { request: ChooserRequest }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const [filter, setFilter] = useState(request.filter ?? "");
|
||||
const rows = useMemo(() => filterChooserItems(request.items, filter), [request.items, filter]);
|
||||
const [active, setActive] = useState(() =>
|
||||
@@ -129,7 +131,7 @@ function ChooserPopup({ request }: { request: ChooserRequest }) {
|
||||
renderSection={(r) => <div className={styles.section}>{r.item.label}</div>}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
className={styles.list}
|
||||
aria-label={request.title}
|
||||
empty={<div className={styles.empty}>{request.emptyText ?? tx("Nothing to show")}</div>}
|
||||
|
||||
@@ -2,6 +2,7 @@ import clsx from "clsx";
|
||||
import { useEffect, useMemo, useState, type KeyboardEvent } from "react";
|
||||
import type { Branch } from "@/bindings";
|
||||
import { HighlightedText, Icon, List, Popup, SearchField, T, firstSelectable, fuzzyMatch, listNavigate } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { isFavoriteBranch, sortLocal, sortRemote } from "./branches";
|
||||
import { loadFavoriteBranches, useFavoriteBranches } from "./branchOps";
|
||||
@@ -91,6 +92,7 @@ export function BranchFilterPopup({
|
||||
onSelectMany: () => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(ROW_HEIGHT);
|
||||
const [query, setQuery] = useState("");
|
||||
const [active, setActive] = useState(0);
|
||||
const [expanded, setExpanded] = useState<ReadonlySet<Group>>(new Set());
|
||||
@@ -127,7 +129,7 @@ export function BranchFilterPopup({
|
||||
setActive(next);
|
||||
}
|
||||
};
|
||||
const height = Math.min(MAX_LIST_HEIGHT, Math.max(ROW_HEIGHT * 3, rows.length * ROW_HEIGHT));
|
||||
const height = Math.min(MAX_LIST_HEIGHT, Math.max(rowHeight * 3, rows.length * rowHeight));
|
||||
return (
|
||||
<Popup
|
||||
open
|
||||
@@ -163,7 +165,7 @@ export function BranchFilterPopup({
|
||||
onActivate={activate}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW_HEIGHT}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Branches"
|
||||
className={styles.branchFilterListBody}
|
||||
empty={
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
max-width: 280px;
|
||||
height: 30px;
|
||||
border-radius: 6px;
|
||||
height: var(--h-toolbar-widget);
|
||||
border-radius: var(--radius-toolbar-dropdown);
|
||||
}
|
||||
.icon {
|
||||
flex: none;
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
type MenuItem,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import type { PopupAnchor } from "@/ui/Popup";
|
||||
import { buildBranchRows, preferredBranchRow, withExpanded, type BranchRow, type PopupAction } from "./branches";
|
||||
import { branchPresentation, extensionPopupActions, useBranchWidgetExtensions } from "./branchWidgetExtensions";
|
||||
@@ -352,13 +353,13 @@ const NO_BRANCHES: readonly Branch[] = [];
|
||||
const INDENT = 16;
|
||||
const ROW_HEIGHT = 24;
|
||||
const SEPARATOR_HEIGHT = 9;
|
||||
const listHeight = (rows: readonly { type: string; key: string }[]) =>
|
||||
const listHeight = (rows: readonly { type: string; key: string }[], rowHeight: number) =>
|
||||
Math.min(
|
||||
440,
|
||||
Math.max(
|
||||
ROW_HEIGHT * 3,
|
||||
rowHeight * 3,
|
||||
rows.reduce(
|
||||
(h, r) => h + (r.type === "section" && r.key.startsWith("separator:") ? SEPARATOR_HEIGHT : ROW_HEIGHT),
|
||||
(h, r) => h + (r.type === "section" && r.key.startsWith("separator:") ? SEPARATOR_HEIGHT : rowHeight),
|
||||
0,
|
||||
),
|
||||
),
|
||||
@@ -422,6 +423,7 @@ interface BranchesPanelProps {
|
||||
|
||||
/** Search, actions and the branches of one repository (the selected one, or `root`). */
|
||||
function BranchesPanel({ onClose, actions: baseActions, root, fallback, onBack }: BranchesPanelProps) {
|
||||
const rowHeight = useRowHeight(ROW_HEIGHT);
|
||||
const selected = useVcs((s) => s.repo);
|
||||
const live = root === undefined || selected === root;
|
||||
const storeBranches = useVcs((s) => s.branches);
|
||||
@@ -555,7 +557,7 @@ function BranchesPanel({ onClose, actions: baseActions, root, fallback, onBack }
|
||||
{!root && <IconButton icon="git-fetch" title="Fetch" size="small" action="vcs.fetch" />}
|
||||
{!root && <OptionsButton hasTags={tags.length > 0} />}
|
||||
</div>
|
||||
<div ref={listRef} style={{ height: listHeight(rows) }} className={styles.listWrap}>
|
||||
<div ref={listRef} style={{ height: listHeight(rows, rowHeight) }} className={styles.listWrap}>
|
||||
<List
|
||||
items={rows}
|
||||
getKey={(r) => r.key}
|
||||
@@ -573,7 +575,7 @@ function BranchesPanel({ onClose, actions: baseActions, root, fallback, onBack }
|
||||
onActivate={(_r, i) => activate(i)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW_HEIGHT}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Branches"
|
||||
className={styles.list}
|
||||
empty={<span className={styles.empty}>{loaded ? tx("No matching branches") : tx("Loading…")}</span>}
|
||||
@@ -618,6 +620,7 @@ function SubMenu({
|
||||
* (acting on all of them) or, when their branches differ, the current repository's.
|
||||
*/
|
||||
function MultiRepoPanel({ onClose, actions: popupActions }: { onClose: () => void; actions: readonly PopupAction[] }) {
|
||||
const rowHeight = useRowHeight(ROW_HEIGHT);
|
||||
const roots = useVcs((s) => s.roots);
|
||||
const heads = useVcs((s) => s.heads);
|
||||
const operations = useVcs((s) => s.operations);
|
||||
@@ -805,7 +808,7 @@ function MultiRepoPanel({ onClose, actions: popupActions }: { onClose: () => voi
|
||||
<IconButton icon="git-fetch" title="Fetch" size="small" action="vcs.fetch" />
|
||||
<OptionsButton hasTags={tags.length > 0} />
|
||||
</div>
|
||||
<div ref={listRef} style={{ height: listHeight(rows) }} className={styles.listWrap}>
|
||||
<div ref={listRef} style={{ height: listHeight(rows, rowHeight) }} className={styles.listWrap}>
|
||||
<List
|
||||
items={rows}
|
||||
getKey={(r) => r.key}
|
||||
@@ -823,7 +826,7 @@ function MultiRepoPanel({ onClose, actions: popupActions }: { onClose: () => voi
|
||||
onActivate={(_r, i) => activate(i)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW_HEIGHT}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Repositories and branches"
|
||||
className={styles.list}
|
||||
empty={
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { Commit } from "@/bindings";
|
||||
import { Dialog, List, SearchField } from "@/ui";
|
||||
import { openDialog } from "./dialogs";
|
||||
import { commitKey } from "./multiRoot";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
export function chooseLogCommit(commits: Commit[], title: string): Promise<Commit | null> {
|
||||
return new Promise((resolve) => {
|
||||
@@ -28,6 +29,7 @@ function CommitChooser({
|
||||
title: string;
|
||||
onDone: (commit: Commit | null) => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(26);
|
||||
const [query, setQuery] = useState("");
|
||||
const shown = commits.filter((c) =>
|
||||
`${c.id} ${c.summary} ${c.author}`.toLocaleLowerCase().includes(query.toLocaleLowerCase()),
|
||||
@@ -41,7 +43,7 @@ function CommitChooser({
|
||||
getKey={commitKey}
|
||||
renderItem={(c) => `${c.shortId} ${c.summary} — ${c.author}`}
|
||||
onActivate={onDone}
|
||||
rowHeight={26}
|
||||
rowHeight={rowHeight}
|
||||
aria-label={title}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -112,6 +112,7 @@ import { ShelfPanel, loadShelves, useShelf } from "./shelf";
|
||||
import { existsOnDisk, refreshNow, repoName, selectRepo, useVcs } from "./store";
|
||||
import { saveVcsSetting } from "./settingsUi";
|
||||
import styles from "./CommitView.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/** MIME type of files dragged onto a change list (absolute paths, newline-separated). */
|
||||
const CHANGES_MIME = "application/x-openidea-changes";
|
||||
@@ -1381,6 +1382,7 @@ async function stashFileChanges(stash: StashEntry): Promise<LogChange[]> {
|
||||
}
|
||||
|
||||
export function StashesPanel() {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const repo = useVcs((s) => s.repo);
|
||||
const repos = useVcs((s) => s.roots);
|
||||
const version = useVcs((s) => s.version);
|
||||
@@ -1491,7 +1493,7 @@ export function StashesPanel() {
|
||||
loadChildren={loadFiles}
|
||||
selected={useMemo(() => new Set(selectedKey ? [selectedKey] : []), [selectedKey])}
|
||||
multiSelect={false}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Stashes"
|
||||
className={styles.stashList}
|
||||
empty={<span className={styles.empty}>{error ?? (loaded ? tx("No stashes") : tx("Loading…"))}</span>}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { showCompareRevisions } from "./operations";
|
||||
import { currentRepo, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
const LIMIT = 2000;
|
||||
|
||||
@@ -75,6 +76,7 @@ function CommitList({
|
||||
error: string | null;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
return (
|
||||
<div className={styles.commitListBody}>
|
||||
{error ? (
|
||||
@@ -89,7 +91,7 @@ function CommitList({
|
||||
<List
|
||||
items={commits}
|
||||
getKey={(c) => c.id}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Commits"
|
||||
className={styles.grow}
|
||||
empty={
|
||||
|
||||
@@ -28,6 +28,7 @@ import { compareFilesData, displayPath } from "./compareData";
|
||||
import type { DirectoryCompareData } from "./directoryCompareKind";
|
||||
import { formatSize, formatTime } from "./model";
|
||||
import styles from "./DirectoryCompare.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
const DiffEditor = lazyComponent(() => import("./DiffEditor").then((m) => m.DiffEditor));
|
||||
|
||||
@@ -153,6 +154,7 @@ function Side({ entry, side, folder }: { entry: DirectoryCompareEntry; side: "le
|
||||
}
|
||||
|
||||
export function DirectoryCompare({ left, right }: { left: string; right: string }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const t = useTx();
|
||||
const [entries, setEntries] = useState<DirectoryCompareEntry[]>([]);
|
||||
const [current, setCurrent] = useState<DirectoryCompareEntry | null>(null);
|
||||
@@ -338,8 +340,7 @@ export function DirectoryCompare({ left, right }: { left: string; right: string
|
||||
onActivate={(r, _i, e) => {
|
||||
if ("entry" in r && e.type === "keydown") open(r.entry);
|
||||
}}
|
||||
rowHeight={22}
|
||||
sectionHeight={24}
|
||||
rowHeight={rowHeight}
|
||||
tableBody={{ headerRows: 1 }}
|
||||
empty={
|
||||
!busy && !cancelled && !error ? (
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: var(--titlebar-tool-button);
|
||||
height: var(--titlebar-tool-button);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
border-radius: var(--radius-toolbar-button);
|
||||
cursor: pointer;
|
||||
}
|
||||
.go {
|
||||
|
||||
@@ -193,7 +193,6 @@ function Chooser({
|
||||
renderSection={(i) => <span title={i.detail}>{i.rev}</span>}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
aria-label="Revisions"
|
||||
className={styles.grow}
|
||||
renderItem={(i) => (
|
||||
|
||||
@@ -18,6 +18,7 @@ import { currentRepo, useVcs } from "./store";
|
||||
import { syncRow, syncSections, type SyncBranch, type SyncDirection, type SyncSection } from "./syncCommits";
|
||||
import styles from "./SyncCommitsPopup.module.css";
|
||||
import common from "./common.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/** A commit range can be long; the popup shows what git lists, bounded like Compare Branches. */
|
||||
const LIMIT = 2000;
|
||||
@@ -96,6 +97,7 @@ function SyncCommitsPopup({
|
||||
anchor: PopupAnchor;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const sections = useMemo(() => syncSections(source.branch, source.direction), [source.branch, source.direction]);
|
||||
const [lists, setLists] = useState<Commit[][] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -223,7 +225,7 @@ function SyncCommitsPopup({
|
||||
onActivate={(row) => {
|
||||
if (row.type === "commit") openDiff(row.commit);
|
||||
}}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label={title}
|
||||
className={styles.list}
|
||||
/>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { HighlightedText, Icon, Input, List, Popup, fuzzyMatch, listNavigate } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import styles from "./common.module.css";
|
||||
|
||||
@@ -75,6 +76,7 @@ export function TargetBranchInput({
|
||||
remote: string | null;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const rowHeight = useRowHeight(ROW_HEIGHT);
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
// No row is chosen until the user moves in the list: Enter keeps pushing the typed name.
|
||||
@@ -139,7 +141,7 @@ export function TargetBranchInput({
|
||||
<span key={s.name}>{s.name}</span>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.targetListWrap} style={{ height: rows * ROW_HEIGHT + LIST_PADDING }}>
|
||||
<div className={styles.targetListWrap} style={{ height: rows * rowHeight + LIST_PADDING }}>
|
||||
<List
|
||||
items={suggestions}
|
||||
getKey={(s) => s.name}
|
||||
@@ -148,7 +150,7 @@ export function TargetBranchInput({
|
||||
onActivate={(s) => choose(s)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={ROW_HEIGHT}
|
||||
rowHeight={rowHeight}
|
||||
aria-label={tx("Remote branches")}
|
||||
className={styles.targetList}
|
||||
empty={<span className={styles.hint}>{tx("No matching remote branches")}</span>}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { executeAction } from "@/platform/actions";
|
||||
import { conflictedFiles, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/**
|
||||
* The stopped rebase / cherry-pick / revert whose conflicts are being resolved from the
|
||||
@@ -64,6 +65,7 @@ export async function acceptSide(f: FileStatus, side: "ours" | "theirs") {
|
||||
}
|
||||
|
||||
function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const files = useVcs((s) => s.status).filter((f) => f.unstaged === "conflicted");
|
||||
const root = useVcs((s) => s.root) ?? "";
|
||||
const op = useVcs((s) => inProgress(s.branch?.operation));
|
||||
@@ -141,7 +143,7 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
getKey={(f) => f.path}
|
||||
activeIndex={Math.min(active, files.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Conflicted files"
|
||||
className={styles.boxList}
|
||||
empty={
|
||||
|
||||
@@ -204,7 +204,6 @@ function PromptDialog(props: PromptOptions & { onDone: (r: PromptResult | null)
|
||||
activeIndex={active}
|
||||
onActivate={acceptPrefix}
|
||||
focusable={false}
|
||||
rowHeight={24}
|
||||
aria-label={tx("Branch name prefixes")}
|
||||
className={styles.prefixList}
|
||||
renderItem={(prefix, state) => (
|
||||
|
||||
@@ -3,6 +3,7 @@ import { setContext } from "@/platform/context";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { Scrollbar, Spinner, T, hideNativeScrollbar } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useGitLogChecks } from "@/workbench/contributions";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import clsx from "clsx";
|
||||
@@ -219,6 +220,8 @@ export function CommitList() {
|
||||
const selectedSet = useMemo(() => new Set(selection), [selection]);
|
||||
const revealTick = useGitLog((s) => s.revealTick);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
// Commit rows shrink in compact mode; the column header (the scroll margin) keeps ROW.
|
||||
const row = useRowHeight(ROW);
|
||||
const selectedIndex = useMemo(
|
||||
() => (selected ? commits.findIndex((c) => commitKey(c) === selected) : -1),
|
||||
[commits, selected],
|
||||
@@ -232,23 +235,24 @@ export function CommitList() {
|
||||
const previous = previousRows.current;
|
||||
previousRows.current = commits;
|
||||
if (!element || previous === commits || (revealTick !== lastRevealed.current && selectedIndex >= 0)) return;
|
||||
const top = Math.max(0, Math.floor((element.scrollTop - ROW) / ROW));
|
||||
const top = Math.max(0, Math.floor((element.scrollTop - ROW) / row));
|
||||
// Preserve the first surviving visible commit and its pixel offset.
|
||||
for (let i = top; i < previous.length; i++) {
|
||||
const next = commits.findIndex((c) => commitKey(c) === commitKey(previous[i]!));
|
||||
if (next < 0) continue;
|
||||
element.scrollTop += (next - i) * ROW;
|
||||
element.scrollTop += (next - i) * row;
|
||||
break;
|
||||
}
|
||||
}, [commits, revealTick, selectedIndex]);
|
||||
}, [commits, revealTick, selectedIndex, row]);
|
||||
const finished = done;
|
||||
const virtualizer = useVirtualizer({
|
||||
count: commits.length + (finished ? 0 : 1),
|
||||
getScrollElement: () => scrollRef.current,
|
||||
estimateSize: () => ROW,
|
||||
estimateSize: () => row,
|
||||
overscan: 8,
|
||||
scrollMargin: ROW,
|
||||
});
|
||||
useEffect(() => virtualizer.measure(), [virtualizer, row]);
|
||||
const items = virtualizer.getVirtualItems();
|
||||
const last = items[items.length - 1];
|
||||
|
||||
@@ -581,7 +585,7 @@ export function CommitList() {
|
||||
const c = commits[v.index];
|
||||
if (!c)
|
||||
return (
|
||||
<div key="loading" className={styles.row} style={{ top: v.start - ROW }}>
|
||||
<div key="loading" className={styles.row} style={{ top: v.start - ROW, height: row }}>
|
||||
<Spinner size={12} />{" "}
|
||||
<span className={styles.muted}>
|
||||
<T>Loading…</T>
|
||||
@@ -598,6 +602,7 @@ export function CommitList() {
|
||||
fileHistoryTarget={fileHistoryTarget}
|
||||
graph={rows[v.index]}
|
||||
top={v.start - ROW}
|
||||
height={row}
|
||||
selected={selectedSet.has(commitKey(c))}
|
||||
head={headKeys.has(commitKey(c))}
|
||||
mine={opts.highlightMine && isMine(c, user)}
|
||||
|
||||
@@ -22,6 +22,7 @@ function CommitRowView({
|
||||
fileHistoryTarget,
|
||||
graph,
|
||||
top,
|
||||
height,
|
||||
selected,
|
||||
head,
|
||||
mine,
|
||||
@@ -45,6 +46,7 @@ function CommitRowView({
|
||||
fileHistoryTarget: string | null;
|
||||
graph: GraphRow | undefined;
|
||||
top: number;
|
||||
height: number;
|
||||
selected: boolean;
|
||||
head: boolean;
|
||||
mine: boolean;
|
||||
@@ -162,7 +164,7 @@ function CommitRowView({
|
||||
selected && styles.selected,
|
||||
opts.showColumnDividers && styles.showDividers,
|
||||
)}
|
||||
style={{ top }}
|
||||
style={{ top, height }}
|
||||
onMouseDown={(e) => {
|
||||
if (e.shiftKey) e.preventDefault(); // no text selection on range clicks
|
||||
onPick(commitKey(c), e);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { Fragment } from "react";
|
||||
import styles from "../GitLog.module.css";
|
||||
import { laneColor, type GraphRow, type GraphSegment } from "../graph";
|
||||
@@ -38,14 +39,15 @@ export function GraphCell({
|
||||
onNode?: () => void;
|
||||
interactive?: boolean;
|
||||
}) {
|
||||
const cy = ROW / 2;
|
||||
const height = useRowHeight(ROW);
|
||||
const cy = height / 2;
|
||||
const width = row.width * LANE;
|
||||
const draw = (s: GraphSegment, i: number, up: boolean) => {
|
||||
const fromX = x(s.fromX ?? s.from);
|
||||
const toX = x(s.toX ?? s.to);
|
||||
const path =
|
||||
seg(fromX, up ? 0 : cy, toX, up ? cy : ROW) +
|
||||
(s.arrow ? arrowHead(up ? fromX : toX, up ? 0 : ROW, up ? -1 : 1) : "");
|
||||
seg(fromX, up ? 0 : cy, toX, up ? cy : height) +
|
||||
(s.arrow ? arrowHead(up ? fromX : toX, up ? 0 : height, up ? -1 : 1) : "");
|
||||
const line = (
|
||||
<path
|
||||
key={interactive ? undefined : `${up ? "u" : "d"}${i}`}
|
||||
@@ -114,7 +116,7 @@ export function GraphCell({
|
||||
<svg
|
||||
className={styles.graph}
|
||||
width={width}
|
||||
height={ROW}
|
||||
height={height}
|
||||
aria-label={tx("Commit graph")}
|
||||
onMouseLeave={() => onHover?.(null)}
|
||||
>
|
||||
|
||||
@@ -18,6 +18,7 @@ import { activeList, useChangelists } from "./changelists";
|
||||
import { currentRepoRoot, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
export type PatchOrigin =
|
||||
| { kind: "changes"; files: FileStatus[] }
|
||||
@@ -259,6 +260,7 @@ export async function showApplyPatch(from: "file" | "clipboard", path?: string)
|
||||
}
|
||||
|
||||
function ApplyPatchDialog({ patch, source, onClose }: { patch: string; source: string; onClose: () => void }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const [repo] = useState(currentRepoRoot);
|
||||
const [files, setFiles] = useState<PatchFile[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -316,7 +318,7 @@ function ApplyPatchDialog({ patch, source, onClose }: { patch: string; source: s
|
||||
<List
|
||||
items={files}
|
||||
getKey={(f) => f.path}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Patch files"
|
||||
className={styles.boxList}
|
||||
empty={
|
||||
|
||||
@@ -30,6 +30,7 @@ import { pushOperation, splitTracked, type PushChoice } from "./pushTarget";
|
||||
import { currentRepo, currentRepoRoot, loadBranches, refreshNow, repoName, useVcs } from "./store";
|
||||
import { stripRemotePrefix, TargetBranchInput } from "./TargetBranchInput";
|
||||
import styles from "./common.module.css";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/** Update Project… scope: one repository (`null`: the selected one), else every repository. */
|
||||
export interface UpdateTarget {
|
||||
@@ -256,6 +257,7 @@ interface MultiPushDialogProps {
|
||||
}
|
||||
|
||||
function MultiPushDialog({ only, onClose }: MultiPushDialogProps) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const allRoots = useVcs((s) => s.roots);
|
||||
const roots = useMemo(() => (only === undefined ? allRoots : allRoots.filter((r) => r === only)), [allRoots, only]);
|
||||
const [repos, setRepos] = useState<RepoPush[] | null>(null);
|
||||
@@ -474,7 +476,7 @@ function MultiPushDialog({ only, onClose }: MultiPushDialogProps) {
|
||||
selected={new Set(shown ? [shown.key] : [])}
|
||||
multiSelect={false}
|
||||
onSelectionChange={(_sel, lead) => setShown(lead)}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Outgoing commits"
|
||||
className={styles.boxList}
|
||||
empty={
|
||||
@@ -604,6 +606,7 @@ function PushRowTarget(props: {
|
||||
}
|
||||
|
||||
function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClose: () => void }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const [repo] = useState(currentRepo);
|
||||
const [branch] = useState(() => useVcs.getState().branch);
|
||||
const [branches] = useState(() => useVcs.getState().branches);
|
||||
@@ -737,7 +740,7 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
|
||||
getKey={(c) => c.id}
|
||||
activeIndex={shownCommit}
|
||||
onActiveChange={setShownCommit}
|
||||
rowHeight={22}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Outgoing commits"
|
||||
className={styles.boxList}
|
||||
empty={<span>{upstream ? tx("Everything is up to date") : tx("No commits")}</span>}
|
||||
|
||||
+21
-3
@@ -295,6 +295,8 @@ html {
|
||||
--fs-tiny: 11px;
|
||||
--fs-code: 13px;
|
||||
--fs-input-large: 15px;
|
||||
/* main toolbar, status bar, tool window headers and editor tabs (IDEA fontSizeOffset) */
|
||||
--fs-chrome: var(--fs-ui);
|
||||
--lh-code: 22px;
|
||||
|
||||
/* metrics (theme JSON at 100%) */
|
||||
@@ -302,6 +304,8 @@ html {
|
||||
/* IDEA's compact header (HEADER_HEIGHT_DFM), the same in compact mode. */
|
||||
--h-compact-header: 30px;
|
||||
--titlebar-tool-button: 30px;
|
||||
/* main toolbar dropdowns: project, VCS branch, run configuration */
|
||||
--h-toolbar-widget: 30px;
|
||||
/* tool window stripe button, icons only */
|
||||
--stripe-icon-button: 30px;
|
||||
--stripe-outer-padding: 4px;
|
||||
@@ -324,6 +328,8 @@ html {
|
||||
--radius-control: 4px;
|
||||
--radius-tab: 6px;
|
||||
--radius-toolbar-button: 6px;
|
||||
/* main toolbar dropdowns (MainToolbar.Dropdown.arc 12): unchanged in compact mode */
|
||||
--radius-toolbar-dropdown: 6px;
|
||||
--radius-floating-toolbar: 3px;
|
||||
--h-floating-toolbar-button: 22px;
|
||||
--floating-toolbar-top: 25px;
|
||||
@@ -1496,18 +1502,30 @@ html {
|
||||
* Appearance options (Settings › Appearance), applied as attributes on :root
|
||||
* by the settings runtime.
|
||||
*/
|
||||
/* Compact mode: smaller rows, toolbars and tabs. */
|
||||
/*
|
||||
* Compact mode: smaller rows, toolbars and tabs. Values follow IDEA's `*.compact`
|
||||
* theme keys (Islands): Tree/List.rowHeight 22, MainToolbar.Button.size and
|
||||
* RunWidget.toolbarHeight 26, Island.borderWidth 4, chrome fontSizeOffset -1.
|
||||
* Swing `arc` is a diameter, so radii here are half of it.
|
||||
*/
|
||||
:root[data-compact] {
|
||||
--h-titlebar: 32px;
|
||||
--titlebar-tool-button: 26px;
|
||||
--h-toolbar-widget: 26px;
|
||||
--h-header: 32px;
|
||||
--h-tabbar: 32px;
|
||||
--h-tab: 24px;
|
||||
--h-row: 20px;
|
||||
--h-list-row: 20px;
|
||||
--h-row: 22px;
|
||||
--h-list-row: 22px;
|
||||
--h-statusbar: 24px;
|
||||
--stripe-icon-button: 24px;
|
||||
--h-field: 24px;
|
||||
--h-button: 24px;
|
||||
--fs-chrome: calc(var(--fs-ui) - 1px);
|
||||
--island-gap: 4px;
|
||||
--island-radius: 8px;
|
||||
--radius-control: 3px;
|
||||
--radius-toolbar-button: 4px;
|
||||
}
|
||||
/* Use contrast scrollbars. */
|
||||
:root[data-contrast-scrollbars] {
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
}
|
||||
/* Status bar widget (StatusBar.Widget): UI font, secondary text, rounded hover. */
|
||||
.status {
|
||||
height: 22px;
|
||||
height: max(var(--h-statusbar) - 8px, var(--h-control-small));
|
||||
margin: 0 -2px;
|
||||
padding: 0 6px;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-ui);
|
||||
font-size: var(--fs-chrome);
|
||||
}
|
||||
/* Main toolbar widget (project / VCS / run configuration). */
|
||||
.title {
|
||||
height: 28px;
|
||||
height: var(--h-toolbar-widget);
|
||||
margin: 0 -4px;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-toolbar-button, 6px);
|
||||
border-radius: var(--radius-toolbar-dropdown);
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
.mono {
|
||||
|
||||
+7
-2
@@ -16,6 +16,7 @@ import {
|
||||
} from "react";
|
||||
import clsx from "clsx";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { useRowHeight } from "./density";
|
||||
import { rowSelectionMode } from "./rowSelection";
|
||||
import styles from "./List.module.css";
|
||||
|
||||
@@ -133,8 +134,8 @@ export function List<T>({
|
||||
isSelected,
|
||||
onActivate,
|
||||
onContextMenu,
|
||||
rowHeight = 24,
|
||||
sectionHeight = 24,
|
||||
rowHeight: fixedRowHeight,
|
||||
sectionHeight: fixedSectionHeight,
|
||||
sectionHeightOf,
|
||||
focusable = true,
|
||||
hoverSelects = false,
|
||||
@@ -154,6 +155,9 @@ export function List<T>({
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const generatedId = useId();
|
||||
const baseId = id ?? generatedId;
|
||||
const defaultRowHeight = useRowHeight();
|
||||
const rowHeight = fixedRowHeight ?? defaultRowHeight;
|
||||
const sectionHeight = fixedSectionHeight ?? defaultRowHeight;
|
||||
const virtualizer = useVirtualizer({
|
||||
count: items.length,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
@@ -161,6 +165,7 @@ export function List<T>({
|
||||
overscan,
|
||||
getItemKey: (i) => getKey(items[i]!, i),
|
||||
});
|
||||
useEffect(() => virtualizer.measure(), [virtualizer, rowHeight, sectionHeight]);
|
||||
|
||||
const viewportHeight = virtualizer.scrollRect?.height;
|
||||
useEffect(() => {
|
||||
|
||||
@@ -253,7 +253,6 @@ export function SelectListbox<V extends string = string>({
|
||||
onActivate={(o) => choose(o)}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
rowHeight={24}
|
||||
aria-label={given(aria["aria-label"])}
|
||||
className={clsx(styles.list, listClassName)}
|
||||
renderItem={(o) => {
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
.editor {
|
||||
--tab-inline-padding: var(--space-2);
|
||||
height: var(--h-header);
|
||||
font-size: var(--fs-chrome);
|
||||
padding: 0 4px;
|
||||
}
|
||||
.compact {
|
||||
/* Shrinks inside tool window headers so the overflow dropdown can take over. */
|
||||
flex: 0 1 auto;
|
||||
height: 28px;
|
||||
height: var(--h-tab);
|
||||
}
|
||||
.scroller {
|
||||
display: flex;
|
||||
@@ -41,7 +42,7 @@
|
||||
align-items: stretch;
|
||||
height: calc(100% - 6px);
|
||||
min-height: 22px;
|
||||
max-height: 28px;
|
||||
max-height: var(--h-tab);
|
||||
border-radius: var(--radius-tab, 6px);
|
||||
color: var(--fg-strong);
|
||||
transition:
|
||||
|
||||
+3
-2
@@ -38,9 +38,9 @@ import { useGivenTx } from "@/platform/i18n";
|
||||
import { useTreeReorder, type TreeReorder } from "./treeReorder";
|
||||
import { startPointerDrag, type DragData } from "./pointerDrag";
|
||||
import { useTreeDirectoryContext } from "./treeDirectoryContext";
|
||||
import { useRowHeight } from "./density";
|
||||
import { useIconRowHeight } from "./iconAppearance";
|
||||
|
||||
const DEFAULT_ROW_HEIGHT = 24;
|
||||
export type { TreeReorder } from "./treeReorder";
|
||||
|
||||
export interface TreeRowState {
|
||||
@@ -353,7 +353,8 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
const leadIndex = lead != null ? (indexOfKey.get(lead) ?? -1) : -1;
|
||||
|
||||
const themedRowHeight = useIconRowHeight();
|
||||
const rowHeight = fixedRowHeight ?? themedRowHeight ?? DEFAULT_ROW_HEIGHT;
|
||||
const defaultRowHeight = useRowHeight();
|
||||
const rowHeight = fixedRowHeight ?? themedRowHeight ?? defaultRowHeight;
|
||||
const virtualizer = useVirtualizer({
|
||||
count: rows.length,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { act, render, renderHook } from "@testing-library/react";
|
||||
import { List } from "./List";
|
||||
import { Tree } from "./Tree";
|
||||
import { compactRowHeight, setCompactMode, useChromeIconSize, useRowHeight } from "./density";
|
||||
import { setIconAppearance } from "./iconAppearance";
|
||||
|
||||
afterEach(() => {
|
||||
setCompactMode(false);
|
||||
setIconAppearance(null);
|
||||
});
|
||||
|
||||
describe("compact mode density", () => {
|
||||
it("takes 2px off row heights and 4px off chrome icons, like IDEA's compact theme keys", () => {
|
||||
expect(compactRowHeight(24, false)).toBe(24);
|
||||
expect(compactRowHeight(24, true)).toBe(22);
|
||||
expect(compactRowHeight(26, true)).toBe(24);
|
||||
const rows = renderHook(() => [useRowHeight(), useRowHeight(26), useChromeIconSize()]);
|
||||
expect(rows.result.current).toEqual([24, 26, 20]);
|
||||
act(() => setCompactMode(true));
|
||||
expect(rows.result.current).toEqual([22, 24, 16]);
|
||||
});
|
||||
|
||||
it("shrinks default tree rows, keeping a theme or explicit row height", () => {
|
||||
const tree = (rowHeight?: number) => (
|
||||
<Tree
|
||||
roots={[{ key: "a" }]}
|
||||
getKey={(n) => n.key}
|
||||
getLabel={(n) => n.key}
|
||||
getChildren={() => undefined}
|
||||
isExpandable={() => false}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="t"
|
||||
/>
|
||||
);
|
||||
const { container, rerender } = render(tree());
|
||||
const row = () => container.querySelector<HTMLElement>('[role="treeitem"]');
|
||||
expect(row()?.style.height).toBe("24px");
|
||||
act(() => setCompactMode(true));
|
||||
expect(row()?.style.height).toBe("22px");
|
||||
act(() => setIconAppearance({ rowHeight: 30 }));
|
||||
expect(row()?.style.height).toBe("30px");
|
||||
rerender(tree(40));
|
||||
expect(row()?.style.height).toBe("40px");
|
||||
});
|
||||
|
||||
it("shrinks default list rows", () => {
|
||||
const { container } = render(<List items={["a", "b"]} getKey={(s) => s} renderItem={(s) => s} aria-label="l" />);
|
||||
const option = () => container.querySelector<HTMLElement>('[role="option"]');
|
||||
expect(option()?.style.height).toBe("24px");
|
||||
act(() => setCompactMode(true));
|
||||
expect(option()?.style.height).toBe("22px");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
/**
|
||||
* Settings › Appearance › Compact mode, for sizes set from JS (virtualised rows,
|
||||
* icon props). CSS reads the same switch from `:root[data-compact]` (tokens.css).
|
||||
* Steps follow IDEA's Islands theme `*.compact` keys: rows −2 (Tree/List 24 → 22,
|
||||
* VCS log 26 → 24), main-toolbar and stripe icons 20 → 16.
|
||||
*/
|
||||
export const useCompactMode = create<boolean>(() => false);
|
||||
|
||||
export function setCompactMode(on: boolean): void {
|
||||
useCompactMode.setState(on, true);
|
||||
}
|
||||
|
||||
export function compactRowHeight(base: number, compact: boolean): number {
|
||||
return compact ? base - 2 : base;
|
||||
}
|
||||
|
||||
/** Height of a list / tree row whose regular height is `base`. */
|
||||
export function useRowHeight(base = 24): number {
|
||||
return compactRowHeight(base, useCompactMode());
|
||||
}
|
||||
|
||||
/** Icon size for window chrome: main toolbar, run widget, tool window stripes. */
|
||||
export function useChromeIconSize(base = 20): number {
|
||||
return useCompactMode() ? base - 4 : base;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { lookup, t, useI18n } from "@/platform/i18n";
|
||||
import { commands, type MenuNode } from "@/platform/ipc";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { Icon, MenuList, Popup, type MenuItem } from "@/ui";
|
||||
import { useChromeIconSize } from "@/ui/density";
|
||||
import menuStyles from "@/ui/Menu.module.css";
|
||||
import { isDistractionFree } from "./distractionFree";
|
||||
import { toolWindowsRestorable } from "./toolwindows/store";
|
||||
@@ -94,6 +95,7 @@ export function MainMenu({ row = false, ...props }: MainMenuProps) {
|
||||
|
||||
function MainMenuBar({ merged, row, onExpandedChange }: MainMenuProps & { merged: boolean; row: boolean }) {
|
||||
useI18n((s) => s.locale);
|
||||
const iconSize = useChromeIconSize();
|
||||
const [menus, setMenus] = useState<Submenu[]>([]);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const [open, setOpen] = useState<number | null>(null);
|
||||
@@ -249,7 +251,7 @@ function MainMenuBar({ merged, row, onExpandedChange }: MainMenuProps & { merged
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name="main-menu" size={20} />
|
||||
<Icon name="main-menu" size={iconSize} />
|
||||
</button>
|
||||
);
|
||||
const titles = (
|
||||
|
||||
@@ -101,7 +101,6 @@ function CustomizeDialog({ onClose }: { onClose: () => void }) {
|
||||
getKey={(id) => id}
|
||||
activeIndex={sel.side === side ? sel.index : -1}
|
||||
onActiveChange={(index) => setSel({ side, index })}
|
||||
rowHeight={24}
|
||||
className={styles.list}
|
||||
aria-label={side === "left" ? "Left group" : "Right group"}
|
||||
empty={
|
||||
@@ -212,7 +211,6 @@ function AddPicker({ hidden, present, onPick }: { hidden: string[]; present: str
|
||||
activeIndex={active}
|
||||
onActiveChange={setActive}
|
||||
onActivate={(c) => onPick(c.id)}
|
||||
rowHeight={24}
|
||||
className={styles.pickerList}
|
||||
aria-label="Actions and widgets to add"
|
||||
renderItem={(c, state) => (
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
gap: var(--space-1);
|
||||
padding: 0 10px 0 12px;
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--fs-ui);
|
||||
font-size: var(--fs-chrome);
|
||||
color: var(--fg-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
/* IDEA's compact status bar is just its widgets' height (StatusBar.Widget.widgetInsets 4,8,3,8). */
|
||||
:global(:root[data-compact]) .bar {
|
||||
height: var(--h-statusbar);
|
||||
}
|
||||
/* Widgets read as plain UI text like IDEA's, whatever their own font. */
|
||||
.item {
|
||||
font-family: var(--font-ui);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
color: var(--fg-strong);
|
||||
font-size: var(--fs-chrome);
|
||||
}
|
||||
/* Room for the native macOS traffic lights (Overlay title bar). */
|
||||
.overlay {
|
||||
@@ -68,12 +69,12 @@
|
||||
/* Main toolbar dropdown widgets. */
|
||||
.widget {
|
||||
min-width: 0;
|
||||
height: 30px;
|
||||
height: var(--h-toolbar-widget);
|
||||
margin: 0;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-popup);
|
||||
border-radius: var(--radius-toolbar-dropdown);
|
||||
color: var(--fg-strong);
|
||||
font-size: var(--fs-ui);
|
||||
font-size: var(--fs-chrome);
|
||||
}
|
||||
.widget {
|
||||
gap: var(--space-1-5);
|
||||
@@ -106,6 +107,12 @@
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
/* IDEA compact: the avatar follows MainToolbar.Button.iconSize (20 → 16). */
|
||||
:global(:root[data-compact]) .avatar {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 9px;
|
||||
}
|
||||
.drag {
|
||||
flex: 1;
|
||||
align-self: stretch;
|
||||
@@ -120,7 +127,7 @@
|
||||
.tool {
|
||||
width: var(--titlebar-tool-button);
|
||||
height: var(--titlebar-tool-button);
|
||||
border-radius: var(--radius-popup);
|
||||
border-radius: var(--radius-toolbar-button);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useActions } from "@/platform/actions";
|
||||
import { shortcutLabel, useKeymap } from "@/platform/keymap";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { BarButton, Icon, IconButton, Menu, type MenuItem, showContextMenu, T } from "@/ui";
|
||||
import { useChromeIconSize } from "@/ui/density";
|
||||
import { useContributions, useWorkbenchSlots, type TitleItemContribution } from "./contributions";
|
||||
import { ErrorBoundary, Slot } from "./ErrorBoundary";
|
||||
import { MainMenu } from "./MainMenu";
|
||||
@@ -213,6 +214,7 @@ function useToolbar() {
|
||||
}
|
||||
|
||||
function GearButton({ customize }: { customize: MenuItem[] }) {
|
||||
const iconSize = useChromeIconSize();
|
||||
const [open, setOpen] = useState(false);
|
||||
const ref = useRef<HTMLButtonElement>(null);
|
||||
const settings = useProject((s) => s.settings);
|
||||
@@ -241,7 +243,7 @@ function GearButton({ customize }: { customize: MenuItem[] }) {
|
||||
ref={ref}
|
||||
icon="settings"
|
||||
title="IDE and Project Settings"
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={styles.tool}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
@@ -255,6 +257,7 @@ function GearButton({ customize }: { customize: MenuItem[] }) {
|
||||
/** One main toolbar entry: a built-in widget, a contributed one or an added action. */
|
||||
function ToolbarEntry({ id, items }: { id: string; items: ReadonlyMap<string, TitleItemContribution> }) {
|
||||
const actions = useActions((s) => s.actions);
|
||||
const iconSize = useChromeIconSize();
|
||||
if (id === PROJECT_WIDGET) return <ProjectButton />;
|
||||
const item = items.get(id);
|
||||
if (item) return <TitleItem item={item} />;
|
||||
@@ -269,7 +272,7 @@ function ToolbarEntry({ id, items }: { id: string; items: ReadonlyMap<string, Ti
|
||||
action={action.id}
|
||||
title={action.title}
|
||||
shortcut={shortcutLabel(action.id) ?? (action.id === "navigate.searchEverywhere" ? "⇧⇧" : undefined)}
|
||||
iconSize={20}
|
||||
iconSize={iconSize}
|
||||
className={styles.tool}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -268,7 +268,6 @@ function ChooseDialog({ options, done }: { options: ChooseItemOptions; done: (v:
|
||||
activeIndex={active}
|
||||
onActiveChange={setActive}
|
||||
onActivate={(item) => done(item)}
|
||||
rowHeight={24}
|
||||
className={styles.list}
|
||||
aria-label={options.title}
|
||||
empty={
|
||||
@@ -474,7 +473,6 @@ function PathDialog({ options, done }: { options: ChoosePathOptions; done: (v: s
|
||||
}}
|
||||
// A click selects; a double click or Enter opens the folder or chooses the file.
|
||||
onActivate={(entry, _i, e) => (e.type !== "click" || e.detail > 1) && choose(entry)}
|
||||
rowHeight={24}
|
||||
className={styles.pathList}
|
||||
aria-label={dir ?? options.title}
|
||||
empty={
|
||||
|
||||
@@ -343,6 +343,11 @@
|
||||
min-height: 44px;
|
||||
padding: 6px 2px 5px;
|
||||
}
|
||||
/* IDEA compact: StripeToolbar.Button.*IconWithName.padding 4 → 3, text padding 6 → 4. */
|
||||
:global(:root[data-compact]) .stripeNamed {
|
||||
min-height: 40px;
|
||||
padding: 4px 2px 3px;
|
||||
}
|
||||
.stripeMore {
|
||||
height: var(--stripe-icon-button);
|
||||
}
|
||||
@@ -440,6 +445,7 @@
|
||||
gap: var(--space-1-5);
|
||||
padding: 0 6px 0 8px;
|
||||
color: var(--fg-emphasis);
|
||||
font-size: var(--fs-chrome);
|
||||
}
|
||||
.headerTabbed {
|
||||
border-bottom: 1px solid var(--border);
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
tooltipAttrs,
|
||||
type MenuItem,
|
||||
} from "@/ui";
|
||||
import { useChromeIconSize } from "@/ui/density";
|
||||
import { FOCUSABLE } from "@/ui/popupState";
|
||||
import { TabStripRegistry } from "@/ui/Tabs";
|
||||
import {
|
||||
@@ -441,6 +442,7 @@ function StripeButton({
|
||||
side: "left" | "right";
|
||||
showName: boolean;
|
||||
}) {
|
||||
const iconSize = useChromeIconSize();
|
||||
const shortcut = shortcutLabel(`toolwindow.${tw.id}`);
|
||||
const dragged = useStripeDrag((s) => s.id === tw.id);
|
||||
return (
|
||||
@@ -469,7 +471,7 @@ function StripeButton({
|
||||
{...tooltipAttrs(toolWindowTitle(tw), shortcut, true)}
|
||||
>
|
||||
<span className={styles.stripeIcon}>
|
||||
<Icon name={tw.icon} size={20} />
|
||||
<Icon name={tw.icon} size={iconSize} />
|
||||
{tw.useBadge && <StripeBadge useBadge={tw.useBadge} />}
|
||||
</span>
|
||||
{showName && (
|
||||
@@ -483,6 +485,7 @@ function StripeButton({
|
||||
|
||||
/** Stripe "…": tool windows without a stripe button; opening one adds its button (IDEA). */
|
||||
function StripeMore({ windows }: { windows: ToolWindowContribution[] }) {
|
||||
const iconSize = useChromeIconSize();
|
||||
const [open, setOpen] = useState(false);
|
||||
const ref = useRef<HTMLButtonElement>(null);
|
||||
const items = useMemo<MenuItem[]>(
|
||||
@@ -512,7 +515,7 @@ function StripeMore({ windows }: { windows: ToolWindowContribution[] }) {
|
||||
data-tooltip-stripe="left"
|
||||
{...tooltipAttrs("More Tool Windows")}
|
||||
>
|
||||
<Icon name="more-horizontal" size={20} />
|
||||
<Icon name="more-horizontal" size={iconSize} />
|
||||
</button>
|
||||
<Menu
|
||||
open={open}
|
||||
|
||||
Reference in New Issue
Block a user