feat: add status dot component
This commit is contained in:
@@ -27,6 +27,7 @@ use gpui_native_core::segmented::{Segmented, SegmentedOption};
|
||||
use gpui_native_core::select::{Select, SelectOption};
|
||||
use gpui_native_core::slider::Slider;
|
||||
use gpui_native_core::spinner::{Spinner, SpinnerVariant};
|
||||
use gpui_native_core::status_dot::{StatusDot, StatusDotVariant};
|
||||
use gpui_native_core::switch::Switch;
|
||||
use gpui_native_core::toast::{Toast, ToastAction, Toasts, ToastsView};
|
||||
use gpui_native_core::toggle::Toggle;
|
||||
@@ -53,6 +54,7 @@ const CATALOG: &[(&str, &[(&str, &str)])] = &[
|
||||
("button", "Button"),
|
||||
("input", "Input"),
|
||||
("field", "Field"),
|
||||
("status-dot", "Status dot"),
|
||||
("checkbox", "Checkbox"),
|
||||
("radio", "Radio"),
|
||||
("switch", "Switch"),
|
||||
@@ -388,6 +390,12 @@ impl Gallery {
|
||||
PanelDescriptor::new("field", "Field", |_, cx| cx.new(FieldDemo::new).into()),
|
||||
cx,
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("status-dot", "Status dot", |_, cx| {
|
||||
cx.new(|_| StatusDotDemo).into()
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("checkbox", "Checkbox", |_, cx| {
|
||||
cx.new(|_| CheckboxDemo { checked: false }).into()
|
||||
@@ -948,6 +956,70 @@ impl Render for FieldDemo {
|
||||
}
|
||||
}
|
||||
|
||||
struct StatusDotDemo;
|
||||
|
||||
impl Render for StatusDotDemo {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let colors = cx.theme().colors;
|
||||
|
||||
let bead = |id: &'static str, variant: StatusDotVariant| {
|
||||
StatusDot::new(id).variant(variant).label("Sync state")
|
||||
};
|
||||
|
||||
ScrollArea::new("status-dot-demo")
|
||||
.size_full()
|
||||
.p_4()
|
||||
.child(demo_section(
|
||||
"variants",
|
||||
colors,
|
||||
h_flex()
|
||||
.gap_3()
|
||||
.child(bead("dot-demo-neutral", StatusDotVariant::Neutral))
|
||||
.child(bead("dot-demo-accent", StatusDotVariant::Accent))
|
||||
.child(bead("dot-demo-success", StatusDotVariant::Success))
|
||||
.child(bead("dot-demo-warning", StatusDotVariant::Warning))
|
||||
.child(bead("dot-demo-danger", StatusDotVariant::Danger)),
|
||||
))
|
||||
.child(demo_section(
|
||||
"sizes",
|
||||
colors,
|
||||
h_flex()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.child(StatusDot::new("dot-demo-small").small().label("Sync state"))
|
||||
.child(StatusDot::new("dot-demo-medium").label("Sync state"))
|
||||
.child(StatusDot::new("dot-demo-large").large().label("Sync state")),
|
||||
))
|
||||
.child(demo_section(
|
||||
"on rows",
|
||||
colors,
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(bead("dot-demo-row-sync", StatusDotVariant::Success))
|
||||
.child("reya/signed — synced"),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(bead("dot-demo-row-drift", StatusDotVariant::Warning))
|
||||
.child("reya/gpui-native-kit — 2 commits drifting"),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(bead("dot-demo-row-fail", StatusDotVariant::Danger))
|
||||
.child("reya/notes — push failed"),
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckboxDemo {
|
||||
checked: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user