Tooling · Catalogs: token viewer, contrast audit; fg_subtle meets AA

DesignTokenViewer shows every token of the theme in the mode shown,
named as code reads it: colors with their hex, syntax, chart and
terminal colors, the type scale, radii, control and icon sizes,
elevations and spacing. A11yChecker audits each text color over the
surfaces it sits on at 4.5:1 and the focus ring and chart hues at
3:1, failures first. The audit found fg_subtle under 4.5:1 on hover
and overlay; it is #6f6d6a light and #8c8a87 dark now, and a test
holds all four Ely palettes to the audit. IconBrowser points to
forms::IconPicker and the ScreenshotTest Harness to the gallery's
capture, each with a section on the tooling page.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-28 08:23:39 -04:00
1 parent bfd1285064
commit d5271d03ea
11 files changed
+757 -8

No files matched your search

@@ -0,0 +1,74 @@
use ely_gpui_component::{
forms::IconPicker,
primitives::{Icon, IconName},
theme::{ActiveTheme, IconSize},
tooling::{A11yChecker, DesignTokenViewer},
typography::Code,
};
use gpui::{AnyElement, App, IntoElement, ParentElement, Styled, Window, div, px};
use crate::probe::probe;
use crate::ui::section;
pub fn sections(window: &mut Window, cx: &mut App) -> Vec<AnyElement> {
let picked = window.use_keyed_state("icon-browser-picked", cx, |_, _| IconName::Search);
let icon = *picked.read(cx);
let fg = cx.theme().colors.fg;
vec![
section(
"DesignTokenViewer",
"Every token of the theme in the mode shown, each named as code reads it: the colors with their hex, the syntax, chart and terminal colors, the type scale, radii, control and icon sizes, elevations and the spacing steps.",
cx,
)
.child(div().max_w(px(840.0)).child(DesignTokenViewer::new()))
.into_any_element(),
section(
"IconBrowser",
"The library's icons, searchable: this is forms::IconPicker, its home. Pick one to see the name code uses.",
cx,
)
.child(
div()
.flex()
.flex_wrap()
.items_start()
.gap_6()
.child(probe(
"icon-browser",
IconPicker::new("icon-browser")
.selected(icon)
.on_change(move |next, _, cx| {
picked.update(cx, |picked, cx| {
*picked = next;
cx.notify();
})
}),
))
.child(
div()
.flex()
.items_center()
.gap_3()
.child(Icon::new(icon).size(IconSize::Xxl).color(fg))
.child(Code::new(format!("IconName::{icon:?}"))),
),
)
.into_any_element(),
section(
"A11yChecker",
"The theme's contrast in the mode shown: each text color over the surfaces it sits on at 4.5:1, the focus ring and the chart hues beside the page at 3:1, failures first. Ely's palettes pass in both modes, with high contrast and without.",
cx,
)
.child(div().max_w(px(560.0)).child(A11yChecker::new()))
.into_any_element(),
section(
"ScreenshotTest Harness",
"The gallery photographs itself: --capture writes every page top to bottom, light and dark, then each page's scripted states, with input posted to its own event queue. Each pass starts its page fresh, and reduced motion holds the shots still.",
cx,
)
.child(Code::new(
"cargo run --example gallery -- --page tooling --capture shots",
))
.into_any_element(),
]
}
+10 -1
View File
@@ -6,6 +6,7 @@ use ely_gpui_component::{
};
use gpui::{AnyElement, App, IntoElement, ParentElement, Styled, Window, div, px};
mod catalogs;
mod inspection;
use super::Page;
@@ -17,7 +18,7 @@ pub const PAGE: Page = Page {
number: 43,
slug: "tooling",
title: "Library Tooling",
summary: "Tools for building with the library: this gallery, a playground that edits a component live, and tools that inspect a running window: its boxes, frames, renders and input.",
summary: "Tools for building with the library: this gallery, a playground that edits a component live, tools that inspect a running window, its boxes, frames, renders and input, and catalogs of its tokens, icons and contrast.",
render,
script: &[
Step::DownAt("button-playground", 472.0, 207.0),
@@ -53,11 +54,18 @@ pub const PAGE: Page = Page {
Step::Type("Hi"),
Step::Key("backspace"),
Step::Shot("events"),
Step::DownAt("icon-browser", 100.0, 14.0),
Step::UpAt("icon-browser", 100.0, 14.0),
Step::Type("sun"),
Step::DownAt("icon-browser", 16.0, 52.0),
Step::UpAt("icon-browser", 16.0, 52.0),
Step::Shot("icon-browser"),
],
};
fn render(window: &mut Window, cx: &mut App) -> AnyElement {
let inspection = inspection::sections(window, cx);
let catalogs = catalogs::sections(window, cx);
div()
.child(section(
"ComponentGallery / Storybook",
@@ -132,5 +140,6 @@ fn render(window: &mut Window, cx: &mut App) -> AnyElement {
),
)
.children(inspection)
.children(catalogs)
.into_any_element()
}