u0ui 0.3.12

Carbon UI: IBM Carbon v11 visuals with a shadcn-style API for GPUI Kit
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
//! Sidebar: application side navigation → Carbon UI shell `SideNav` /
//! `SideNavItems` / `SideNavLink` / `SideNavMenu` / `SideNavMenuItem` /
//! `SideNavDivider` (`.cds--side-nav`), plus `SidebarProvider` /
//! `SidebarTrigger` / `SidebarInset` (`.cu-sb-*`). Always laid out inline (the
//! reference's default `inline`).
//!
//! - **Behavior**: links and menu headings are Base `Button`s (focus,
//!   Enter/Space, pointer); a `SideNavMenu` toggles its links (open by
//!   `expanded`). [`SidebarProvider`] owns the open state (controlled or not)
//!   and puts a [`SidebarTrigger`] (a ghost `md` icon button) at the top of
//!   the inset.
//! - **Appearance**: 16rem on `background` with no edge line, items from 1rem down; links 2rem tall, `text-secondary` 14/20 with
//!   a 16px `icon-secondary` icon 1.5rem before the text, hover
//!   `background-hover` + `text-primary`, the current link
//!   `background-selected` + 600 + a 3px `border-interactive` bar; menu
//!   headings heading-compact-01 with a 16px chevron, their links indented
//!   2rem (4.5rem under an icon), an active closed menu marked like a current
//!   link; dividers 1px `border-subtle` with `0.5rem 1rem` margins; the
//!   optional header (600, 1rem padding, bottom line) and footer (top line).
//!   Focus: a 2px inset `focus` outline.
//! - **`expanded(false)`**: the reference always renders Carbon's `SideNav`
//!   with `isFixedNav` (and never `isRail`), so `expanded={false}` gets
//!   `.cds--side-nav--collapsed { inline-size: 16rem; transform:
//!   translateX(-16rem) }`: the nav keeps its 16rem slot in the row (a
//!   transform does not change layout) and is moved out of it, leaving the
//!   slot empty. There is no icon rail.
//! - **Hidden by the trigger**: `.cu-sb--closed .cds--side-nav { display:
//!   none }`, so the nav and its slot disappear and reappear at once.
//! - **Motion**: colors 110ms; the menu chevron turns 180° in 110ms; a menu's
//!   links show and hide at once (`.cds--side-nav__menu` has no height
//!   transition); toggling `expanded` slides the nav out of / into its slot
//!   over 110ms `cubic-bezier(0.2, 0, 1, 0.9)` (`.cds--side-nav { transition:
//!   …, transform 0.11s }`; reduced motion: a cut).
use super::button::{Button, ButtonSize, ButtonVariant};
use super::overlay::{self, Callback, OpenChange, rem};
use crate::{
    icons::{CarbonIcon, Icon, IconSize},
    motion::{self, Curve, Motion, Speed},
    theme::color,
    tokens::{ColorRole, TypeStyle},
    typography::TypeStyled as _,
};
use gpui_kit::{
    AnyElement, App, CursorStyle, ElementId, FontWeight, Hsla, InteractiveElement, IntoElement,
    ParentElement, RenderOnce, SharedString, StatefulInteractiveElement as _, Styled, Window, div,
    prelude::FluentBuilder as _, px,
};
use std::rc::Rc;

/// `transition: color 110ms, background-color 110ms` (CSS `ease` ≈ productive standard).
pub const ITEM_MOTION: Motion = Motion::new(Curve::ProductiveStandard, Speed::Fast02);
/// `.cds--side-nav { transition: transform 0.11s cubic-bezier(0.2, 0, 1, 0.9) }`.
pub const SLIDE_MOTION: Motion = Motion::new(Curve::ProductiveExit, Speed::Fast02).spatial(true);
/// `.cds--side-nav--expanded, .cds--side-nav--collapsed { inline-size: 16rem }`.
pub const WIDTH: f32 = 256.;
/// `.cds--side-nav--collapsed { transform: translateX(-16rem) }`.
pub const COLLAPSED_OFFSET: f32 = WIDTH;

/// One side navigation entry (`index.d.ts` `NavItem`).
#[derive(Clone)]
pub struct SideNavItem {
    label: SharedString,
    icon: Option<Icon>,
    active: bool,
    expanded: bool,
    divider: bool,
    items: Vec<SideNavItem>,
    on_click: Option<Callback>,
}

impl SideNavItem {
    /// A link (`SideNavLink`, or `SideNavMenuItem` inside a menu).
    pub fn link(label: impl Into<SharedString>) -> Self {
        Self {
            label: label.into(),
            icon: None,
            active: false,
            expanded: false,
            divider: false,
            items: Vec::new(),
            on_click: None,
        }
    }

    /// A menu (`SideNavMenu`) of links.
    pub fn menu(
        label: impl Into<SharedString>,
        items: impl IntoIterator<Item = SideNavItem>,
    ) -> Self {
        Self {
            items: items.into_iter().collect(),
            ..Self::link(label)
        }
    }

    /// A divider (`SideNavDivider`).
    pub fn divider() -> Self {
        Self {
            divider: true,
            ..Self::link("")
        }
    }

    /// Leading icon (`renderIcon`).
    pub fn icon(mut self, icon: impl Into<Icon>) -> Self {
        self.icon = Some(icon.into());
        self
    }

    /// The current page (`isActive`).
    pub fn active(mut self, active: bool) -> Self {
        self.active = active;
        self
    }

    /// A menu that starts open (`defaultExpanded`).
    pub fn expanded(mut self, expanded: bool) -> Self {
        self.expanded = expanded;
        self
    }

    /// Navigate when activated (`href`).
    pub fn on_click(mut self, f: impl Fn(&mut Window, &mut App) + 'static) -> Self {
        self.on_click = Some(Rc::new(f));
        self
    }
}

/// `(background, text, icon)` of a link or menu heading.
pub fn item_colors(current: bool, hovered: bool) -> (Hsla, Hsla, Hsla) {
    use ColorRole::*;
    if current {
        // `.cds--side-nav__link--current { background-color: var(--background-selected) }`.
        let bg = if hovered {
            BackgroundSelectedHover
        } else {
            BackgroundSelected
        };
        (color(bg), color(TextPrimary), color(IconPrimary))
    } else if hovered {
        (
            color(BackgroundHover),
            color(TextPrimary),
            color(IconPrimary),
        )
    } else {
        (
            Hsla::transparent_black(),
            color(TextSecondary),
            color(IconSecondary),
        )
    }
}

/// The nav panel's fill. `.cds--side-nav__navigation` is `background` with
/// no border on any edge (no `.cds--side-nav*` rule sets one), so the panel
/// meets the page without a line.
pub fn nav_background() -> Hsla {
    color(ColorRole::Background)
}

/// A Carbon side navigation. See the module docs.
#[derive(IntoElement)]
pub struct Sidebar {
    id: ElementId,
    items: Vec<SideNavItem>,
    label: SharedString,
    expanded: bool,
    header: Option<AnyElement>,
    footer: Option<AnyElement>,
    visible: bool,
}

impl Sidebar {
    /// A side nav with a stable `id`.
    pub fn new(id: impl Into<ElementId>) -> Self {
        Self {
            id: id.into(),
            items: Vec::new(),
            label: SharedString::default(),
            expanded: true,
            header: None,
            footer: None,
            visible: true,
        }
    }

    /// Append an entry.
    pub fn item(mut self, item: SideNavItem) -> Self {
        self.items.push(item);
        self
    }

    /// Append entries.
    pub fn items(mut self, items: impl IntoIterator<Item = SideNavItem>) -> Self {
        self.items.extend(items);
        self
    }

    /// The accessible name (`label`).
    pub fn label(mut self, label: impl Into<SharedString>) -> Self {
        self.label = label.into();
        self
    }

    /// Shown (default) or collapsed: moved out of its 16rem slot
    /// (`.cds--side-nav--collapsed`; see the module docs).
    pub fn expanded(mut self, expanded: bool) -> Self {
        self.expanded = expanded;
        self
    }

    /// Content above the items (`.cu-sidenav-header`).
    pub fn header(mut self, header: impl IntoElement) -> Self {
        self.header = Some(header.into_any_element());
        self
    }

    /// Content below the items (`.cu-sidenav-footer`).
    pub fn footer(mut self, footer: impl IntoElement) -> Self {
        self.footer = Some(footer.into_any_element());
        self
    }

    fn visible(mut self, visible: bool) -> Self {
        self.visible = visible;
        self
    }
}

#[allow(clippy::too_many_arguments)]
fn row(
    id: ElementId,
    label: SharedString,
    icon: Option<Icon>,
    current: bool,
    heading: bool,
    indent: f32,
    trailing: Option<AnyElement>,
    on_click: Callback,
    window: &mut Window,
    cx: &mut App,
) -> AnyElement {
    let hover = window.use_keyed_state((id.clone(), "hover"), cx, |_, _| false);
    let focus = window
        .use_keyed_state((id.clone(), "focus"), cx, |_, cx| cx.focus_handle())
        .read(cx)
        .clone();
    let focused = focus.is_focused(window);
    let (bg, text, icon_color) = item_colors(current, *hover.read(cx));
    let bg = motion::animate_color((id.clone(), "bg"), bg, ITEM_MOTION, window, cx);
    let text = motion::animate_color((id.clone(), "text"), text, ITEM_MOTION, window, cx);
    gpui_kit::base::Button::new(id)
        .track_focus(&focus)
        .accessibility_label(label.clone())
        .relative()
        .w_full()
        .h(rem(32.))
        .flex_shrink_0()
        .flex()
        .flex_row()
        .items_center()
        .justify_start()
        .pl(rem(16. + indent))
        .pr(rem(16.))
        .bg(bg)
        .text_color(text)
        .map(|this| {
            // `.cds--side-nav__link` is heading-compact-01 (600); only links in a
            // menu drop to 400 (`.cds--side-nav__menu .cds--side-nav__link`).
            if heading || current || indent == 0. {
                this.type_style(TypeStyle::HeadingCompact01)
            } else {
                this.type_style(TypeStyle::BodyCompact01)
                    .font_weight(FontWeight::NORMAL)
            }
        })
        .cursor(CursorStyle::PointingHand)
        .on_hover(move |h, _, cx| {
            hover.update(cx, |v, cx| {
                *v = *h;
                cx.notify();
            })
        })
        .on_click(move |_, window, cx| on_click(window, cx))
        .when_some(icon, |this, icon| {
            // `.cds--side-nav__icon { flex: 0 0 1rem; margin-inline-end: 1.5rem }`.
            this.child(
                div()
                    .flex_shrink_0()
                    .mr(rem(24.))
                    .child(icon.size(IconSize::S16).color(icon_color)),
            )
        })
        .child(
            div()
                .flex_1()
                .min_w_0()
                .overflow_hidden()
                .whitespace_nowrap()
                .text_ellipsis()
                .child(label),
        )
        .children(trailing)
        .when(current, |this| {
            // `::before { inline-size: 3px; background-color: var(--border-interactive) }`.
            this.child(
                div()
                    .absolute()
                    .top_0()
                    .bottom_0()
                    .left_0()
                    .w(px(3.))
                    .bg(color(ColorRole::BorderInteractive)),
            )
        })
        .when(focused, |this| {
            this.child(
                div()
                    .absolute()
                    .top_0()
                    .left_0()
                    .size_full()
                    .border_2()
                    .border_color(color(ColorRole::Focus)),
            )
        })
        .into_any_element()
}

impl RenderOnce for Sidebar {
    fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
        let id = self.id.clone();
        let target = if self.expanded { 0. } else { COLLAPSED_OFFSET };
        // Sampled even while hidden so a reveal never replays a stale slide.
        let offset = motion::animate((id.clone(), "slide"), target, SLIDE_MOTION, window, cx);
        // `.cds--side-nav` sits in a 16rem flex slot (`.cu-inline-sidenav { position:
        // relative }`); `.cu-sb--closed .cds--side-nav { display: none }` drops it.
        let slot = div()
            .id(id.clone())
            .flex_shrink_0()
            .h_full()
            .min_h(rem(320.));
        if !self.visible {
            return slot.into_any_element();
        }
        let slot = slot.relative().w(rem(WIDTH)).overflow_hidden();
        if offset >= COLLAPSED_OFFSET {
            // Fully out of the slot: nothing visible, nothing to focus.
            return slot.into_any_element();
        }
        let mut list = div()
            .id((id.clone(), "items"))
            .flex_1()
            .min_h_0()
            .overflow_y_scroll()
            .pt(rem(16.))
            .flex()
            .flex_col();
        for (index, item) in self.items.into_iter().enumerate() {
            let item_id = ElementId::NamedChild(
                std::sync::Arc::new(id.clone()),
                SharedString::from(format!("item-{index}")),
            );
            if item.divider {
                list = list.child(
                    div()
                        .flex_shrink_0()
                        .my(rem(8.))
                        .mx(rem(16.))
                        .h(px(1.))
                        .bg(color(ColorRole::BorderSubtle01)),
                );
                continue;
            }
            if item.items.is_empty() {
                let on_click = item.on_click.clone();
                list = list.child(row(
                    item_id,
                    item.label,
                    item.icon,
                    item.active,
                    false,
                    0.,
                    None,
                    Rc::new(move |window, cx| {
                        if let Some(f) = &on_click {
                            f(window, cx)
                        }
                    }),
                    window,
                    cx,
                ));
                continue;
            }
            let default = item.expanded;
            let openness = overlay::openness(&item_id, None, default, None, window, cx);
            let open = openness.open;
            let set_open = openness.setter();
            let rotation = motion::chevron_rotation((item_id.clone(), "chevron"), open, window, cx);
            let child_active = item.items.iter().any(|i| i.active);
            let has_icon = item.icon.is_some();
            let chevron = Some(
                div()
                    .flex_1()
                    .flex()
                    .justify_end()
                    .child(
                        Icon::carbon(CarbonIcon::ChevronDown)
                            .size(IconSize::S16)
                            .color(color(ColorRole::IconSecondary))
                            .rotate(gpui_kit::radians(rotation)),
                    )
                    .into_any_element(),
            );
            list = list.child(row(
                (item_id.clone(), "heading").into(),
                item.label.clone(),
                item.icon.clone(),
                // `--active .cds--side-nav__submenu[aria-expanded=false]`: marked while closed.
                (item.active || child_active) && !open,
                true,
                0.,
                chevron,
                Rc::new(move |window, cx| set_open(!open, window, cx)),
                window,
                cx,
            ));
            if open {
                let mut links = div().flex().flex_col();
                for (i, link) in item.items.into_iter().enumerate() {
                    let on_click = link.on_click.clone();
                    links = links.child(row(
                        ElementId::NamedChild(
                            std::sync::Arc::new(item_id.clone()),
                            SharedString::from(format!("link-{i}")),
                        ),
                        link.label,
                        None,
                        link.active,
                        false,
                        // `.cds--side-nav__menu .cds--side-nav__link { padding-inline-start: 2rem }`,
                        // 4.5rem under an icon.
                        if has_icon { 56. } else { 16. },
                        None,
                        Rc::new(move |window, cx| {
                            if let Some(f) = &on_click {
                                f(window, cx)
                            }
                        }),
                        window,
                        cx,
                    ));
                }
                list = list.child(links);
            }
        }

        slot.child(
            div()
                .absolute()
                .top_0()
                .left(rem(-offset))
                .w(rem(WIDTH))
                .h_full()
                .bg(nav_background())
                .child(
                    div()
                        .size_full()
                        .flex()
                        .flex_col()
                        .when_some(self.header, |this, header| {
                            // `.cu-sidenav-header { padding: spacing-05; font-weight: 600; border-bottom }`.
                            this.child(
                                div()
                                    .flex_shrink_0()
                                    .p(rem(16.))
                                    .type_style(TypeStyle::HeadingCompact01)
                                    .text_color(color(ColorRole::TextPrimary))
                                    .border_b_1()
                                    .border_color(color(ColorRole::BorderSubtle01))
                                    .child(header),
                            )
                        })
                        .child(list)
                        .when_some(self.footer, |this, footer| {
                            this.child(
                                div()
                                    .flex_shrink_0()
                                    .p(rem(16.))
                                    .border_t_1()
                                    .border_color(color(ColorRole::BorderSubtle01))
                                    .child(footer),
                            )
                        }),
                ),
        )
        .into_any_element()
    }
}

/// `SidebarProvider` + `SidebarInset`: the side nav beside the page content,
/// with a [`SidebarTrigger`] at the top of the content. See the module docs.
#[derive(IntoElement)]
pub struct SidebarProvider {
    id: ElementId,
    sidebar: Option<Sidebar>,
    open: Option<bool>,
    default_open: bool,
    on_open_change: Option<OpenChange>,
    children: Vec<AnyElement>,
    open_label: SharedString,
    close_label: SharedString,
    show_trigger: bool,
}

impl SidebarProvider {
    /// A provider with a stable `id`.
    pub fn new(id: impl Into<ElementId>) -> Self {
        Self {
            id: id.into(),
            sidebar: None,
            open: None,
            default_open: true,
            on_open_change: None,
            children: Vec::new(),
            // The reference trigger's labels; override per locale.
            open_label: "Open menu".into(),
            close_label: "Close menu".into(),
            show_trigger: true,
        }
    }

    /// The side nav.
    pub fn sidebar(mut self, sidebar: Sidebar) -> Self {
        self.sidebar = Some(sidebar);
        self
    }

    /// Controlled open state.
    pub fn open(mut self, open: bool) -> Self {
        self.open = Some(open);
        self
    }

    /// Initial open state when uncontrolled (default true).
    pub fn default_open(mut self, open: bool) -> Self {
        self.default_open = open;
        self
    }

    /// Called when the trigger toggles the side nav.
    pub fn on_open_change(mut self, f: impl Fn(bool, &mut Window, &mut App) + 'static) -> Self {
        self.on_open_change = Some(Rc::new(f));
        self
    }

    /// Put the [`SidebarTrigger`] at the top of the content (default true).
    /// Off, the inset holds only the children, as a bare `SidebarInset`
    /// does in the reference (`PatternGlobalHeader`).
    pub fn show_trigger(mut self, show: bool) -> Self {
        self.show_trigger = show;
        self
    }

    /// The trigger's accessible names when closed / open.
    pub fn trigger_labels(
        mut self,
        open: impl Into<SharedString>,
        close: impl Into<SharedString>,
    ) -> Self {
        self.open_label = open.into();
        self.close_label = close.into();
        self
    }
}

impl ParentElement for SidebarProvider {
    fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
        self.children.extend(elements);
    }
}

/// `SidebarTrigger`: a ghost `md` icon button with the Menu icon.
pub struct SidebarTrigger;

impl SidebarTrigger {
    /// The trigger button; `label` is its accessible name and tooltip.
    pub fn button(id: impl Into<ElementId>, label: impl Into<SharedString>) -> Button {
        Button::new(id, label)
            .variant(ButtonVariant::Ghost)
            .size(ButtonSize::Md)
            .icon(CarbonIcon::Menu)
            .icon_only(true)
    }
}

impl RenderOnce for SidebarProvider {
    fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
        let id = self.id.clone();
        let openness = overlay::openness(
            &id,
            self.open,
            self.default_open,
            self.on_open_change.clone(),
            window,
            cx,
        );
        let open = openness.open;
        let set_open = openness.setter();
        let trigger = SidebarTrigger::button(
            (id.clone(), "trigger"),
            if open {
                self.close_label.clone()
            } else {
                self.open_label.clone()
            },
        )
        .on_click(move |_, window, cx| set_open(!open, window, cx));
        div()
            .flex()
            .flex_row()
            .size_full()
            .children(self.sidebar.map(|s| s.visible(open)))
            .child(
                // `.cu-sb-inset { flex: 1; min-width: 0; padding: spacing-05 }`.
                div()
                    .flex_1()
                    .min_w_0()
                    .p(rem(16.))
                    .flex()
                    .flex_col()
                    .items_start()
                    .when(self.show_trigger, |this| this.child(trigger))
                    .children(self.children),
            )
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::tokens::CarbonTheme;

    fn hex(c: Hsla) -> String {
        let c = c.to_rgb();
        let b = |v: f32| (v * 255.).round() as u8;
        format!("#{:02x}{:02x}{:02x}", b(c.r), b(c.g), b(c.b))
    }

    #[test]
    fn colors_follow_side_nav_css() {
        crate::theme::tests_set(CarbonTheme::White);
        let (bg, text, icon) = item_colors(false, false);
        assert_eq!(
            (bg.a, hex(text), hex(icon)),
            (0., "#525252".into(), "#525252".into())
        );
        let (_, text, _) = item_colors(false, true);
        assert_eq!(hex(text), "#161616");
        let (bg, text, _) = item_colors(true, false);
        assert_eq!(bg, color(ColorRole::BackgroundSelected));
        assert_eq!(hex(text), "#161616");
    }

    #[test]
    fn nav_panel_is_background_without_border() {
        crate::theme::tests_set(CarbonTheme::White);
        assert_eq!(hex(nav_background()), "#ffffff");
        // The panel itself draws no edge; the only lines are header/footer rules.
        let src = include_str!("sidebar.rs");
        let panel = src.split("slot.child(").nth(1).unwrap();
        let panel = panel.split(".when_some(self.header").next().unwrap();
        assert!(!panel.contains("border_r"));
    }

    #[test]
    fn widths_and_motion() {
        assert_eq!((WIDTH, COLLAPSED_OFFSET), (256., 256.));
        assert_eq!(SLIDE_MOTION.speed.millis(), 110);
        assert_eq!(SLIDE_MOTION.curve.points(), (0.2, 0., 1., 0.9));
    }
}