ui: Update Label component (#24653)

- Standardize style methods
- Convert label story to a component preview
- update component preview styles  

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-02-11 15:16:59 -05:00 committed by GitHub
parent aab3e0495d
commit 2d71733490
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 182 additions and 151 deletions

View file

@ -1,7 +1,7 @@
use std::ops::{Deref, DerefMut};
use collections::HashMap;
use gpui::{div, prelude::*, AnyElement, App, IntoElement, RenderOnce, SharedString, Window};
use gpui::{div, prelude::*, px, AnyElement, App, IntoElement, RenderOnce, SharedString, Window};
use linkme::distributed_slice;
use once_cell::sync::Lazy;
use parking_lot::RwLock;
@ -201,8 +201,9 @@ impl RenderOnce for ComponentExample {
};
base.gap_1()
.text_xs()
.text_color(cx.theme().colors().text_muted)
.p_2()
.text_sm()
.text_color(cx.theme().colors().text)
.when(self.grow, |this| this.flex_1())
.child(self.element)
.child(self.variant_name)
@ -243,13 +244,34 @@ impl RenderOnce for ComponentExampleGroup {
.text_sm()
.text_color(cx.theme().colors().text_muted)
.when(self.grow, |this| this.w_full().flex_1())
.when_some(self.title, |this, title| this.gap_4().child(title))
.when_some(self.title, |this, title| {
this.gap_4().pb_5().child(
div()
.flex()
.items_center()
.gap_3()
.child(div().h_px().w_4().bg(cx.theme().colors().border_variant))
.child(
div()
.flex_none()
.text_size(px(10.))
.child(title.to_uppercase()),
)
.child(
div()
.h_px()
.w_full()
.flex_1()
.bg(cx.theme().colors().border),
),
)
})
.child(
div()
.flex()
.items_start()
.w_full()
.gap_6()
.gap_8()
.children(self.examples)
.into_any_element(),
)