T44d Web · Gallery builds for wasm32: one story per section by URL, themed by the host

The gallery's entry runs natively or, on wasm32, from a wasm_bindgen start
through gpui_web, single-threaded with WebGL2 fallback. ?page, ?story and
?theme choose what shows; an unknown one fails in the page and the log.
set_theme switches the mode later. Pictures load from ELY_GALLERY_ASSETS.
scripts/stories.py writes examples/gallery/stories.json from the pages.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-29 19:16:41 -04:00
1 parent 29f1c8f467
commit 09dd3fc2cb
83 files changed
+1000 -455

No files matched your search

+10
View File
@@ -136,6 +136,16 @@ impl Theme {
Self::fade_to_target(cx);
}
/// Sets `mode` without the fade, as before a window's first frame; a fade under way stops.
pub fn set_mode_now(mode: Mode, cx: &mut App) {
log::info!("theme: mode -> {mode:?}, at once");
let theme = cx.global_mut::<Theme>();
theme.mode = mode;
theme.transition += 1;
theme.colors = theme.target();
cx.refresh_windows();
}
pub fn set_high_contrast(on: bool, cx: &mut App) {
log::info!("theme: high contrast -> {on}");
cx.global_mut::<Theme>().high_contrast = on;
+25
View File
@@ -1,3 +1,5 @@
use std::time::Duration;
use gpui::{TestAppContext, hsla};
use super::{ActiveTheme, Mode, Palette, Syntax, Theme};
@@ -19,6 +21,29 @@ fn an_owners_palette_serves_its_mode_alone(cx: &mut TestAppContext) {
assert_eq!(cx.read(|cx| cx.theme().palette()), Palette::light(false));
}
/// A mode set at once wears its palette at once, and a fade under way cannot pull it back.
#[gpui::test]
fn a_mode_set_at_once_skips_the_fade(cx: &mut TestAppContext) {
cx.update(|cx| {
Theme::init(cx);
Theme::update(cx, |theme| theme.reduced_motion = true);
Theme::set_mode(Mode::Dark, cx);
Theme::set_mode_now(Mode::Light, cx);
});
assert_eq!(
cx.read(|cx| cx.theme().colors.clone()),
Palette::light(false)
);
std::thread::sleep(Duration::from_millis(2));
cx.executor().advance_clock(Duration::from_millis(100));
cx.run_until_parked();
assert!(!cx.read(|cx| cx.theme().is_dark()));
assert_eq!(
cx.read(|cx| cx.theme().colors.clone()),
Palette::light(false)
);
}
/// Every color of the palette and of code answers to its field's name, the quiet fills too.
#[test]
fn every_color_answers_to_its_name() {