gpui-deck 0.0.4

Headless GPUI primitives with application-owned presentation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
//! Command and document navigation with application-owned layout and state.

#[path = "recipes/sidebar.rs"]
mod sidebar;
use super::catalogue_forms::{Sheet, SheetSide};
use sidebar::Sidebar;

use gpui::{
    AppContext as _, Context, Entity, FocusHandle, FontWeight, InteractiveElement as _,
    IntoElement, ParentElement as _, Render, Role, SharedString, StatefulInteractiveElement as _,
    Styled as _, Subscription, Window, div, prelude::FluentBuilder as _, px, rgb,
};
use gpui_deck::{
    Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionState, Align, Breadcrumb,
    BreadcrumbItem, BreadcrumbList, Button, CheckboxState, CollapsibleState, Direction,
    DirectionProvider, DropdownMenu, MenuEvent, MenuItem, MenuOption, MenuState, MenuSubmenu,
    Menubar, MenubarItem, MenubarMenu, MenubarState, NavigationMenu, NavigationMenuEntry,
    NavigationMenuEvent, NavigationMenuItem, NavigationMenuLink, NavigationMenuState, Placement,
    Popover, PopoverState, TabItem, TabsState, TestSupportExt as _, ToggleGroup, ToggleGroupState,
    ToggleItem, ToggleOption,
};

pub(crate) struct NavigationCatalogue {
    bar: Entity<MenubarState>,
    navigation: Entity<NavigationMenuState>,
    file: Entity<MenuState>,
    view: Entity<MenuState>,
    export: Entity<MenuState>,
    path_menu: Entity<MenuState>,
    alignment: Entity<ToggleGroupState>,
    help: Entity<AccordionState>,
    quick_help: Entity<PopoverState>,
    quick_help_close: FocusHandle,
    guide_focus: FocusHandle,
    reference_focus: FocusHandle,
    direction: Direction,
    pub(crate) page: SharedString,
    last_command: SharedString,
    show_grid: bool,
    selection: CheckboxState,
    theme: SharedString,
    pub(crate) sections: Entity<TabsState>,
    pub(crate) sidebar: Entity<CollapsibleState>,
    pub(crate) tools: Entity<CollapsibleState>,
    _subscriptions: Vec<Subscription>,
}

impl NavigationCatalogue {
    pub(crate) fn new(_: &mut Window, cx: &mut Context<Self>) -> Self {
        let export = cx.new(|cx| {
            MenuState::new(
                [
                    MenuItem::new("export-png", "PNG image"),
                    MenuItem::new("export-svg", "SVG image"),
                ],
                cx,
            )
        });
        let file = cx.new(|cx| {
            MenuState::new(
                [
                    MenuItem::new("new", "New document"),
                    MenuItem::new("save", "Save document").disabled(true),
                    MenuItem::new("export", "Export").submenu(&export),
                ],
                cx,
            )
        });
        let view = cx.new(|cx| {
            MenuState::new(
                [
                    MenuItem::new("grid", "Show grid"),
                    MenuItem::new("selection", "Selected layers"),
                    MenuItem::new("system", "System theme"),
                    MenuItem::new("light", "Light theme"),
                    MenuItem::new("dark", "Dark theme"),
                ],
                cx,
            )
        });
        let bar = cx.new(|cx| {
            MenubarState::new(
                [
                    MenubarItem::new("File", &file),
                    MenubarItem::new("View", &view),
                ],
                cx,
            )
        });
        let guide_focus = cx.focus_handle();
        let reference_focus = cx.focus_handle();
        let navigation = cx.new(|cx| {
            NavigationMenuState::new(
                [
                    NavigationMenuItem::new("overview", "Overview"),
                    NavigationMenuItem::new("learn", "Learn")
                        .with_popup()
                        .initial_focus(&guide_focus),
                    NavigationMenuItem::new("reference", "Reference")
                        .with_popup()
                        .initial_focus(&reference_focus),
                    NavigationMenuItem::new("community", "Community"),
                ],
                cx,
            )
        });
        let alignment = cx.new(|cx| {
            ToggleGroupState::new(
                [
                    ToggleItem::new("center", "Center"),
                    ToggleItem::new("end", "End"),
                ],
                cx,
            )
            .single_selection()
        });
        let help = cx.new(|cx| {
            AccordionState::new(
                [
                    AccordionItem::new("alignment", "How does reading alignment work?"),
                    AccordionItem::new("commands", "How do command menus work?"),
                ],
                cx,
            )
            .multiple(true)
            .default_open(["alignment"])
        });
        let quick_help_close = cx.focus_handle();
        let quick_help = cx.new(|cx| PopoverState::new(cx).with_initial_focus(&quick_help_close));
        let sections = cx.new(|cx| {
            TabsState::new(
                [
                    TabItem::new("overview", "Project overview"),
                    TabItem::new("activity", "Activity (unavailable)").disabled(true),
                    TabItem::new("members", "Members"),
                    TabItem::new("exports", "Exports"),
                ],
                cx,
            )
        });
        let sidebar = cx.new(|cx| CollapsibleState::new(cx).default_open(true));
        let tools = cx.new(|cx| CollapsibleState::new(cx).default_open(true));
        // Ancestors hidden behind the breadcrumb ellipsis; values are local pages.
        let path_menu = cx.new(|cx| {
            MenuState::new(
                [
                    MenuItem::new("getting-started", "Documentation"),
                    MenuItem::new("api", "Components"),
                ],
                cx,
            )
        });
        let mut subscriptions = vec![
            cx.observe(&path_menu, |_, _, cx| cx.notify()),
            cx.subscribe(&path_menu, |this: &mut Self, _, event, cx| {
                let MenuEvent::Action(value) = event;
                this.page = value.clone();
                cx.notify();
            }),
            cx.observe(&sections, |_, _, cx| cx.notify()),
            cx.observe(&sidebar, |_, _, cx| cx.notify()),
            cx.observe(&tools, |_, _, cx| cx.notify()),
            cx.observe(&bar, |_, _, cx| cx.notify()),
            cx.observe(&navigation, |_, _, cx| cx.notify()),
            cx.observe(&alignment, |_, _, cx| cx.notify()),
            cx.observe(&help, |_, _, cx| cx.notify()),
            cx.observe(&quick_help, |_, _, cx| cx.notify()),
            cx.subscribe(&navigation, |this: &mut Self, _, event, cx| {
                let NavigationMenuEvent::Navigate(value) = event;
                this.page = value.clone();
                cx.notify();
            }),
        ];
        for menu in [&file, &view] {
            subscriptions.push(cx.subscribe(menu, |this: &mut Self, _, event, cx| {
                let MenuEvent::Action(value) = event;
                this.last_command = value.clone();
                match value.as_ref() {
                    "grid" => this.show_grid = !this.show_grid,
                    "selection" => {
                        this.selection = if this.selection == CheckboxState::Checked {
                            CheckboxState::Unchecked
                        } else {
                            CheckboxState::Checked
                        }
                    }
                    "system" | "light" | "dark" => this.theme = value.clone(),
                    _ => {}
                }
                cx.notify();
            }));
        }
        Self {
            bar,
            navigation,
            file,
            view,
            export,
            path_menu,
            alignment,
            help,
            quick_help,
            quick_help_close,
            guide_focus,
            reference_focus,
            direction: Direction::Ltr,
            page: "overview".into(),
            last_command: "No command selected".into(),
            show_grid: true,
            selection: CheckboxState::Indeterminate,
            theme: "system".into(),
            sections,
            sidebar,
            tools,
            _subscriptions: subscriptions,
        }
    }

    fn menu_option(
        &self,
        menu: &Entity<MenuState>,
        index: usize,
        cx: &Context<Self>,
    ) -> MenuOption {
        let state = menu.read(cx);
        let item = &state.items()[index];
        let marker = if menu == &self.view {
            match index {
                0 if self.show_grid => "✓ ",
                1 if self.selection == CheckboxState::Indeterminate => "− ",
                1 if self.selection == CheckboxState::Checked => "✓ ",
                2..=4 if item.value() == &self.theme => "● ",
                _ => "   ",
            }
        } else {
            ""
        };
        MenuOption::new(menu, index)
            .px_3()
            .py_2()
            .rounded_sm()
            .bg(rgb(if state.highlighted_index() == Some(index) {
                0x334155
            } else {
                0x172033
            }))
            .text_color(rgb(if item.is_disabled() {
                0x64748b
            } else {
                0xe2e8f0
            }))
            .child(format!("{marker}{}", item.label()))
    }

    fn link(
        &self,
        id: &'static str,
        value: &'static str,
        label: &'static str,
    ) -> NavigationMenuLink {
        NavigationMenuLink::new(id, &self.navigation, value)
            .current(self.page.as_ref() == value)
            .px_3()
            .py_2()
            .rounded_sm()
            .bg(rgb(if self.page.as_ref() == value {
                0x1d4ed8
            } else {
                0x172033
            }))
            .button(|button| {
                button
                    .accessibility_label(label)
                    .focus_visible(|style| style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220)))
            })
            .child(label)
    }
}

fn panel() -> gpui::Div {
    div()
        .w(px(230.))
        .p_2()
        .flex()
        .flex_col()
        .gap_1()
        .rounded_md()
        .border_1()
        .border_color(rgb(0x475569))
        .bg(rgb(0x172033))
}

fn trigger(button: Button, label: &'static str, open: bool) -> Button {
    button
        .px_3()
        .py_2()
        .rounded_md()
        .bg(rgb(if open { 0x334155 } else { 0x172033 }))
        .focus_visible(|style| style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220)))
        .child(label)
}

impl Render for NavigationCatalogue {
    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        let direction_label = if self.direction.is_rtl() {
            "Direction: RTL"
        } else {
            "Direction: LTR"
        };
        let open_menu = self.bar.read(cx).open_index(cx);
        let open_navigation = self.navigation.read(cx).open_index(cx);
        let export_highlighted = self.file.read(cx).highlighted_index() == Some(2);
        let alignment = self.alignment.read(cx);
        let alignment_controls = self
            .direction
            .row(
                ToggleGroup::new("reading-alignment", &self.alignment)
                    .accessibility_label("Reading alignment"),
            )
            .gap_2()
            .children(alignment.items().iter().enumerate().map(|(index, item)| {
                ToggleOption::new(&self.alignment, index)
                    .px_3()
                    .py_2()
                    .rounded_md()
                    .bg(rgb(if alignment.is_pressed(index) {
                        0x1d4ed8
                    } else {
                        0x172033
                    }))
                    .focus_visible(|style| style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220)))
                    .child(item.label().clone())
            }));
        let menu =
            self.direction
                .row(Menubar::new(&self.bar).accessibility_label("Document commands"))
                .gap_2()
                .child(
                    MenubarMenu::new(&self.bar, 0)
                        .offset(px(5.))
                        .trigger(|button| trigger(button, "File", open_menu == Some(0)))
                        .content(
                            panel()
                                .child(self.menu_option(&self.file, 0, cx))
                                .child(self.menu_option(&self.file, 1, cx))
                                .child(
                                    MenuSubmenu::new(&self.file, 2)
                                        .trigger(|option| {
                                            option
                                                .px_3()
                                                .py_2()
                                                .rounded_sm()
                                                .bg(rgb(if export_highlighted {
                                                    0x334155
                                                } else {
                                                    0x172033
                                                }))
                                                .child(if self.direction.is_rtl() {
                                                    "‹ Export"
                                                } else {
                                                    "Export ›"
                                                })
                                        })
                                        .content(panel().children((0..2).map(|index| {
                                            self.menu_option(&self.export, index, cx)
                                        }))),
                                ),
                        ),
                )
                .child(
                    MenubarMenu::new(&self.bar, 1)
                        .offset(px(5.))
                        .trigger(|button| trigger(button, "View", open_menu == Some(1)))
                        .content(
                            panel()
                                .child(self.menu_option(&self.view, 0, cx).checked(self.show_grid))
                                .child(
                                    self.menu_option(&self.view, 1, cx)
                                        .check_state(self.selection),
                                )
                                .child(
                                    div()
                                        .id("catalogue-appearance")
                                        .role(Role::Group)
                                        .aria_label("Appearance")
                                        .flex()
                                        .flex_col()
                                        .border_t_1()
                                        .border_color(rgb(0x475569))
                                        .pt_1()
                                        .children((2..5).map(|index| {
                                            self.menu_option(&self.view, index, cx).radio_checked(
                                                self.view.read(cx).items()[index].value()
                                                    == &self.theme,
                                            )
                                        })),
                                ),
                        ),
                );

        let navigation = self
            .direction
            .row(NavigationMenu::new(&self.navigation).accessibility_label("Documentation pages"))
            .gap_2()
            .flex_wrap()
            .child(
                NavigationMenuEntry::new(&self.navigation, 0)
                    .current(self.page.as_ref() == "overview")
                    .trigger(|button| {
                        trigger(button, "Overview", self.page.as_ref() == "overview")
                    }),
            )
            .child(
                NavigationMenuEntry::new(&self.navigation, 1)
                    .offset(px(5.))
                    .trigger(|button| trigger(button, "Learn", open_navigation == Some(1)))
                    .content(
                        panel()
                            .child(
                                div()
                                    .px_3()
                                    .py_1()
                                    .font_weight(FontWeight::BOLD)
                                    .child("Build with composition"),
                            )
                            .child(
                                self.link("guide-start", "getting-started", "Getting started")
                                    .button(|button| button.track_focus(&self.guide_focus)),
                            )
                            .child(self.link(
                                "guide-composition",
                                "composition",
                                "Composing controls",
                            )),
                    ),
            )
            .child(
                NavigationMenuEntry::new(&self.navigation, 2)
                    .offset(px(5.))
                    .trigger(|button| trigger(button, "Reference", open_navigation == Some(2)))
                    .content(
                        panel()
                            .child(
                                self.link("reference-api", "api", "Component APIs")
                                    .button(|button| button.track_focus(&self.reference_focus)),
                            )
                            .child(self.link(
                                "reference-keyboard",
                                "keyboard",
                                "Keyboard navigation",
                            )),
                    ),
            )
            .child(
                NavigationMenuEntry::new(&self.navigation, 3)
                    .current(self.page.as_ref() == "community")
                    .trigger(|button| {
                        trigger(button, "Community", self.page.as_ref() == "community")
                    }),
            );

        let description = match self.page.as_ref() {
            "getting-started" => {
                "Create retained state, render a headless control, and supply the application's presentation."
            }
            "composition" => {
                "Menu, Popover and Button behaviors combine into these navigation surfaces. One owner handles each state transition."
            }
            "api" => {
                "Menus report commands; navigation reports destinations. The application decides what each value means."
            }
            "keyboard" => {
                "Use Left and Right between top-level entries. Down opens a disclosure; Escape returns to its trigger."
            }
            "community" => {
                "Use the project's issue tracker to discuss reproducible behavior and focused component improvements."
            }
            _ => {
                "This local page changes when a navigation link is activated. Command menus above control independent document preferences."
            }
        };
        let page_title = match self.page.as_ref() {
            "getting-started" => "Getting started",
            "composition" => "Composing controls",
            "api" => "Component APIs",
            "keyboard" => "Keyboard navigation",
            "community" => "Community",
            _ => "Overview",
        };
        let path_open = self.path_menu.read(cx).is_open(cx);
        let breadcrumb =
            Breadcrumb::new("page-breadcrumb")
                .accessibility_label("Page location")
                .child(
                    self.direction
                        .row(BreadcrumbList::new("page-breadcrumb-list"))
                        .flex_wrap()
                        .items_center()
                        .gap_1()
                        .child(
                            BreadcrumbItem::new("page-crumb-home").child(trigger(
                                Button::new("page-crumb-home-button")
                                    .accessibility_label("Home")
                                    .on_click(cx.listener(|this, _, _, cx| {
                                        this.page = "overview".into();
                                        cx.notify();
                                    })),
                                "Home",
                                false,
                            )),
                        )
                        .child(if self.direction.is_rtl() {
                            "‹"
                        } else {
                            "›"
                        })
                        .child(
                            BreadcrumbItem::new("page-crumb-hidden").child(
                                DropdownMenu::new("page-crumb-more", &self.path_menu)
                                    .accessibility_label("Hidden locations")
                                    .offset(px(4.))
                                    .trigger(|button| {
                                        trigger(
                                            button.accessibility_label("Show hidden locations"),
                                            "…",
                                            path_open,
                                        )
                                    })
                                    .content(panel().children((0..2).map(|index| {
                                        self.menu_option(&self.path_menu, index, cx)
                                    }))),
                            ),
                        )
                        .child(if self.direction.is_rtl() {
                            "‹"
                        } else {
                            "›"
                        })
                        .child(
                            BreadcrumbItem::new("page-crumb-current")
                                .current(true)
                                .px_3()
                                .child(gpui::text!(id = "page-crumb-current-text", page_title)),
                        ),
                );
        let help = self.help.read(cx);
        let section = self.sections.read(cx);
        let selected_section = section.selected_index().unwrap_or(0);
        let section_label = section.items()[selected_section].label().clone();
        let project_sidebar = div().w_full().min_w_0().flex().gap_4()
            .when(window.viewport_size().width < px(640.), |layout| layout.flex_col())
            .child(Sidebar::new("project-sidebar", &self.sections, "Project sections", super::Appearance::Compact.palette())
                .sheet_below(px(640.))
                .collapsible(&self.sidebar)
                .group("Project", ["overview", "activity"])
                .collapsible_group("Project tools", ["members", "exports"], &self.tools)
                .flex_shrink_0())
            .child(div().id("project-section").test_support().role(Role::Region)
                .aria_label(section_label.clone()).flex_1().min_w_0().p_4()
                .rounded_md().bg(rgb(0x172033))
                .child(div().font_weight(FontWeight::BOLD).child(section_label))
                .child(div().text_sm().whitespace_normal().child(match selected_section {
                    2 => "Members of this local project. Closing navigation keeps the current page open.",
                    3 => "Export options for this local project. Navigation selection survives closing a group.",
                    _ => "Use Tab and Enter to choose a page. Collapse Project tools or the full sidebar without losing the current page.",
                })));
        let help_sections = Accordion::new("navigation-help", &self.help)
            .w_full()
            .flex()
            .flex_col()
            .gap_2()
            .children(help.items().iter().enumerate().map(|(index, item)| {
                div()
                    .flex()
                    .flex_col()
                    .rounded_md()
                    .border_1()
                    .border_color(rgb(0x334155))
                    .child(
                        AccordionHeader::new(&self.help, index)
                            .w_full()
                            .px_3()
                            .py_2()
                            .flex()
                            .items_center()
                            .justify_between()
                            .bg(rgb(0x172033))
                            .focus_visible(|style| {
                                style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220))
                            })
                            .child(item.label().clone())
                            .child(if help.is_open(index) { "−" } else { "+" }),
                    )
                    .child(
                        AccordionPanel::new(&self.help, index)
                            .tab_stop(true)
                            .px_3()
                            .py_2()
                            .text_sm()
                            .text_color(rgb(0x94a3b8))
                            .focus_visible(|style| {
                                style.bg(rgb(0x334155)).text_color(rgb(0xe2e8f0))
                            })
                            .child(if index == 0 {
                                "Choose Center or End to align the page preview. Only one option stays pressed; press it again to return to Start. Arrow keys move focus without changing the alignment."
                            } else {
                                "File contains document actions and an Export submenu. View changes the grid, selected layers and theme. Escape closes one menu level and returns focus to its trigger."
                            }),
                    )
            }));
        DirectionProvider::new(self.direction).w_full().child(
            div().w_full().flex().flex_col().gap_4().p_4().rounded_lg()
                .border_1().border_color(rgb(0x334155)).bg(rgb(0x0f172a))
                .child(div().flex().justify_between().items_center().gap_3()
                    .child(div().text_lg().font_weight(FontWeight::BOLD).child("Commands and navigation"))
                    .child(Button::new("navigation-direction").px_3().py_2().rounded_md().bg(rgb(0x334155))
                        .accessibility_label(direction_label)
                        .focus_visible(|style| style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220)))
                        .child(direction_label)
                        .on_click(cx.listener(|this, _, _, cx| {
                            this.direction = if this.direction.is_rtl() { Direction::Ltr } else { Direction::Rtl }; cx.notify();
                        }))))
                .child(menu)
                .child(div().text_sm().text_color(rgb(0x94a3b8))
                    .child("Open File or View with ↓. Arrow keys switch menus; Export opens a submenu. Escape returns one level."))
                .child(div().text_sm().child(format!("Last command: {} · Grid: {} · Selection: {:?} · Theme: {}",
                    self.last_command, if self.show_grid { "shown" } else { "hidden" }, self.selection, self.theme)))
                .child(div().h(px(1.)).bg(rgb(0x334155)))
                .child(navigation)
                .child(breadcrumb)
                .child(Popover::new("navigation-keyboard-reference", &self.quick_help)
                    .accessibility_label("Navigation keyboard reference")
                    .side(Placement::Right)
                    .align(Align::Start)
                    .offset(px(8.))
                    .trigger(|button| {
                        trigger(button.accessibility_label("Keyboard reference"), "Keyboard reference", self.quick_help.read(cx).is_open())
                    })
                    .content(panel().w(px(280.)).p_3().gap_3()
                        .child(div().id("navigation-keyboard-heading").role(Role::Heading).aria_level(3)
                            .aria_label("Navigate with the keyboard")
                            .font_weight(FontWeight::BOLD).child("Navigate with the keyboard"))
                        .child(div().text_sm().child("Tab reaches each control. Arrow keys move between menu entries; Down opens a menu. Enter or Space activates the focused item, and Escape closes the current surface."))
                        .child(Button::new("close-navigation-keyboard-reference")
                            .accessibility_label("Got it")
                            .track_focus(&self.quick_help_close).px_3().py_2().rounded_md()
                            .bg(rgb(0x334155))
                            .focus_visible(|style| style.bg(rgb(0x93c5fd)).text_color(rgb(0x0b1220)))
                            .child("Got it")
                            .on_click(cx.listener(|this, _, window, cx| {
                                this.quick_help.update(cx, |state, cx| state.close(window, cx));
                            })))))
                .child(div().text_sm().text_color(rgb(0x94a3b8))
                    .child("Reading alignment: choose Center or End. Press the selected option again to return to Start."))
                .child(alignment_controls)
                .child(div().p_4().rounded_md().bg(rgb(0x172033)).flex().flex_col().gap_2()
                    .when(alignment.is_pressed(0), |this| this.text_center())
                    .when(alignment.is_pressed(1), |this| {
                        if self.direction.is_rtl() { this.text_left() } else { this.text_right() }
                    })
                    .child(div().font_weight(FontWeight::BOLD).child(format!("Page: {}", self.page)))
                    .child(description))
                .child(div().text_sm().text_color(rgb(0x94a3b8))
                    .child("Navigation help · Both answers can stay open."))
                .child(help_sections)
                .child(div().text_lg().font_weight(FontWeight::BOLD).child("Project sidebar"))
                .child(project_sidebar),
        )
    }
}