gpui_kit_material/lib.rs
1//! Material 3 adapters for Longbridge GPUI Kit.
2//!
3//! The kit is layered so each layer can be replaced without touching the
4//! ones above it:
5//!
6//! | Layer | Module | Holds |
7//! | --- | --- | --- |
8//! | Color | [`color`] (`gpui-kit-material-color`) | palettes, roles, scheme derivation |
9//! | Theme | [`theme`] | the painted scheme, palette transitions, [`theme::color`] |
10//! | Tokens | [`tokens`] | shape, type scale, layout metrics, elevation, state layers |
11//! | Motion | [`motion`] | M3 springs, entrances, retargetable values |
12//! | Icons | [`icons`] | Google Material Symbols through [`icons::Assets`] |
13//! | Components | [`components`] | Material presentation over Kit components and Base parts |
14//!
15//! Reuse [`gpui_kit::component`] controls where their presentation hooks meet the
16//! Material contract; [`gpui_base`] supplies behavior for uncovered parts. This
17//! kit owns the Material appearance and motion, not another generic UI runtime.
18//!
19//! Call `gpui_kit::init` and then [`init`] once at startup. Use Kit's
20//! `open_window` for the single Root, register [`icons::Assets`], and initialize [`theme::init_component_theme`] before Root's first
21//! render. Advance [`theme::advance_component_theme`] from input events and
22//! pre-frame callbacks. Base-only consumers can paint with
23//! [`theme::apply_scheme`] at the start of each root render.
24extern crate gpui_kit as gpui;
25
26pub use gpui_kit_material_color as color;
27
28pub mod components;
29pub mod icons;
30pub mod motion;
31pub mod theme;
32pub mod tokens;
33
34/// Register the kit's key bindings. Call once, before opening windows.
35pub fn init(cx: &mut gpui::App) {
36 icons::init(cx);
37 components::init(cx);
38}
39
40/// The roles, tokens and components most pages need, including the
41/// [`theme::color`] lookup. The crate root's `color` is the color module.
42pub mod prelude {
43 pub use crate::color::themes::{Contrast, ThemeId, ThemeMode};
44 pub use crate::color::{Appearance, ColorRole, PaletteId, ThemePreferences};
45 pub use crate::components::*;
46 pub use crate::theme::color;
47 pub use crate::tokens::{layout::*, shape::*, typography::*};
48}