Файли
openidea/src/ui/density.ts
T
Chris Schofield efd4e454ee 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 <[email protected]>
2026-11-20 03:26:32 +08:00

28 рядки
986 B
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
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;
}