GPUI Box GitHub

Scenes

cascader

Builds Cascader

cascader in the dark theme
studio-dark
cascader in the light theme
studio-light

The code that drew it

A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.

fn cascader(window: &mut Window, cx: &mut App) -> AnyElement {
    if !cx.has_global::<SceneCascader>() {
        let cascader = cx.new(|cx| {
            Cascader::new("scene.cascader", window, cx)
                .name("Fixture destination")
                .selected("release-notes")
                .options([
                    CascaderOption::new("guides", "Guides").children([
                        CascaderOption::new("getting-started", "Getting started"),
                        CascaderOption::new("configuration", "Configuration"),
                    ]),
                    CascaderOption::new("reference", "Reference").loading_children(),
                    CascaderOption::new("archive", "Archive").unavailable_children(
                        "The fixture host does not provide archived sections.",
                    ),
                    CascaderOption::new("release-notes", "Release notes"),
                    CascaderOption::new("managed", "Managed section").disabled(true),
                ])
        });
        cascader.update(cx, |cascader, cx| cascader.open(window, cx));
        cx.set_global(SceneCascader { cascader });
    }
    let theme = cx.theme().clone();
    let cascader = cx.global::<SceneCascader>().cascader.clone();
    stack(&theme)
        .w(px(680.0))
        .child(caption(
            &theme,
            "caller-owned hierarchy and value; the open path belongs only to the view",
        ))
        .child(cascader)
        .into_any_element()
}