This PR adds a `TrafficLights` component for GPUI2. <img width="861" alt="Screenshot 2023-09-21 at 11 32 10 PM" src="https://github.com/zed-industries/zed/assets/1486634/0fe0e847-49b3-44dc-bd4c-64f12f0051c1"> Release Notes: - N/A
31 lines
859 B
Rust
31 lines
859 B
Rust
use gpui2::elements::div;
|
|
use gpui2::style::StyleHelpers;
|
|
use gpui2::{Element, Hsla, IntoElement, ParentElement, ViewContext};
|
|
|
|
use crate::theme;
|
|
|
|
#[derive(Element)]
|
|
pub struct TrafficLights {}
|
|
|
|
pub fn traffic_lights() -> TrafficLights {
|
|
TrafficLights {}
|
|
}
|
|
|
|
impl TrafficLights {
|
|
fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
let theme = theme(cx);
|
|
|
|
div()
|
|
.flex()
|
|
.items_center()
|
|
.gap_2()
|
|
.child(traffic_light(theme.lowest.negative.default.foreground))
|
|
.child(traffic_light(theme.lowest.warning.default.foreground))
|
|
.child(traffic_light(theme.lowest.positive.default.foreground))
|
|
}
|
|
}
|
|
|
|
fn traffic_light<V: 'static, C: Into<Hsla>>(fill: C) -> div::Div<V> {
|
|
div().w_3().h_3().rounded_full().fill(fill.into())
|
|
}
|