App menu: the titlebar's "Settings and more" (Alt+F, F10, the palette, the account menu's last row) with rows from the site config; page zoom per tab in the host

Frame: AppMenu.tsx is a menu at the end of the titlebar cluster (before the caption buttons; macOS has none there). Its rows are `ShellSite.menu`: ordered groups of built-in rows by name and the app's own ({id, label, icon, shortcut, hint, when, checked, run | submenu}); `DEFAULT_MENU`, `menuWith` and `menuWithout` order, add and remove. A built-in row shows only when the app serves it (decks, `menu.languages`, themes, `menu.modes`, and `features`: zoom, store, workspaces, developer, updates), so no app gets a dead row. Language, Theme, Mode, Workspaces and Developer are submenus; Language and Theme apply live and keep the menu open, Mode asks the same keep-my-changes question as Settings (panel `menuModes()`). Keyboard: arrows, Home/End, type-ahead, the arrow along the reading direction opens a submenu, Esc closes one level; ARIA menu roles; submenus stay inside the window; one highlight for pointer and keys. It is an overlay like the other shell menus (the shell is raised, panes stay visible, nothing is dimmed).

Words: menuMessages.en.json (`wb.menu.*`), read through the framework i18n with that English as the fallback until the catalogs have them; words the panel already has are reused.

Host: `tab_zoom {id, factor}` (shell-only) sets a tab's page zoom with the engine's own zoom, clamped to 25%..500% and remembered per tab id in app data `zoom.json` (a number per tab id, nothing else; a closed tab's entry goes); without a factor it reads. A tab may forward four more shortcut names: `app-menu`, `zoom-in`, `zoom-out`, `zoom-reset`. The titlebar shows a zoom chip only while the pane in front is not at 100%.

create-waybetter: `tab_zoom` in the shell capability list; the template says which panel sections it lacks (store, updates) and how to add menu rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-30 21:52:51 +07:00
parent eed6bdd8f4
commit e5d43afffc
27 changed files with 1587 additions and 18 deletions

View file

@ -0,0 +1,80 @@
/* The app menu (AppMenu.tsx): the titlebar's "Settings and more" button, its menu and submenus.
Tokens come from shell.css (:root --bt-*), so it follows the chrome theme (and its first-frame
cache) like every other shell menu. Its width in the titlebar is reserved in --bt-tb-menu. */
/* The button: the last thing before the caption buttons. */
.bt-app-button {
align-self: center; display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; margin-right: 8px; padding: 0; box-sizing: border-box; /* rtl-ok: titlebar */
border: 1px solid transparent; border-radius: 15px; background: transparent; color: var(--bt-text-2); cursor: pointer;
transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease);
}
.bt-app-button:hover { background: var(--bt-hover); border-color: var(--bt-line-soft); color: var(--bt-text); }
.bt-app-button[aria-expanded=true] { background: var(--bt-hover); border-color: rgb(var(--bt-accent-rgb) / .5); color: var(--bt-text); }
.bt-app-button:focus-visible { outline: 0; box-shadow: var(--bt-ring); }
.bt-shell .bt-app-button svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
/* The menu and its submenus. `display: contents`: the layers are positioned on their own. */
.bt-app-layers { display: contents; }
.bt-menu.bt-app-menu {
width: 304px; max-width: calc(100vw - 16px); padding: 6px; overflow-y: auto; overscroll-behavior: contain;
scrollbar-width: thin; scrollbar-color: var(--bt-line-strong) transparent;
}
.bt-menu.bt-app-menu:focus { outline: 0; }
.bt-menu.bt-app-sub {
width: max-content; min-width: 224px; max-width: min(320px, calc(100vw - 16px)); z-index: 1;
animation: bt-app-sub-in var(--bt-t1) var(--bt-ease-out);
}
@keyframes bt-app-sub-in { from { opacity: 0; transform: translateX(6px); } }
.bt-app-menu hr { flex: none; width: auto; align-self: stretch; }
/* Rows: one highlight, wherever it comes from (the pointer moves the focus, as the arrows do);
a row whose submenu is open keeps it; the keyboard's focus also gets a hairline in the accent. */
.bt-app-menu button { flex: none; width: 100%; min-width: 0; box-sizing: border-box; }
.bt-app-menu button:hover:not(:disabled) { background: transparent; }
.bt-app-menu button:focus:not(:disabled), .bt-app-menu button[aria-expanded=true] { background: var(--bt-hover); outline: 0; }
.bt-app-menu button:focus-visible:not(:disabled) { box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .6); }
.bt-app-menu button:active:not(:disabled) { background: var(--bt-press); }
.bt-app-menu button:focus > .bt-glyph, .bt-app-menu button[aria-expanded=true] > .bt-glyph { color: var(--bt-text); }
/* The leading column: an icon, or the check of a choice (empty while it is not the one chosen). */
.bt-app-check { display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; }
.bt-app-check .bt-glyph { width: 15px; height: 15px; color: var(--bt-accent); stroke-width: 2.1; }
.bt-app-menu [aria-checked=true] .bt-menu-label { color: var(--bt-text); font-weight: 600; }
/* The trailing column: a quiet value (the language in use, a version), the keys, the submenu arrow. */
.bt-app-hint { flex: 0 1 auto; min-width: 0; max-width: 46%; margin-inline-start: auto; padding-inline-start: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bt-muted); font: 400 12px/1.3 var(--bt-ui); font-variant-numeric: tabular-nums; }
.bt-app-menu .bt-menu-keys { flex: none; padding-inline-start: 12px; unicode-bidi: isolate; direction: ltr; }
.bt-app-hint + .bt-menu-keys, .bt-app-menu .wb-dots + .bt-app-hint { margin-inline-start: 0; }
.bt-app-menu .bt-app-chevron { width: 14px; height: 14px; margin-inline: 2px -4px; color: var(--bt-faint); }
.bt-app-menu .bt-app-hint + .bt-app-chevron { margin-inline-start: -4px; }
.bt-app-menu button:focus > .bt-app-chevron, .bt-app-menu button[aria-expanded=true] > .bt-app-chevron { color: var(--bt-text-2); }
[dir="rtl"] .bt-app-menu .bt-app-chevron { transform: scaleX(-1); }
.bt-app-menu .wb-dots { margin-inline-start: 8px; }
/* Zoom: one line, − 100% + and a reset. The stepper reads left to right in every language. */
.bt-app-zoom { display: flex; align-items: center; gap: 10px; height: 36px; flex: none; padding-inline: 10px 3px; color: var(--bt-text); }
.bt-app-zoom > .bt-glyph { color: var(--bt-muted); }
.bt-app-zoom.is-off > .bt-glyph, .bt-app-zoom.is-off .bt-menu-label, .bt-app-zoom.is-off .bt-app-zoom-value { color: var(--bt-faint); }
.bt-app-zoom-step { display: flex; align-items: center; flex: none; height: 28px; border-radius: 9px; direction: ltr; background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px var(--bt-line); }
.bt-app-menu .bt-app-zoom button { width: 30px; height: 28px; flex: none; padding: 0; justify-content: center; border-radius: 8px; color: var(--bt-text-2); }
.bt-app-menu .bt-app-zoom button > .bt-glyph { width: 14px; height: 14px; color: inherit; }
.bt-app-menu .bt-app-zoom button:focus { color: var(--bt-text); }
.bt-app-menu .bt-app-zoom button[aria-disabled=true] { color: var(--bt-faint); cursor: default; }
.bt-app-menu .bt-app-zoom button[aria-disabled=true]:active { background: var(--bt-hover); }
.bt-app-zoom-value { min-width: 50px; padding: 0 2px; text-align: center; color: var(--bt-text); font: 500 12px/1 var(--bt-mono); font-variant-numeric: tabular-nums; }
.bt-app-menu .bt-app-zoom .bt-app-zoom-reset { width: 28px; border-radius: 9px; }
/* Words that are not a choice: the mode question, an empty list, an error. */
.bt-app-note { display: flex; flex-direction: column; gap: 3px; max-width: 288px; padding: 8px 10px 7px; box-sizing: border-box; }
.bt-app-note strong { color: var(--bt-text); font: 600 13px/1.3 var(--bt-ui); }
.bt-app-note span { color: var(--bt-muted); font: 400 12px/1.4 var(--bt-ui); white-space: normal; }
.bt-app-note.is-error span { color: var(--bt-danger); }
/* The account menu's last row: the way here from where the account name is. */
.bt-menu .bt-acct-settings { flex: none; height: 34px; gap: 11px; padding: 0 8px; border-radius: 10px; color: var(--bt-text-2); }
.bt-menu .bt-acct-settings > .bt-glyph { width: 32px; height: 15px; }
.bt-menu .bt-acct-settings:focus-visible { box-shadow: var(--bt-ring); }
/* The titlebar's zoom chip: only while the pane in front is not at 100% (TitlebarExtras.tsx). */
.bt-zoom-chip { font-family: var(--bt-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.bt-zoom-chip .bt-glyph { color: var(--bt-muted); }