core: remove sizing from badge
This commit is contained in:
@@ -9,7 +9,7 @@ use gpui::{
|
|||||||
use gpui_native_icons::Icon;
|
use gpui_native_icons::Icon;
|
||||||
use gpui_native_theme::{ActiveTheme as _, Size, Theme};
|
use gpui_native_theme::{ActiveTheme as _, Size, Theme};
|
||||||
|
|
||||||
use crate::common::{Sizable, StyledExt, h_flex};
|
use crate::common::{StyledExt, h_flex};
|
||||||
|
|
||||||
/// The tooltip view builder gpui's `.tooltip(...)` expects.
|
/// The tooltip view builder gpui's `.tooltip(...)` expects.
|
||||||
type TooltipBuilder = Rc<dyn Fn(&mut Window, &mut App) -> AnyView>;
|
type TooltipBuilder = Rc<dyn Fn(&mut Window, &mut App) -> AnyView>;
|
||||||
@@ -77,7 +77,6 @@ pub struct Badge {
|
|||||||
label: SharedString,
|
label: SharedString,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
variant: BadgeVariant,
|
variant: BadgeVariant,
|
||||||
size: Size,
|
|
||||||
tooltip: Option<TooltipBuilder>,
|
tooltip: Option<TooltipBuilder>,
|
||||||
style: StyleRefinement,
|
style: StyleRefinement,
|
||||||
}
|
}
|
||||||
@@ -94,7 +93,6 @@ impl Badge {
|
|||||||
label: label.into(),
|
label: label.into(),
|
||||||
icon: None,
|
icon: None,
|
||||||
variant: BadgeVariant::default(),
|
variant: BadgeVariant::default(),
|
||||||
size: Size::default(),
|
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
style: StyleRefinement::default(),
|
style: StyleRefinement::default(),
|
||||||
}
|
}
|
||||||
@@ -125,12 +123,6 @@ impl Badge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sizable for Badge {
|
|
||||||
fn apply_size(&mut self, size: Size) {
|
|
||||||
self.size = size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl gpui::Styled for Badge {
|
impl gpui::Styled for Badge {
|
||||||
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
||||||
&mut self.style
|
&mut self.style
|
||||||
@@ -140,7 +132,7 @@ impl gpui::Styled for Badge {
|
|||||||
impl RenderOnce for Badge {
|
impl RenderOnce for Badge {
|
||||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let metrics = theme.sizes.resolve(self.size);
|
let metrics = theme.sizes.resolve(Size::Small);
|
||||||
let label_size = metrics.caption_size;
|
let label_size = metrics.caption_size;
|
||||||
let (background, foreground, border) = self.variant.tokens(theme);
|
let (background, foreground, border) = self.variant.tokens(theme);
|
||||||
|
|
||||||
|
|||||||
@@ -1903,9 +1903,7 @@ impl Render for BadgeDemo {
|
|||||||
)
|
)
|
||||||
.child(Badge::new("badge-drift", "drift").variant(BadgeVariant::Warning))
|
.child(Badge::new("badge-drift", "drift").variant(BadgeVariant::Warning))
|
||||||
.child(Badge::new("badge-danger", "12").variant(BadgeVariant::Danger))
|
.child(Badge::new("badge-danger", "12").variant(BadgeVariant::Danger))
|
||||||
.child(Badge::new("badge-outline", "outline").variant(BadgeVariant::Outline))
|
.child(Badge::new("badge-outline", "outline").variant(BadgeVariant::Outline)),
|
||||||
.child(Badge::new("badge-small", "small").small())
|
|
||||||
.child(Badge::new("badge-large", "large").large()),
|
|
||||||
))
|
))
|
||||||
.child(demo_section(
|
.child(demo_section(
|
||||||
"tooltip",
|
"tooltip",
|
||||||
|
|||||||
Reference in New Issue
Block a user