From 5ccbc09ce7d43d226683589e8141f9e216f2f176 Mon Sep 17 00:00:00 2001 From: blasty Date: Fri, 7 Aug 2026 23:24:12 +0200 Subject: Centre modals with a rule about modals, not a list of them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SearchPalette opened pinned to the top of the screen: the CSS named the screens that centre (`SymbolPalette, StringsPalette, ProjectPalette, …`) and a new dialog is not on a list nobody remembers to edit. The comment sitting above that rule — "every #pal-box palette centres, not just the symbol one" — was the *first* time this happened. `ModalScreen { align: center middle; }` matches subclasses, so every dialog inherits it and the next one is centred for free; the eight per-screen rules that only repeated it are gone. Textual's own Ctrl+P CommandPalette is a ModalScreen too and wants its stock top alignment, so it opts out in one visible line rather than by omission. The `modal_centering` scenario checks both halves: that centring is expressed as a rule, and that it actually reaches a dialog's laid-out region (above/below and left/right within a cell). 894 passed, 0 failed. --- docs/TEXTUAL_NOTES.md | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs') diff --git a/docs/TEXTUAL_NOTES.md b/docs/TEXTUAL_NOTES.md index 83d385c..10df669 100644 --- a/docs/TEXTUAL_NOTES.md +++ b/docs/TEXTUAL_NOTES.md @@ -53,6 +53,13 @@ Hard-won Textual behaviour and the patterns this app relies on. Pairs with `build_byte_to_codepoint_dict`, so character offsets smear on non-ASCII), and a `TextAreaTheme` that sets `base_style` overrides the widget's CSS colours — ours sets only `syntax_styles` so the editor keeps the app's background. +- **Centre modals with a rule, not a list.** `ModalScreen { align: center middle; }` + matches subclasses, so every dialog inherits it and the next one is centred + for free. Naming the screens instead (`SymbolPalette, StringsPalette, …`) is + how two palettes shipped pinned to the top of the screen. Textual's own + `CommandPalette` is a ModalScreen too and wants its stock top alignment, so it + opts out explicitly. The `modal_centering` scenario asserts both the rule and + that it reaches a real dialog's `region`. - **Modal chrome lives in ONE grouped CSS rule** (`#quit-box, #help-box, …` in `IdaTui.CSS`): `border: round`, title colour, subtitle colour. Per-box rules carry only size. Dialog titles are `border_title`/`border_subtitle` on the box, -- cgit v1.3.1-sl0p