Skip to content

About

An egui-shelled component catalog for Rust with Storybook-style scene discovery — browse UI components in isolation, one state at a time.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

126 Commits

Folders and files

Repository files navigation

gallery

An egui-shelled component catalog for Rust with Storybook-style scene discovery — browse your UI components in isolation, one state at a time. Scenes live next to the components they exercise and are discovered from a config; the shell finds them, with no central list.

Status: pre-release, not on crates.io. Until 1.0 a minor release may carry a breaking change; the changelog names each. See Status & roadmap.

How it looks to a consumer

An instance is one flat crate plus a config — nothing else. Scaffold one into a sub-directory of your choosing with

cargo generate --git kubijo/rs-gallery template --name my-gallery --no-workspace

--name picks the directory; --no-workspace stops cargo-generate splicing the instance into an enclosing workspace, so it is safe to run inside one — the instance carries its own [workspace]. It prompts for the gallery git URL, scene glob and title, or copy template/, rename Cargo.toml.liquid to Cargo.toml, and fill the {{ … }} markers by hand. It ships a runnable example.scene.rs and a standalone justfile, so the first just run already shows something.

The scaffolded dependency tracks the default branch. Add tag = "v0.1.0" beside the git key — in both gallery and gallery-build — to hold a release instead; just update then reports what has landed since it.

just run opens the window; just hot rebuilds and hot-swaps scenes as you edit them. (Both wrap cargo run, so plain cargo run / cargo run -- --hot work too.) Without a window at all, just render and just capture write scenes to PNGs — see Rendering scenes to images. cargo run -- --help explains every flag, and the scaffolded gallery.toml lists every setting with its default.

The instance package must not be named gallery — its scenes dylib would clash with the framework crate at link time (the binary and directory still can). The scaffold names it app-gallery; that field is a plain literal rather than a placeholder, so rename it by hand.

A scene is a function next to the component it shows:

// src/button.scene.rs
use gallery::prelude::*;

scene_meta! { title: "Components / Button" }

#[scene("enabled")]
fn enabled(ctx: &mut SceneCtx, ui: &mut Ui) {
    stage!(ctx, ui, |ui| {
        ui.button("Save");
    });
}

Documentation

Writing scenes:

Driving and checking them:

  • Driving a scene with plays: scripted gestures and checks, in a capture or live in the window.
  • Snapshots: a play's screenshots and accessibility trees compared against references.
  • Testing a catalog: every scene and play as a test, with an HTML report and videos.

Using the tool:

  • The window: its panels, toggles and shortcuts, the performance window, hot reload.
  • Rendering scenes to images: PNGs with no window, capture recipes, knobs and globals from the command line.
  • Recording: MP4, APNG and GIF of a scene or a play.

The project itself:

How it works

#[scene] self-registers through inventory; build.rs reads gallery.toml and compiles in the scene files its globs match; launch! reads the same file, builds them into the crate's dylib and runs the shell. The globs are written down once and both go to them, so a bare cargo build — a CI type-check, an editor — finds the scenes a run finds. The dylib is what --hot swaps without restarting — still one crate.

Three crates: gallery (shell and framework), gallery-macros (the #[scene] and #[play] proc-macros), gallery-build (the build.rs helper).

Dependency compatibility

Gallery and scenes use compatible egui 0.36 dependencies. Native accessibility uses eframe/accesskit, and runtime capture uses egui_kittest. gallery-build has no accessibility stack.

Status & roadmap

On either renderer: discovery, the tree, hot reload, knobs read and written from the scene, catalog globals, the source view, SVG icons, headless captures, plays with their checks, snapshots and recordings, the catalog's tests with their report, and plays run live in the window. What is planned is in docs/TODO.md.

License

Code: Unlicense — public domain, no rights reserved.

Bundled fonts: the shell sets its own text in Inter (fonts/inter/ — Regular and SemiBold), and ships four Noto fallback faces (fonts/noto/ — Sans, Symbols, Symbols 2, Math) so arrows, math, and symbol glyphs render instead of tofu. Both are SIL OFL 1.1 (Inter, Noto), which permits embedding and redistribution. Scenes keep egui's own faces. CJK and emoji aren't bundled (each is multi-megabyte); a catalog that needs them adds its own font in the host setup closure.

About

An egui-shelled component catalog for Rust with Storybook-style scene discovery — browse UI components in isolation, one state at a time.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages