lib.rs

 1//! # UI – Zed UI Primitives & Components
 2//!
 3//! This crate provides a set of UI primitives and components that are used to build all of the elements in Zed's UI.
 4//!
 5//! ## Work in Progress
 6//!
 7//! This crate is still a work in progress. The initial primitives and components are built for getting all the UI on the screen,
 8//! much of the state and functionality is mocked or hard codeded, and performance has not been a focus.
 9//!
10//! Expect some inconsistencies from component to component as we work out the best way to build these components.
11//!
12//! ## Getting Started
13//!
14//! This is a quick primer to get you started using the UI components.
15//!
16//! You shouldn't need to construct an element from scratch very often. If you find
17//! yourself manually styling things like hover, text colors, etc, you should
18//! probably check that there isn't already a base component for whatever you are building.
19//!
20//! Here is an into to some of the most common elements:
21//!
22//! ### Text
23//!
24//! For generic UI text most frequently you will use a [`Label`] component.
25//!
26//! ```rust
27//! use ui2::prelude::*;
28//! use ui2::{Label, LabelColor};
29//!
30//! pub fn render_some_ui_text<V: 'static>() -> impl Component<V> {
31//!     div().p_2().child(
32//!         Label::new("Hello World")
33//!             .color(LabelColor::Muted)
34//!     )
35//! }
36//! ```
37//!
38//! ### Interactive Elements
39//!
40//! - Icon: To make an icon interactive, use [`IconButton`].
41//! - Button: To make a button interactive, use [`Button`].
42//!
43//! ## Design Philosophy
44//!
45//! Work in Progress!
46//!
47
48// TODO: Fix warnings instead of supressing.
49#![allow(dead_code, unused_variables)]
50
51mod components;
52mod elements;
53mod elevation;
54pub mod prelude;
55pub mod settings;
56mod static_data;
57pub mod utils;
58
59pub use components::*;
60pub use elements::*;
61pub use prelude::*;
62pub use static_data::*;
63
64// This needs to be fully qualified with `crate::` otherwise we get a panic
65// at:
66//   thread '<unnamed>' panicked at crates/gpui2/src/platform/mac/platform.rs:66:81:
67//   called `Option::unwrap()` on a `None` value
68//
69// AFAICT this is something to do with conflicting names between crates and modules that
70// interfaces with declaring the `ClassDecl`.
71pub use crate::settings::*;
72
73#[cfg(feature = "stories")]
74mod story;
75#[cfg(feature = "stories")]
76pub use story::*;