@@ -14,8 +14,18 @@ use strum::EnumIter;
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
pub enum UITextSize {
+ /// The default size for UI text.
+ ///
+ /// `0.825rem` or `14px` at the default scale of `1rem` = `16px`.
+ ///
+ /// Note: The absolute size of this text will change based on a user's `ui_scale` setting.
#[default]
Default,
+ /// The small size for UI text.
+ ///
+ /// `0.75rem` or `12px` at the default scale of `1rem` = `16px`.
+ ///
+ /// Note: The absolute size of this text will change based on a user's `ui_scale` setting.
Small,
}
@@ -28,24 +38,6 @@ impl UITextSize {
}
}
-/// The default text size for UI text
-///
-/// At a default 16px per rem, this is 14px.
-///
-/// Use [`ui_text_sm`] for smaller text.
-pub fn ui_text_default() -> Rems {
- rems(0.875)
-}
-
-/// The small text size for UI text
-///
-/// At a default 16px per rem, this is 12px.
-///
-/// Use [`ui_text_default`] for regular-sized text.
-pub fn ui_text_sm() -> Rems {
- rems(0.75)
-}
-
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
pub enum FileSystemStatus {
#[default]
@@ -1,28 +1,40 @@
-use gpui::Styled;
+use gpui::{Div, Styled};
use crate::UITextSize;
-pub trait StyledExt: Styled {
- fn text_ui_size(self, size: UITextSize) -> Self
- where
- Self: Sized,
- {
+/// Extends [`Styled`](gpui::Styled) with Zed specific styling methods.
+pub trait StyledExt {
+ fn text_ui_size(self, size: UITextSize) -> Self;
+ fn text_ui(self) -> Self;
+ fn text_ui_sm(self) -> Self;
+}
+
+impl<V: 'static> StyledExt for Div<V> {
+ fn text_ui_size(self, size: UITextSize) -> Self {
let size = size.rems();
self.text_size(size)
}
- fn text_ui(self) -> Self
- where
- Self: Sized,
- {
+ /// The default size for UI text.
+ ///
+ /// `0.825rem` or `14px` 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_sm`] for regular-sized text.
+ fn text_ui(self) -> Self {
let size = UITextSize::default().rems();
self.text_size(size)
}
- fn text_ui_sm(self) -> Self
- where
- Self: Sized,
- {
+ /// The small size for UI text.
+ ///
+ /// `0.75rem` or `12px` 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_sm(self) -> Self {
let size = UITextSize::Small.rems();
self.text_size(size)