This PR adds an initial set of default colors to `gpui`.
These will power default-styled gpui components (things like checkboxes,
buttons, inputs, etc.), storybook, and give a very simple,
appearance-aware set of colors out of the box for folks to build with.
These colors will evolve and be updated in the near future, they are
literally pulled from Finder for now :)
The API might not be perfect, I focused on getting something in quickly
that we can iterate on!
### Usage
```rs
use gpui::{colors, DefaultColor}
fn auto(cx: &WindowContext) -> {
// Init the full set of DefaultColors
let colors = colors(cx.appearance());
// Use a color
// It will automatically give you the correct color for the system's
// current appearance.
let background = DefaultColor::Background.hsla(&colors)
}
fn manual() -> {
// Init the full sets of DefaultColors
let light_colors = DefaultColors::light();
let dark_colors = DefaultColors::dark();
// Use a color
// Maybe for some fancy inverted element
let background = DefaultColor::Background.hsla(&light_colors)
let inverted_background = DefaultColor::Background.hsla(&dark_colors)
let inverted_text = DefaultColor::Text.hsla(&dark_colors)
}
```
Note: We need `cx` for the auto way as we need to get the system
appearance from the App/Window/ViewContext via `cx.appearance()`.
### Example
You can run `script/storybook default_colors` to open the Default Colors
story:
| Light | Dark |
|-------|------|
| 
| 
|
Release Notes:
- N/A
26 lines
375 B
Rust
26 lines
375 B
Rust
mod anchored;
|
|
mod animation;
|
|
mod canvas;
|
|
mod common;
|
|
mod deferred;
|
|
mod div;
|
|
mod img;
|
|
mod list;
|
|
mod surface;
|
|
mod svg;
|
|
mod text;
|
|
mod uniform_list;
|
|
|
|
pub use anchored::*;
|
|
pub use animation::*;
|
|
pub use canvas::*;
|
|
pub use common::*;
|
|
pub use deferred::*;
|
|
pub use div::*;
|
|
pub use img::*;
|
|
pub use list::*;
|
|
pub use surface::*;
|
|
pub use svg::*;
|
|
pub use text::*;
|
|
pub use uniform_list::*;
|