diff --git a/crates/editor2/src/items.rs b/crates/editor2/src/items.rs index e0374d3d7307ce0972a94d66993e0b9df05750a0..ddb5b25db2fd990a675b15165b8d7d19282e3b1d 100644 --- a/crates/editor2/src/items.rs +++ b/crates/editor2/src/items.rs @@ -603,7 +603,11 @@ impl Item for Editor { Color::Muted })) .when_some(description, |this, description| { - this.child(Label::new(description).color(Color::Muted)) + this.child( + Label::new(description) + .size(LabelSize::XSmall) + .color(Color::Muted), + ) }) .into_any_element() } diff --git a/crates/ui2/src/components/button/button.rs b/crates/ui2/src/components/button/button.rs index 406cd1f420be8b6ff2e2a81e92f47fd8fa0748b1..bc5d03d639ffe4ba4fb1d5c8c6886268b7660159 100644 --- a/crates/ui2/src/components/button/button.rs +++ b/crates/ui2/src/components/button/button.rs @@ -172,7 +172,7 @@ impl RenderOnce for Button { Label::new(label) .color(label_color) .size(self.label_size.unwrap_or_default()) - .line_height_style(LineHeightStyle::UILabel), + .line_height_style(LineHeightStyle::UiLabel), ) .when(!self.icon_position.is_some(), |this| { this.children(self.icon.map(|icon| { diff --git a/crates/ui2/src/components/button/toggle_button.rs b/crates/ui2/src/components/button/toggle_button.rs index 39a517111b9a1958afac86979f4adbbdd18c25bf..4a6ecdeb2fc6cea673e8f695a35e0b7ec7cfa517 100644 --- a/crates/ui2/src/components/button/toggle_button.rs +++ b/crates/ui2/src/components/button/toggle_button.rs @@ -122,7 +122,7 @@ impl RenderOnce for ToggleButton { .child( Label::new(self.label) .color(label_color) - .line_height_style(LineHeightStyle::UILabel), + .line_height_style(LineHeightStyle::UiLabel), ) } } diff --git a/crates/ui2/src/components/label/label_like.rs b/crates/ui2/src/components/label/label_like.rs index 72a48adea451f49cd10dd2e2bd224f16d4ae51a9..ebfbbecceb6d2468d3c7da98929d3cd4bd20f1ba 100644 --- a/crates/ui2/src/components/label/label_like.rs +++ b/crates/ui2/src/components/label/label_like.rs @@ -8,14 +8,15 @@ pub enum LabelSize { #[default] Default, Small, + XSmall, } #[derive(Default, PartialEq, Copy, Clone)] pub enum LineHeightStyle { #[default] TextLabel, - /// Sets the line height to 1 - UILabel, + /// Sets the line height to 1. + UiLabel, } pub trait LabelCommon { @@ -92,8 +93,9 @@ impl RenderOnce for LabelLike { .map(|this| match self.size { LabelSize::Default => this.text_ui(), LabelSize::Small => this.text_ui_sm(), + LabelSize::XSmall => this.text_ui_xs(), }) - .when(self.line_height_style == LineHeightStyle::UILabel, |this| { + .when(self.line_height_style == LineHeightStyle::UiLabel, |this| { this.line_height(relative(1.)) }) .text_color(self.color.color(cx)) diff --git a/crates/ui2/src/styled_ext.rs b/crates/ui2/src/styled_ext.rs index 3358968c727c26872a6140b83a68b81043634c52..7e761f8f2c7a156be20ecc6b0ee20a4b72f2974a 100644 --- a/crates/ui2/src/styled_ext.rs +++ b/crates/ui2/src/styled_ext.rs @@ -3,7 +3,7 @@ use settings::Settings; use theme::ThemeSettings; use crate::prelude::*; -use crate::{ElevationIndex, UITextSize}; +use crate::{ElevationIndex, UiTextSize}; fn elevated(this: E, cx: &mut WindowContext, index: ElevationIndex) -> E { this.bg(cx.theme().colors().elevated_surface_background) @@ -44,10 +44,8 @@ pub trait StyledExt: Styled + Sized { self.flex().flex_col() } - fn text_ui_size(self, size: UITextSize) -> Self { - let size = size.rems(); - - self.text_size(size) + fn text_ui_size(self, size: UiTextSize) -> Self { + self.text_size(size.rems()) } /// The default size for UI text. @@ -58,9 +56,7 @@ pub trait StyledExt: Styled + Sized { /// /// Use [`text_ui_sm`] for regular-sized text. fn text_ui(self) -> Self { - let size = UITextSize::default().rems(); - - self.text_size(size) + self.text_size(UiTextSize::default().rems()) } /// The small size for UI text. @@ -71,9 +67,18 @@ pub trait StyledExt: Styled + Sized { /// /// Use [`text_ui`] for regular-sized text. fn text_ui_sm(self) -> Self { - let size = UITextSize::Small.rems(); + self.text_size(UiTextSize::Small.rems()) + } - self.text_size(size) + /// The extra small size for UI text. + /// + /// `0.625rem` or `10px` at the default scale of `1rem` = `16px`. + /// + /// Note: The absolute size of this text will change based on a user's `ui_scale` setting. + /// + /// Use [`text_ui`] for regular-sized text. + fn text_ui_xs(self) -> Self { + self.text_size(UiTextSize::XSmall.rems()) } /// The font size for buffer text. diff --git a/crates/ui2/src/styles/typography.rs b/crates/ui2/src/styles/typography.rs index 18b2c4849af3687b6ea0468a3ccc77846637f67f..4819791b02c988bfccc1c59484b373e5d8249bfe 100644 --- a/crates/ui2/src/styles/typography.rs +++ b/crates/ui2/src/styles/typography.rs @@ -1,7 +1,7 @@ use gpui::{rems, Rems}; #[derive(Debug, Default, Clone)] -pub enum UITextSize { +pub enum UiTextSize { /// The default size for UI text. /// /// `0.825rem` or `14px` at the default scale of `1rem` = `16px`. @@ -15,13 +15,21 @@ pub enum UITextSize { /// /// Note: The absolute size of this text will change based on a user's `ui_scale` setting. Small, + + /// The extra small size for UI text. + /// + /// `0.625rem` or `10px` at the default scale of `1rem` = `16px`. + /// + /// Note: The absolute size of this text will change based on a user's `ui_scale` setting. + XSmall, } -impl UITextSize { +impl UiTextSize { pub fn rems(self) -> Rems { match self { - Self::Default => rems(0.875), - Self::Small => rems(0.75), + Self::Default => rems(14. / 16.), + Self::Small => rems(12. / 16.), + Self::XSmall => rems(10. / 16.), } } }