Files
pipelines/app/notes/design-compact.md
T

95 lines
4.6 KiB
Markdown

# Compact design
Default's Material 3 look, packed tight for a big monitor and long runs and
chats (Settings > Design > Compact). It has the same colours and glass bars
as Default. Type is smaller: body 13px, labels 11-12px, chat reading 14px on a
1.5 line. Spacing sits on a 4px grid. Rows are 36px with one line and about
54px with two. Icons are 18px, avatars 28px, and every corner is 6px.
## Tokens
- `density` (`DesignDensity`, `design_density.dart`; `comfortable` for every
other design). It holds `spacing` (0.6), `iconSize` (18), `avatarSize`
(28), `railWidth` (64), `railLabels` (false) and `titleBarHeight` (32).
- `space(v)` scales a widget's own spacing and snaps it to the 4px grid.
- `inset(v)` does the same for side insets, halfway between: 16 becomes 12.
- `minTouchRow` is 40 on touch devices and 0 on pointer devices.
- `dense` and `pointerPlatform` are also available. All of them return the
input unchanged when the density is comfortable, so other designs keep
their numbers.
- `ReadingType.paragraphGap` is the gap between paragraphs of an answer, in
lines. Default is 0.9; Compact is 0.6.
- `AppDesignTokens.denseCorners(r)` gives the design's radius only under a
dense design. It is for surfaces whose own corners the comfortable designs
keep: floating windows (12), search thumbnails, find bars, run detail
boxes and the search field stadium.
- `AppDesign.dense` and `AppDesign.swatchLines` (the picker preview draws 4
thin lines for Compact).
## Themed surfaces
- `compact_theme.dart`, `compact_controls.dart`, `compact_typography.dart`:
- visual density is `compact`;
- the tap target is `shrinkWrap` on desktop and `padded` (40px) on touch;
- Material 3 icon buttons need their own `visualDensity`, otherwise they
ignore the theme's; they are 32px with a padding of 7;
- buttons, chips, fields, the search bar, list tiles, menus, popups,
dialogs, sheets, snack bars, tooltips, FABs (40px), the rail, the
navigation bar, tabs, badges, the scrollbar, date and time pickers all
take 6px corners and dense paddings;
- cards get a hairline, so `Card.outlined` (graph nodes) keeps its outline.
- `AppListRow` / `AppListAvatar`: dense insets, padding and avatar size, plus
the touch minimum.
- `ShellNavigationRail`: 64px wide, icons only with tooltips. Settings uses
the same 56x32 indicator as the tabs.
- The shell and window host read the rail width through
`navigationRailSpaceOf`.
- Chat:
- the operator bubble has 6px corners and 12/8 padding;
- turn gaps and the paragraph gap are tighter;
- the activity line is 28px (40px on touch);
- turn chips, follow-up and automatic-continue cards are tighter;
- code blocks use 8px insets with monospace at 13/14;
- the composer is a 40px pill, and its field padding is 10 because
density takes 4px off each side.
- Top bars: segmented pieces are 40px (`segmentedPieceHeight(context)`) and
title pill padding is 12. Chat bar text buttons have a 32px minimum.
- Floating windows: a 32px title bar with 16px icons and 6px corners on the
frame, outline and page clip.
- Graph: nodes use 12/8 insets with a 32px minimum height.
`graphMetricsOf(context)` tightens the gaps, lanes and padding.
- Settings: `settingsSectionGapOf` and `settingsRowInsetOf` give 16 and 12,
and the group header, footer and item paddings are dense.
## Live switch
A switch into or out of a dense design does not blend
(`AppDesignController.themeAnimationDuration` is zero). The reason:
`ThemeData.lerp` takes a component theme's unset size as 0, so every icon
(and any text style set in a component theme) passes through size 0. In
skwasm, laying out glyphs at nearly zero size hung the page. This was
bisected with `tool/perf/design_bench.mjs`, and the pause stack showed
`paragraph_layout`.
For the same reason, Compact's component themes set no text styles. Each
component keeps its Material role, which is already at Compact's size.
`test/ui/theme/compact_switch_test.dart` checks every frame of a switch.
Default, Terminal and Paper keep their blend.
## Perf budget changes
- `test/perf/design_bench_test.dart` budgets `scrollRebuildsPerRow`, not
per frame. A denser design shows more rows in each 120px step.
- `design_bench.mjs` gives the chat-switch clicks per-design points
(`compact: [x, y]`), checked with `tool/capture`.
## Still Default
- Sliders and switches keep their size.
- Tab heights are not themeable.
- The walkthrough's bullet dot sits off the baseline in every design.
- The glass bar margins (`kFloatingBarMargin`) and `GlassBarMetrics` (artifact
viewer, chevron pager) keep 48px.
- Fields that set their own `OutlineInputBorder()` keep 4px corners.