arc-ui 0.4.0

Physics-first native Rust desktop UI component library & charts for GPUI (120+ interactive components ported from Arc).
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
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
//! Ported from Arc (MIT) © 2026 Elia Kuratli
//! Reference: registry/blocks/page-header/page-header.tsx.
//! 页面头部保留滚动收紧、四页签、问题完成和归档等桌面交互;真实媒体资源由调用方提供。
use super::{child_id, text};
use crate::{
    Avatar, AvatarGroup, AvatarGroupMember, AvatarSize, Badge, BadgeTone, Button, ButtonSize,
    ButtonVariant, DropdownItem, DropdownMenu, Progress,
};
use arc_motion::{
    ArcPresence, ArcPresenceConfig, LayoutSnapshot, arc_spring, arc_spring_with_options,
    layout::layout_scope_key, motion_now, sample_shared_layout, spring::SpringOptions,
};
use arc_tokens::{ActiveArcTheme as _, BlockTokens, Radii, Spacing, Typography};
use gpui_kit::base::{ElementExt as _, StyledExt as _};
use gpui_kit::{
    App, BorderStyle, Bounds, Edges, ElementId, InteractiveElement as _, IntoElement,
    ParentElement, Pixels, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled,
    TestSupportExt as _, Window, assets::IconName, bounds, canvas, div, point, prelude::*, px,
    quad, svg,
};
use std::{cell::RefCell, rc::Rc, time::Duration};

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum PageSection {
    #[default]
    Overview,
    Issues,
    Updates,
    Files,
}
impl PageSection {
    fn order(self) -> usize {
        match self {
            Self::Overview => 0,
            Self::Issues => 1,
            Self::Updates => 2,
            Self::Files => 3,
        }
    }
    fn label(self) -> &'static str {
        match self {
            Self::Overview => "Overview",
            Self::Issues => "Issues",
            Self::Updates => "Updates",
            Self::Files => "Files",
        }
    }
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MilestoneState {
    Done,
    #[default]
    Active,
    Planned,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PagePerson {
    pub name: SharedString,
    pub photo: Option<SharedString>,
}
impl PagePerson {
    pub fn new(name: impl Into<SharedString>) -> Self {
        Self {
            name: name.into(),
            photo: None,
        }
    }
    pub fn photo(mut self, photo: impl Into<SharedString>) -> Self {
        self.photo = Some(photo.into());
        self
    }
}
impl From<&str> for PagePerson {
    fn from(name: &str) -> Self {
        Self::new(name)
    }
}
impl From<String> for PagePerson {
    fn from(name: String) -> Self {
        Self::new(name)
    }
}
impl From<SharedString> for PagePerson {
    fn from(name: SharedString) -> Self {
        Self::new(name)
    }
}
#[derive(Clone, Debug)]
pub struct PageIssue {
    pub id: SharedString,
    pub title: SharedString,
    pub done: bool,
    pub label: Option<SharedString>,
    pub owner: Option<PagePerson>,
}
impl PageIssue {
    pub fn new(id: impl Into<SharedString>, title: impl Into<SharedString>) -> Self {
        Self {
            id: id.into(),
            title: title.into(),
            done: false,
            label: None,
            owner: None,
        }
    }
    pub fn label(mut self, label: impl Into<SharedString>) -> Self {
        self.label = Some(label.into());
        self
    }
    pub fn owner(mut self, owner: impl Into<SharedString>) -> Self {
        self.owner = Some(PagePerson::new(owner));
        self
    }
    pub fn owner_with(mut self, owner: PagePerson) -> Self {
        self.owner = Some(owner);
        self
    }
}
#[derive(Clone, Debug)]
pub struct PageMilestone {
    pub id: SharedString,
    pub name: SharedString,
    pub note: SharedString,
    pub state: MilestoneState,
}
impl PageMilestone {
    pub fn new(
        name: impl Into<SharedString>,
        note: impl Into<SharedString>,
        state: MilestoneState,
    ) -> Self {
        let name = name.into();
        Self {
            id: name.clone(),
            name,
            note: note.into(),
            state,
        }
    }
}
#[derive(Clone, Debug)]
pub struct PageActivity {
    pub id: SharedString,
    pub person: PagePerson,
    pub text: SharedString,
    pub time: SharedString,
}
impl PageActivity {
    pub fn new(
        id: impl Into<SharedString>,
        person: impl Into<SharedString>,
        text: impl Into<SharedString>,
        time: impl Into<SharedString>,
    ) -> Self {
        Self {
            id: id.into(),
            person: PagePerson::new(person),
            text: text.into(),
            time: time.into(),
        }
    }
}
#[derive(Clone, Debug)]
pub struct PageUpdate {
    pub id: SharedString,
    pub author: PagePerson,
    pub date: SharedString,
    pub body: SharedString,
    pub status: Option<SharedString>,
    pub tone: BadgeTone,
}
impl PageUpdate {
    pub fn new(
        id: impl Into<SharedString>,
        author: impl Into<PagePerson>,
        date: impl Into<SharedString>,
        body: impl Into<SharedString>,
    ) -> Self {
        Self {
            id: id.into(),
            author: author.into(),
            date: date.into(),
            body: body.into(),
            status: None,
            tone: BadgeTone::Success,
        }
    }
    pub fn status(mut self, status: impl Into<SharedString>, tone: BadgeTone) -> Self {
        self.status = Some(status.into());
        self.tone = tone;
        self
    }
}
#[derive(Clone, Debug)]
pub struct PageFile {
    pub id: SharedString,
    pub name: SharedString,
    pub kind: SharedString,
    pub size: SharedString,
    pub owner: Option<PagePerson>,
    pub date: Option<SharedString>,
}
impl PageFile {
    pub fn new(
        id: impl Into<SharedString>,
        name: impl Into<SharedString>,
        kind: impl Into<SharedString>,
        size: impl Into<SharedString>,
    ) -> Self {
        Self {
            id: id.into(),
            name: name.into(),
            kind: kind.into(),
            size: size.into(),
            owner: None,
            date: None,
        }
    }
    pub fn owner(mut self, owner: impl Into<SharedString>) -> Self {
        self.owner = Some(PagePerson::new(owner));
        self
    }
    pub fn owner_with(mut self, owner: PagePerson) -> Self {
        self.owner = Some(owner);
        self
    }
    pub fn date(mut self, date: impl Into<SharedString>) -> Self {
        self.date = Some(date.into());
        self
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum SharePhase {
    Idle,
    Sending,
    Sent,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum NoticeTone {
    Success,
    Neutral,
}
impl NoticeTone {
    fn glyph(self) -> &'static str {
        match self {
            Self::Success => "✓",
            Self::Neutral => "•",
        }
    }
}
type Notice = Rc<dyn Fn(SharedString, &mut Window, &mut App)>;
#[derive(IntoElement)]
pub struct PageHeader {
    id: ElementId,
    title: SharedString,
    description: SharedString,
    issues: Vec<PageIssue>,
    milestones: Vec<PageMilestone>,
    activity: Vec<PageActivity>,
    members: Vec<PagePerson>,
    updates: Vec<PageUpdate>,
    files: Vec<PageFile>,
    project_url: Option<SharedString>,
    section: PageSection,
    archived: bool,
    on_notice: Option<Notice>,
}

#[derive(Clone)]
struct State {
    section: PageSection,
    archived: bool,
    issues: Vec<PageIssue>,
    scroll: gpui_kit::ScrollHandle,
    condensed: bool,
    notice: SharedString,
    notice_tone: NoticeTone,
    notice_at: f64,
    following: bool,
    sharing: SharePhase,
    serial: u64,
    updates: Vec<PageUpdate>,
    collapsed: bool,
    width: f32,
    direction: f32,
    /// 打开中的问题;完成后先播放退场,再从这里移除。
    closing: Vec<SharedString>,
    done_count: u32,
    sample: Vec<PageIssue>,
    /// 每枚页签的实测边界(canvas prepaint 记录),供指示线按真实 tab 定位。
    tab_bounds: Rc<RefCell<[Option<Bounds<Pixels>>; 4]>>,
}
impl State {
    fn notify(&mut self, message: impl Into<SharedString>, tone: NoticeTone, now: f64) {
        self.notice = message.into();
        self.notice_tone = tone;
        self.notice_at = now;
    }
}
impl PageHeader {
    pub fn new(id: impl Into<ElementId>) -> Self {
        Self {
            id: id.into(),
            title: "Checkout redesign".into(),
            description:
                "Rebuilding mobile checkout around saved payment methods and a single review step."
                    .into(),
            issues: vec![],
            milestones: sample_milestones(),
            activity: sample_activity(),
            members: sample_members(),
            updates: vec![],
            files: vec![],
            project_url: None,
            section: PageSection::Overview,
            archived: false,
            on_notice: None,
        }
    }
    pub fn title(mut self, v: impl Into<SharedString>) -> Self {
        self.title = v.into();
        self
    }
    pub fn description(mut self, v: impl Into<SharedString>) -> Self {
        self.description = v.into();
        self
    }
    pub fn issues(mut self, v: impl IntoIterator<Item = PageIssue>) -> Self {
        self.issues = v.into_iter().collect();
        self
    }
    pub fn milestones(mut self, v: impl IntoIterator<Item = PageMilestone>) -> Self {
        self.milestones = v.into_iter().collect();
        self
    }
    pub fn activity(mut self, v: impl IntoIterator<Item = PageActivity>) -> Self {
        self.activity = v.into_iter().collect();
        self
    }
    pub fn members(mut self, v: impl IntoIterator<Item = PagePerson>) -> Self {
        self.members = v.into_iter().collect();
        self
    }
    pub fn updates(mut self, v: impl IntoIterator<Item = PageUpdate>) -> Self {
        self.updates = v.into_iter().collect();
        self
    }
    pub fn files(mut self, v: impl IntoIterator<Item = PageFile>) -> Self {
        self.files = v.into_iter().collect();
        self
    }
    pub fn project_url(mut self, v: impl Into<SharedString>) -> Self {
        self.project_url = Some(v.into());
        self
    }
    pub fn section(mut self, v: PageSection) -> Self {
        self.section = v;
        self
    }
    pub fn archived(mut self, v: bool) -> Self {
        self.archived = v;
        self
    }
    pub fn on_notice(mut self, f: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self {
        self.on_notice = Some(Rc::new(f));
        self
    }
}

fn sample_members() -> Vec<PagePerson> {
    [
        "Emma Collins",
        "Marcus Johnson",
        "Ava Mitchell",
        "Sofia Ramirez",
        "Jasmine Brooks",
    ]
    .into_iter()
    .map(PagePerson::new)
    .collect()
}
fn sample_milestones() -> Vec<PageMilestone> {
    vec![
        PageMilestone::new(
            "Saved payment methods",
            "Shipped Sep 18",
            MilestoneState::Done,
        ),
        PageMilestone::new(
            "Single review step",
            "In progress, due Oct 1",
            MilestoneState::Active,
        ),
        PageMilestone::new(
            "Staged rollout",
            "Planned for Oct 14",
            MilestoneState::Planned,
        ),
    ]
}
fn sample_activity() -> Vec<PageActivity> {
    vec![
        PageActivity::new("a1", "Ava Mitchell", "moved CHK-131 to review", "1h ago"),
        PageActivity::new(
            "a2",
            "Marcus Johnson",
            "merged the saved cards endpoint",
            "3h ago",
        ),
        PageActivity::new(
            "a3",
            "Emma Collins",
            "shared Checkout flows v3",
            "Yesterday",
        ),
        PageActivity::new(
            "a4",
            "Sofia Ramirez",
            "closed CHK-119, a double charge on retry",
            "Yesterday",
        ),
        PageActivity::new(
            "a5",
            "Jasmine Brooks",
            "set the rollout date to October 14",
            "Sep 17",
        ),
    ]
}
fn avatar(id: ElementId, person: &PagePerson) -> Avatar {
    let a = Avatar::new(id, person.name.clone());
    match &person.photo {
        Some(photo) => a.src(photo.clone()),
        None => a,
    }
}
impl RenderOnce for PageHeader {
    fn render(self, w: &mut Window, cx: &mut App) -> impl IntoElement {
        let colors = cx.arc_theme().colors;
        let motion = cx.arc_theme().motion;
        let now = motion_now(cx);
        let sample = self.issues.clone();
        let opening: Vec<PageIssue> = sample.iter().filter(|i| !i.done).cloned().collect();
        let initial_done = sample.iter().filter(|i| i.done).count() as u32;
        let state = w.use_keyed_state(child_id(&self.id, "state"), cx, |_, _| State {
            section: self.section,
            archived: self.archived,
            issues: opening,
            scroll: gpui_kit::ScrollHandle::new(),
            condensed: false,
            notice: "".into(),
            notice_tone: NoticeTone::Success,
            notice_at: f64::NEG_INFINITY,
            following: false,
            sharing: SharePhase::Idle,
            serial: 0,
            updates: self.updates.clone(),
            collapsed: false,
            width: 0.0,
            direction: 1.0,
            closing: vec![],
            done_count: initial_done,
            sample,
            tab_bounds: Rc::new(RefCell::new([None; 4])),
        });
        let snap = state.read(cx).clone();
        let open = snap.issues.len() as u32;
        let done = snap.done_count;
        let mut root = div()
            .id(self.id.clone())
            .role(Role::Region)
            .aria_label(self.title.clone())
            .relative()
            .w_full()
            .flex()
            .flex_col()
            .h(BlockTokens::PAGE_HEIGHT)
            .overflow_hidden()
            .rounded(Radii::PANEL)
            .border_1()
            .border_color(colors.border)
            .bg(colors.surface)
            .text_color(colors.foreground);
        // GPUI 没有 ResizeObserver;用 prepaint 读取自身宽度,并以滞回阈值折叠次要操作。
        let measure = state.clone();
        root = root.on_prepaint(move |bounds, window, cx| {
            let width = f32::from(bounds.size.width);
            if width <= 0.0 {
                return;
            }
            let mut changed = false;
            measure.update(cx, |s, _| {
                if (s.width - width).abs() > 0.5 {
                    s.width = width;
                    let collapsed = if s.collapsed {
                        width < BlockTokens::ACTIONS_RETURN
                    } else {
                        width < BlockTokens::ACTIONS_COLLAPSE
                    };
                    if collapsed != s.collapsed {
                        s.collapsed = collapsed;
                        changed = true;
                    }
                }
            });
            if changed {
                window.refresh();
            }
        });
        let condensed = arc_spring(
            (self.id.clone(), "header"),
            if snap.condensed { 1.0 } else { 0.0 },
            motion.spring.smooth,
            w,
            cx,
        )
        .clamp(0.0, 1.0);
        let notice = self.on_notice.clone();
        let archived = snap.archived;
        let collapsed = snap.collapsed;
        let following = snap.following;

        // 上游:面包屑与紧凑标题共享同一单元格,收紧时交叉淡换。这里以透明度近似。
        let chevron = || {
            svg()
                .path(IconName::ChevronRight.path())
                .size(px(14.0))
                .text_color(colors.border_strong)
        };
        let lead = if condensed < 0.5 {
            div()
                .flex()
                .min_w(px(0.0))
                .items_center()
                .gap(Spacing::S1)
                .opacity((1.0 - condensed * 2.0).clamp(0.0, 1.0))
                .child(text("Northline", cx).text_color(colors.text_muted))
                .child(chevron())
                .child(text("Projects", cx).text_color(colors.text_muted))
                .child(chevron())
                .child(
                    text(self.title.clone(), cx)
                        .text_color(colors.text_secondary)
                        .truncate(),
                )
        } else {
            div()
                .flex()
                .min_w(px(0.0))
                .items_center()
                .gap(Spacing::S2)
                .opacity(((condensed - 0.5) * 2.0).clamp(0.0, 1.0))
                .child(
                    Button::new(child_id(&self.id, "compact"))
                        .label(self.title.clone())
                        .accessibility_label(format!("{}, back to top", self.title))
                        .size(ButtonSize::Sm)
                        .variant(ButtonVariant::Ghost)
                        .on_click({
                            let st = state.clone();
                            move |_, w, cx| {
                                st.update(cx, |s, _| {
                                    s.scroll.set_offset(gpui_kit::point(px(0.0), px(0.0)));
                                    s.condensed = false;
                                });
                                w.refresh();
                            }
                        }),
                )
                .child(
                    Badge::new(
                        child_id(&self.id, "compact-status"),
                        if archived { "Archived" } else { "On track" },
                    )
                    .tone(if archived {
                        BadgeTone::Neutral
                    } else {
                        BadgeTone::Success
                    }),
                )
        };
        let mut actions = div().flex().flex_wrap().gap(Spacing::S2).items_center();
        if !collapsed {
            let follow_state = state.clone();
            actions = actions.child(
                Button::new(child_id(&self.id, "follow"))
                    .label(if following { "Following" } else { "Follow" })
                    .accessibility_label(if following {
                        "Unfollow project"
                    } else {
                        "Follow project"
                    })
                    .selected(following)
                    .size(ButtonSize::Sm)
                    .variant(ButtonVariant::Secondary)
                    .on_click(move |_, w, cx| toggle_follow(&follow_state, w, cx)),
            );
            let share_state = state.clone();
            let sharing = snap.sharing;
            actions = actions.child(
                Button::new(child_id(&self.id, "share"))
                    .label(match sharing {
                        SharePhase::Sending => "Sharing…",
                        SharePhase::Sent => "Shared",
                        SharePhase::Idle => "Share update",
                    })
                    .loading(sharing == SharePhase::Sending)
                    .disabled(archived || sharing != SharePhase::Idle)
                    .size(ButtonSize::Sm)
                    .variant(ButtonVariant::Secondary)
                    .on_click(move |_, w, cx| share_update(&share_state, w, cx)),
            );
        }
        let add_state = state.clone();
        actions = actions.child(
            Button::new(child_id(&self.id, "add-issue"))
                .label("New issue")
                .disabled(archived)
                .size(ButtonSize::Sm)
                .on_click(move |_, w, cx| create_issue(&add_state, w, cx)),
        );
        let copy_state = state.clone();
        let project_url = self.project_url.clone();
        let mut menu = DropdownMenu::new(child_id(&self.id, "more"), "More actions");
        if collapsed {
            let follow_state = state.clone();
            menu = menu.item(
                DropdownItem::new(if following { "Unfollow" } else { "Follow" })
                    .on_select(move |_, w, cx| toggle_follow(&follow_state, w, cx)),
            );
            let share_state = state.clone();
            menu = menu.item(
                DropdownItem::new(match snap.sharing {
                    SharePhase::Sending => "Sharing…",
                    SharePhase::Sent => "Shared",
                    SharePhase::Idle => "Share update",
                })
                .disabled(archived || snap.sharing != SharePhase::Idle)
                .on_select(move |_, w, cx| share_update(&share_state, w, cx)),
            );
        }
        menu = menu.item(
            DropdownItem::new("Copy project link")
                .separator_before(collapsed)
                .disabled(project_url.is_none())
                .on_select(move |_, w, cx| copy_link(&copy_state, project_url.as_ref(), w, cx)),
        );
        menu = menu.item(
            DropdownItem::new(if archived {
                "Restore project"
            } else {
                "Archive project"
            })
            .separator_before(true)
            .on_select({
                let archive_state = state.clone();
                let notice = notice.clone();
                move |_, w, cx| {
                    toggle_archive(&archive_state, notice.as_ref(), w, cx);
                }
            }),
        );
        actions = actions.child(menu);
        // intro 大标题区:收紧时随弹簧收起高度(上游 height: 0 ↔ auto)。
        let intro = arc_spring(
            (self.id.clone(), "intro"),
            if snap.condensed { 0.0 } else { 1.0 },
            motion.spring.smooth,
            w,
            cx,
        )
        .clamp(0.0, 1.0);
        let member_row = AvatarGroup::new(child_id(&self.id, "members"))
            .members(self.members.iter().map(|p| {
                let member = AvatarGroupMember::new(p.name.clone());
                match &p.photo {
                    Some(photo) => member.src(photo.clone()),
                    None => member,
                }
            }))
            .max(4)
            .size(AvatarSize::Sm)
            .label("Project members");
        root = root.child(
            div()
                .id(child_id(&self.id, "header"))
                .pt(Spacing::S4)
                .px(Spacing::S4)
                .flex_none()
                .child(
                    div()
                        .flex()
                        .gap(Spacing::S4)
                        .justify_between()
                        .items_center()
                        .child(div().flex_1().min_w(px(0.0)).child(lead))
                        .child(actions),
                )
                .child(
                    div()
                        .overflow_hidden()
                        .flex()
                        .flex_col()
                        .gap(Spacing::S2)
                        .max_h(px(220.0 * intro))
                        .pt(Spacing::S4)
                        .when(intro > 0.02, |d| {
                            d.child(
                                div()
                                    .flex()
                                    .flex_wrap()
                                    .items_center()
                                    .gap(Spacing::S2)
                                    .child(
                                        div()
                                            .text_size(Typography::TEXT_2XL)
                                            .font_medium()
                                            .child(self.title.clone()),
                                    )
                                    .child(
                                        Badge::new(
                                            child_id(&self.id, "status"),
                                            if archived { "Archived" } else { "On track" },
                                        )
                                        .tone(
                                            if archived {
                                                BadgeTone::Neutral
                                            } else {
                                                BadgeTone::Success
                                            },
                                        ),
                                    ),
                            )
                            .child(
                                text(self.description.clone(), cx)
                                    .text_color(colors.text_secondary),
                            )
                            .child(
                                div()
                                    .flex()
                                    .flex_wrap()
                                    .items_center()
                                    .gap(Spacing::S4)
                                    .child(member_row)
                                    .child(
                                        text("Led by Emma Collins", cx)
                                            .text_color(colors.text_muted),
                                    )
                                    .child(text("Target Oct 14", cx).text_color(colors.text_muted)),
                            )
                        }),
                ),
        );
        let sections = [
            PageSection::Overview,
            PageSection::Issues,
            PageSection::Updates,
            PageSection::Files,
        ];
        // 自绘页签:文字 + 计数 + 底部 2px accent 指示器。
        // 上游指示器是每个激活 tab 内的绝对定位子元素(left/right 10px),
        // 因此必须按单枚 tab 的真实边界定位与滑行(共享布局 FLIP),
        // 不能按四等分比例铺在整条 tab 行上。
        let tab_bounds = state.read(cx).tab_bounds.clone();
        let selected_order = snap.section.order();
        let indicator_scope = layout_scope_key(&self.id);
        let indicator_morph = motion.spring.morph;
        let indicator = canvas(
            move |_, _, _| {},
            move |list_rect, _, window, cx| {
                let Some(tab_rect) = tab_bounds.borrow()[selected_order] else {
                    window.request_animation_frame();
                    return;
                };
                // 上游 .indicator:距 tab 左右各 10px,2px 高,顶部两角 2px 圆角。
                let target = LayoutSnapshot::new(
                    bounds(
                        point(
                            tab_rect.origin.x - list_rect.origin.x + px(10.0),
                            tab_rect.origin.y - list_rect.origin.y + tab_rect.size.height - px(2.0),
                        ),
                        gpui_kit::size(tab_rect.size.width - px(20.0), px(2.0)),
                    ),
                    gpui_kit::Corners {
                        top_left: px(2.0),
                        top_right: px(2.0),
                        bottom_right: px(0.0),
                        bottom_left: px(0.0),
                    },
                );
                let flip = sample_shared_layout(
                    indicator_scope.clone(),
                    "indicator",
                    target,
                    Some(indicator_morph),
                    window,
                    cx,
                );
                let paint = bounds(
                    point(
                        list_rect.origin.x + flip.bounds.origin.x,
                        list_rect.origin.y + flip.bounds.origin.y,
                    ),
                    flip.bounds.size,
                );
                window.paint_quad(quad(
                    paint,
                    flip.corner_radii,
                    colors.accent,
                    Edges::default(),
                    colors.accent,
                    BorderStyle::Solid,
                ));
            },
        );
        let mut tabs = div()
            .relative()
            .flex()
            .gap(Spacing::S1)
            .mt(Spacing::S3)
            .mx(-Spacing::S4)
            .px(Spacing::S4 - Spacing::S2)
            .border_b_1()
            .border_color(colors.border)
            .child(indicator);
        for section in sections {
            let count = match section {
                PageSection::Issues => Some(snap.issues.len()),
                PageSection::Updates => Some(snap.updates.len()),
                PageSection::Files => Some(self.files.len()),
                PageSection::Overview => None,
            };
            let selected = snap.section == section;
            let st = state.clone();
            let measured = state.read(cx).tab_bounds.clone();
            let measure_index = section.order();
            let measure = canvas(
                move |bounds, _, _| {
                    measured.borrow_mut()[measure_index] = Some(bounds);
                },
                |_, _, _, _| {},
            )
            .absolute()
            .inset_0();
            let mut tab = div()
                .id(child_id(&self.id, format!("tab-{}", section.label())))
                .test_support()
                .role(Role::Tab)
                .aria_selected(selected)
                .aria_label(match count {
                    Some(count) => format!("{} · {count}", section.label()),
                    None => section.label().to_owned(),
                })
                .cursor_pointer()
                .relative()
                .h(px(44.0))
                .px(Spacing::S2)
                .flex()
                .flex_none()
                .items_center()
                .gap(Spacing::S1)
                .text_size(Typography::TEXT_SM)
                .font_medium()
                .whitespace_nowrap()
                .text_color(if selected {
                    colors.foreground
                } else {
                    colors.text_muted
                })
                .hover(move |s| s.text_color(colors.foreground))
                .on_click(move |_, w, cx| {
                    st.update(cx, |s, _| {
                        if section != s.section {
                            s.direction = if section.order() > s.section.order() {
                                1.0
                            } else {
                                -1.0
                            };
                        }
                        s.section = section;
                        s.scroll.set_offset(gpui_kit::point(px(0.0), px(0.0)));
                    });
                    w.refresh();
                })
                .child(measure)
                .child(section.label());
            if let Some(count) = count {
                tab = tab.child(
                    text(count.to_string(), cx)
                        .text_color(if selected {
                            colors.text_secondary
                        } else {
                            colors.text_muted
                        })
                        .text_size(Typography::TEXT_SM),
                );
            }
            tabs = tabs.child(tab);
        }
        root = root.child(tabs);
        let scroll_state = state.clone();
        let mut body = div()
            .id(child_id(&self.id, "body"))
            .test_support()
            .p(Spacing::S6)
            .flex_1()
            .min_h(px(0.0))
            .track_scroll(&snap.scroll)
            .on_scroll(move |_, w, cx| {
                scroll_state.update(cx, |s, _| {
                    let top = -f32::from(s.scroll.offset().y);
                    s.condensed = if s.condensed {
                        top > BlockTokens::EXPAND_AT
                    } else {
                        top > BlockTokens::CONDENSE_AT
                    };
                });
                w.refresh();
            })
            .overflow_y_scroll();
        // 面板沿页签方向滑入;key 绑定 section,切换时从对应方向开始。
        let slide = arc_spring_with_options(
            (
                child_id(&self.id, format!("panel-{}", snap.section.label())),
                "slide",
            ),
            0.0,
            SpringOptions::new(motion.spring.smooth).with_initial_value(snap.direction * 12.0),
            w,
            cx,
        );
        body = body.ml(px(slide.value));
        match snap.section {
            PageSection::Overview => {
                body = body.child(
                    Progress::new(child_id(&self.id, "progress"))
                        .value(done as f32)
                        .max((open + done).max(1) as f32)
                        .label(format!("{done} of {} issues done", open + done))
                        .show_value(true),
                );
                body = body.child(
                    div()
                        .id(child_id(&self.id, "milestones"))
                        .role(Role::List)
                        .aria_label("Milestones")
                        .flex()
                        .flex_col()
                        .gap(Spacing::S1)
                        .child(div().font_medium().child("Milestones"))
                        .children(self.milestones.iter().map(|m| {
                            let (glyph, color) = match m.state {
                                MilestoneState::Done => ("✓", colors.success),
                                MilestoneState::Active => ("◌", colors.accent),
                                MilestoneState::Planned => ("○", colors.text_muted),
                            };
                            div()
                                .id(child_id(&self.id, format!("milestone-{}", m.id)))
                                .test_support()
                                .role(Role::ListItem)
                                .flex()
                                .items_center()
                                .gap(Spacing::S2)
                                .child(div().text_color(color).child(glyph))
                                .child(div().flex_1().child(m.name.clone()))
                                .child(text(m.note.clone(), cx))
                        })),
                );
                body = body.child(
                    div()
                        .id(child_id(&self.id, "activity"))
                        .role(Role::List)
                        .aria_label("Recent activity")
                        .flex()
                        .flex_col()
                        .gap(Spacing::S2)
                        .child(div().font_medium().child("Recent activity"))
                        .children(self.activity.iter().map(|a| {
                            div()
                                .id(child_id(&self.id, format!("activity-{}", a.id)))
                                .test_support()
                                .role(Role::ListItem)
                                .flex()
                                .items_center()
                                .gap(Spacing::S2)
                                .child(avatar(
                                    child_id(&self.id, format!("who-{}", a.id)),
                                    &a.person,
                                ))
                                .child(
                                    div()
                                        .flex_1()
                                        .child(format!("{} {}", a.person.name, a.text)),
                                )
                                .child(text(a.time.clone(), cx))
                        })),
                );
            }
            PageSection::Issues => {
                body = body.role(Role::List).aria_label("Open issues");
                let has_issues = !snap.issues.is_empty();
                let all_closing =
                    !has_issues || snap.issues.iter().all(|i| snap.closing.contains(&i.id));
                for issue in snap.issues {
                    let issue_state = state.clone();
                    let key = issue.id.clone();
                    let issue_id = issue.id.clone();
                    let issue_title = issue.title.clone();
                    let closing = snap.closing.contains(&issue.id);
                    let id = child_id(&self.id, format!("issue-{}", issue.id));
                    // 完成后行高随退场弹簧收起,380ms 后再从列表移除并累加进度。
                    let presence = ArcPresence::new((id.clone(), "row"), !closing)
                        .animate_initial(false)
                        .config(ArcPresenceConfig {
                            enter_duration: motion.duration.standard,
                            exit_duration: Duration::from_millis(380),
                            enter_ease: motion.ease.enter,
                            exit_ease: motion.ease.standard,
                            fade_on_reduced_motion: true,
                        })
                        .sample(w, cx);
                    if !presence.should_render() {
                        continue;
                    }
                    let cb = self.on_notice.clone();
                    let mut row = div()
                        .id(id)
                        .role(Role::ListItem)
                        .opacity(presence.progress)
                        .max_h(BlockTokens::ROW_HEIGHT * presence.progress)
                        .overflow_hidden()
                        .flex()
                        .items_center()
                        .gap(Spacing::S2)
                        .p(Spacing::S2)
                        .child(
                            Button::new(child_id(&self.id, format!("check-{}", issue.id)))
                                .label(if closing { "✓" } else { "○" })
                                .accessibility_label(format!(
                                    "Mark {} {}",
                                    issue.title,
                                    if closing { "open" } else { "done" }
                                ))
                                .disabled(closing)
                                .size(ButtonSize::Sm)
                                .variant(ButtonVariant::Ghost)
                                .on_click(move |_, w, cx| {
                                    let now = motion_now(cx);
                                    let first = issue_state.update(cx, |s, _| {
                                        if s.closing.contains(&key) {
                                            return false;
                                        }
                                        s.closing.push(key.clone());
                                        s.notify(
                                            format!("{key} marked done"),
                                            NoticeTone::Success,
                                            now,
                                        );
                                        true
                                    });
                                    if !first {
                                        return;
                                    }
                                    let weak = issue_state.downgrade();
                                    let removal = issue_id.clone();
                                    w.spawn(cx, async move |cx| {
                                        cx.background_executor()
                                            .timer(Duration::from_millis(380))
                                            .await;
                                        let _ = cx.update(|w, cx| {
                                            let _ = weak.update(cx, |s, _| {
                                                s.issues.retain(|i| i.id != removal);
                                                s.closing.retain(|c| c != &removal);
                                                s.done_count += 1;
                                            });
                                            w.refresh();
                                        });
                                    })
                                    .detach();
                                    if let Some(cb) = &cb {
                                        cb(format!("{} marked done", issue_id).into(), w, cx)
                                    }
                                    w.refresh();
                                }),
                        )
                        .child(
                            div()
                                .text_color(colors.text_muted)
                                .child(issue_title.clone()),
                        )
                        .child(div().flex_1().child(issue_title));
                    if let Some(label) = issue.label.clone() {
                        row = row.child(Badge::new(
                            child_id(&self.id, format!("label-{}", issue.id)),
                            label,
                        ));
                    }
                    if let Some(owner) = issue.owner.as_ref() {
                        row = row.child(avatar(
                            child_id(&self.id, format!("owner-{}", issue.id)),
                            owner,
                        ));
                    }
                    body = body.child(row);
                }
                if all_closing {
                    let st = state.clone();
                    body = body.child(
                        div()
                            .id(child_id(&self.id, "empty-issues"))
                            .test_support()
                            .flex()
                            .flex_col()
                            .items_center()
                            .gap(Spacing::S2)
                            .p(Spacing::S6)
                            .child(div().font_medium().child("No open issues"))
                            .child(text("Everything in this project is done.", cx))
                            .child(
                                Button::new(child_id(&self.id, "restore-issues"))
                                    .label("Restore sample issues")
                                    .size(ButtonSize::Sm)
                                    .variant(ButtonVariant::Secondary)
                                    .on_click(move |_, w, cx| {
                                        let now = motion_now(cx);
                                        st.update(cx, |s, _| {
                                            s.issues = s
                                                .sample
                                                .iter()
                                                .filter(|i| !i.done)
                                                .cloned()
                                                .collect();
                                            s.done_count =
                                                s.sample.iter().filter(|i| i.done).count() as u32;
                                            s.closing.clear();
                                            s.notify(
                                                "Sample issues restored",
                                                NoticeTone::Neutral,
                                                now,
                                            );
                                        });
                                        w.refresh();
                                    }),
                            ),
                    );
                }
            }
            PageSection::Updates => {
                body = body.role(Role::List);
                if snap.updates.is_empty() {
                    body = body.child(text("No project updates yet", cx));
                }
                for update in snap.updates {
                    let mut head = div()
                        .flex()
                        .items_center()
                        .gap(Spacing::S2)
                        .child(div().font_medium().child(update.author.name.clone()))
                        .child(text(update.date.clone(), cx));
                    if let Some(status) = update.status.clone() {
                        head = head.child(
                            Badge::new(child_id(&self.id, format!("status-{}", update.id)), status)
                                .tone(update.tone),
                        );
                    }
                    body = body.child(
                        div()
                            .id(child_id(&self.id, format!("update-{}", update.id)))
                            .test_support()
                            .role(Role::ListItem)
                            .p(Spacing::S3)
                            .flex()
                            .gap(Spacing::S3)
                            .child(avatar(
                                child_id(&self.id, format!("author-{}", update.id)),
                                &update.author,
                            ))
                            .child(
                                div()
                                    .flex_1()
                                    .flex()
                                    .flex_col()
                                    .gap(Spacing::S1)
                                    .child(head)
                                    .child(text(update.body, cx)),
                            ),
                    );
                }
            }
            PageSection::Files => {
                body = body.role(Role::List);
                if self.files.is_empty() {
                    body = body.child(text("No project files", cx));
                }
                for file in self.files {
                    body = body.child(
                        div()
                            .id(child_id(&self.id, format!("file-{}", file.id)))
                            .test_support()
                            .role(Role::ListItem)
                            .p(Spacing::S3)
                            .flex()
                            .items_center()
                            .gap(Spacing::S3)
                            .child(div().text_color(colors.text_secondary).child("▤"))
                            .child(
                                div()
                                    .flex_1()
                                    .flex()
                                    .flex_col()
                                    .child(div().font_medium().child(file.name))
                                    .child(text(format!("{} · {}", file.kind, file.size), cx)),
                            )
                            .when_some(file.owner.as_ref(), |d, owner| {
                                d.child(avatar(
                                    child_id(&self.id, format!("owner-{}", file.id)),
                                    owner,
                                ))
                            })
                            .when_some(file.date, |d, date| d.child(text(date, cx))),
                    );
                }
            }
        }
        let notice_live = (now - snap.notice_at) < 3.2 && !snap.notice.is_empty();
        if notice_live {
            w.request_animation_frame();
        }
        let tone = snap.notice_tone;
        let toast_color = match tone {
            NoticeTone::Success => colors.success,
            NoticeTone::Neutral => colors.text_secondary,
        };
        root.child(body.child(div().min_h(BlockTokens::PAGE_BODY_MIN)))
            .child(
                div()
                    .id(child_id(&self.id, "notice"))
                    .role(Role::Status)
                    .child(snap.notice.clone())
                    .when(notice_live, |d| {
                        d.absolute()
                            .bottom(Spacing::S4)
                            .left(Spacing::S4)
                            .flex()
                            .items_center()
                            .gap(Spacing::S2)
                            .px(Spacing::S4)
                            .py(Spacing::S2)
                            .rounded(Radii::PANEL)
                            .border_1()
                            .border_color(colors.border)
                            .bg(colors.surface_raised)
                            .text_color(colors.foreground)
                            .child(div().text_color(toast_color).child(tone.glyph()))
                            .child(snap.notice.clone())
                    }),
            )
            .child(
                div()
                    .id(child_id(&self.id, "members-sr"))
                    .role(Role::Status)
                    .aria_label(format!("{} project members", self.members.len()))
                    .opacity(0.0)
                    .child(self.members.len().to_string()),
            )
    }
}
fn toggle_follow(state: &gpui_kit::Entity<State>, w: &mut Window, cx: &mut App) {
    let now = motion_now(cx);
    state.update(cx, |s, _| {
        s.following = !s.following;
        let message = if s.following {
            "Following project"
        } else {
            "Stopped following project"
        };
        s.notify(message, NoticeTone::Success, now);
    });
    w.refresh();
}
fn share_update(state: &gpui_kit::Entity<State>, w: &mut Window, cx: &mut App) {
    if state.read(cx).sharing != SharePhase::Idle {
        return;
    }
    let now = motion_now(cx);
    state.update(cx, |s, _| {
        s.sharing = SharePhase::Sending;
        s.notify("Sharing update…", NoticeTone::Neutral, now);
    });
    let weak = state.downgrade();
    w.spawn(cx, async move |cx| {
        cx.background_executor()
            .timer(Duration::from_millis(700))
            .await;
        let _ = cx.update(|w, cx| {
            let now = motion_now(cx);
            let _ = weak.update(cx, |s, _| {
                s.serial += 1;
                let key: SharedString = format!("local-update-{}", s.serial).into();
                s.updates.insert(
                    0,
                    PageUpdate::new(
                        key,
                        "You",
                        "Just now",
                        "Local project update shared with the preview team.",
                    )
                    .status("On track", BadgeTone::Success),
                );
                if s.section != PageSection::Updates {
                    s.direction = if PageSection::Updates.order() > s.section.order() {
                        1.0
                    } else {
                        -1.0
                    };
                }
                s.section = PageSection::Updates;
                s.sharing = SharePhase::Sent;
                s.notify(
                    "Local update shared; no request sent",
                    NoticeTone::Success,
                    now,
                );
            });
            w.refresh();
        });
        cx.background_executor()
            .timer(Duration::from_millis(1800))
            .await;
        let _ = cx.update(|w, cx| {
            let _ = weak.update(cx, |s, _| {
                if s.sharing == SharePhase::Sent {
                    s.sharing = SharePhase::Idle;
                }
            });
            w.refresh();
        });
    })
    .detach();
    w.refresh();
}
fn create_issue(state: &gpui_kit::Entity<State>, w: &mut Window, cx: &mut App) {
    let now = motion_now(cx);
    state.update(cx, |s, _| {
        s.serial += 1;
        let key: SharedString = format!("local-issue-{}", s.serial).into();
        s.issues
            .push(PageIssue::new(key, "Review the next project task"));
        if s.section != PageSection::Issues {
            s.direction = if PageSection::Issues.order() > s.section.order() {
                1.0
            } else {
                -1.0
            };
        }
        s.section = PageSection::Issues;
        s.notify("Local issue created", NoticeTone::Success, now);
    });
    w.refresh();
}
fn copy_link(
    state: &gpui_kit::Entity<State>,
    url: Option<&SharedString>,
    w: &mut Window,
    cx: &mut App,
) {
    let Some(url) = url else { return };
    cx.write_to_clipboard(gpui_kit::ClipboardItem::new_string(url.to_string()));
    let now = motion_now(cx);
    state.update(cx, |s, _| s.notify("Link copied", NoticeTone::Success, now));
    w.refresh();
}
fn toggle_archive(
    state: &gpui_kit::Entity<State>,
    notice: Option<&Notice>,
    w: &mut Window,
    cx: &mut App,
) {
    let now = motion_now(cx);
    let mut archived = false;
    state.update(cx, |s, _| {
        s.archived = !s.archived;
        archived = s.archived;
        let message = if archived {
            "Project archived"
        } else {
            "Project restored"
        };
        s.notify(message, NoticeTone::Neutral, now);
    });
    w.refresh();
    if let Some(cb) = notice {
        cb(
            if archived {
                "Project archived"
            } else {
                "Project restored"
            }
            .into(),
            w,
            cx,
        )
    }
}
#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn sections_are_distinct() {
        assert_ne!(PageSection::Issues, PageSection::Files);
        assert!(PageSection::Files.order() > PageSection::Overview.order());
    }
}