chore: replace pixel metrics with rem-based sizing across ui
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run

This commit is contained in:
2026-11-19 15:47:50 +07:00
parent 5a597f43c4
commit a0f69b6450
74 changed files with 897 additions and 1090 deletions
+4 -9
View File
@@ -1,10 +1,10 @@
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
App, Context, Entity, FontWeight, IntoElement, ParentElement as _, Render, SharedString, App, Context, Entity, IntoElement, ParentElement as _, Render, SharedString, Styled as _,
Styled as _, Window, div, Window, div,
}; };
use ui::button::{Button, ButtonVariant}; use ui::button::{Button, ButtonVariant};
use ui::common::v_flex; use ui::common::{StyledExt as _, v_flex};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use crate::identity::import::ImportDialog; use crate::identity::import::ImportDialog;
@@ -47,12 +47,7 @@ impl Render for SignedOutView {
.items_center() .items_center()
.justify_center() .justify_center()
.gap_4() .gap_4()
.child( .child(div().text_2xl().font_semibold().child("Signed"))
div()
.text_2xl()
.font_weight(FontWeight::SEMIBOLD)
.child("Signed"),
)
.child( .child(
v_flex() v_flex()
.gap_1() .gap_1()
+8 -7
View File
@@ -7,9 +7,9 @@ use metadata::ProfileDirectory;
use signed_core::Announcement; use signed_core::Announcement;
use signed_state::{RepoListStore, Timestamp}; use signed_state::{RepoListStore, Timestamp};
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
use crate::repo::actions::open_repo_panel; use crate::repo::actions::open_repo_panel;
@@ -111,7 +111,8 @@ pub(super) fn render_card(
.child( .child(
div() div()
.min_w_0() .min_w_0()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.whitespace_nowrap() .whitespace_nowrap()
.text_ellipsis() .text_ellipsis()
.child(name), .child(name),
@@ -120,7 +121,7 @@ pub(super) fn render_card(
this.child( this.child(
h_flex() h_flex()
.gap_1() .gap_1()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.whitespace_nowrap() .whitespace_nowrap()
.child( .child(
@@ -136,7 +137,7 @@ pub(super) fn render_card(
div() div()
.h_16() .h_16()
.min_w_0() .min_w_0()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.line_clamp(2) .line_clamp(2)
.child(description), .child(description),
@@ -157,7 +158,7 @@ pub(super) fn render_card(
) )
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.whitespace_nowrap() .whitespace_nowrap()
.child(owner_name), .child(owner_name),
@@ -167,7 +168,7 @@ pub(super) fn render_card(
h_flex() h_flex()
.flex_1() .flex_1()
.justify_end() .justify_end()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.whitespace_nowrap() .whitespace_nowrap()
.child(activity), .child(activity),
+2 -3
View File
@@ -6,7 +6,7 @@ use signed_state::Backend;
use ui::button::{Button, ButtonVariant}; use ui::button::{Button, ButtonVariant};
use ui::common::v_flex; use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
pub struct ExitDialog { pub struct ExitDialog {
handle: DialogHandle, handle: DialogHandle,
@@ -31,8 +31,7 @@ impl Render for ExitDialog {
.content(|_, cx| { .content(|_, cx| {
v_flex() v_flex()
.child( .child(
div() div().text_base()
.typeset(TextRole::Body, cx)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child( .child(
"You will be signed out on this device and will need to sign in again on the next session.", "You will be signed out on this device and will need to sign in again on the next session.",
+2 -2
View File
@@ -9,7 +9,7 @@ use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field; use ui::field::Field;
use ui::input::{Input, InputState, InputStateEvent}; use ui::input::{Input, InputState, InputStateEvent};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use crate::shared::progress::{DialogProgress, error_row}; use crate::shared::progress::{DialogProgress, error_row};
@@ -163,7 +163,7 @@ impl Render for ImportDialog {
.gap_3() .gap_3()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(description), .child(description),
) )
+2 -2
View File
@@ -9,7 +9,7 @@ use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field; use ui::field::Field;
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use crate::shared::progress::{DialogProgress, error_row}; use crate::shared::progress::{DialogProgress, error_row};
@@ -96,7 +96,7 @@ impl Render for OnboardingDialog {
.gap_3() .gap_3()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Set up your Signed identity to get started."), .child("Set up your Signed identity to get started."),
) )
+7 -7
View File
@@ -9,10 +9,10 @@ use ui::avatar::Avatar;
use ui::badge::Badge; use ui::badge::Badge;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
pub fn repo_header(id: SharedString, name: SharedString, unread: usize, cx: &App) -> AnyElement { pub fn repo_header(id: SharedString, name: SharedString, unread: usize) -> AnyElement {
h_flex() h_flex()
.h_12() .h_12()
.w_full() .w_full()
@@ -20,7 +20,7 @@ pub fn repo_header(id: SharedString, name: SharedString, unread: usize, cx: &App
.child( .child(
div() div()
.min_w_0() .min_w_0()
.typeset(TextRole::Body, cx) .text_base()
.whitespace_nowrap() .whitespace_nowrap()
.text_ellipsis() .text_ellipsis()
.child(name), .child(name),
@@ -36,7 +36,7 @@ pub fn empty_section_row(cx: &App) -> AnyElement {
.h_12() .h_12()
.w_full() .w_full()
.px_3() .px_3()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.bg(cx.theme().colors.secondary) .bg(cx.theme().colors.secondary)
.rounded(cx.theme().radius.control) .rounded(cx.theme().radius.control)
@@ -78,7 +78,7 @@ pub fn thread(
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child( .child(
h_flex() h_flex()
.size_6() .size_6()
@@ -134,7 +134,7 @@ fn sub_activity(
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.gap_1() .gap_1()
.typeset(TextRole::Caption, cx) .text_xs()
.child( .child(
Avatar::new(event.pubkey) Avatar::new(event.pubkey)
.name(name.clone()) .name(name.clone())
@@ -184,7 +184,7 @@ pub fn empty_state(message: &'static str, cx: &App) -> AnyElement {
) )
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(message)), .child(SharedString::from(message)),
) )
+4 -4
View File
@@ -12,11 +12,10 @@ use nostr::prelude::{Event, EventId, Kind, PublicKey, Timestamp};
use signed_core::{InboxItem, InboxReadState, RepoAddr}; use signed_core::{InboxItem, InboxReadState, RepoAddr};
use signed_state::{Backend, BackendEvent, Inbox, RefreshGate, RefreshRequest, RepoListStore}; use signed_state::{Backend, BackendEvent, Inbox, RefreshGate, RefreshRequest, RepoListStore};
use ui::button::Button; use ui::button::Button;
use ui::common::{h_flex, v_flex}; use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::scroll_area::ScrollArea; use ui::scroll_area::ScrollArea;
use ui::theme::{TextRole, Typeset as _};
mod helpers; mod helpers;
@@ -351,7 +350,7 @@ impl InboxView {
.map(ToString::to_string) .map(ToString::to_string)
.unwrap_or_default() .unwrap_or_default()
)); ));
repo_header(id, name, section.unread, cx) repo_header(id, name, section.unread)
} }
InboxRow::Entry(section_ix, entry_ix) => { InboxRow::Entry(section_ix, entry_ix) => {
let Some(section) = self.sections.get(section_ix) else { let Some(section) = self.sections.get(section_ix) else {
@@ -416,7 +415,8 @@ impl Render for InboxView {
.gap_2() .gap_2()
.child( .child(
div() div()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.child(SharedString::from("Inbox")), .child(SharedString::from("Inbox")),
) )
.child(div().flex_1()) .child(div().flex_1())
+6 -7
View File
@@ -7,12 +7,12 @@ use nostr::prelude::{EventId, PublicKey};
use signed_core::GitEvent; use signed_core::GitEvent;
use signed_state::RepoStore; use signed_state::RepoStore;
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::empty_state::EmptyState; use ui::empty_state::EmptyState;
use ui::input::InputState; use ui::input::InputState;
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::scroll_area::ScrollArea; use ui::scroll_area::ScrollArea;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
use crate::issues::helpers::{comment_form, comments_section, issue_roots, sidebar_section}; use crate::issues::helpers::{comment_form, comments_section, issue_roots, sidebar_section};
@@ -147,7 +147,8 @@ impl Render for IssueDetailView {
div() div()
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.child(title), .child(title),
), ),
) )
@@ -160,7 +161,7 @@ impl Render for IssueDetailView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
@@ -187,9 +188,7 @@ impl Render for IssueDetailView {
.child(SharedString::from(age)), .child(SharedString::from(age)),
), ),
) )
.child( .child(div().text_base().child(content)),
div().typeset(TextRole::Body, cx).child(content),
),
) )
.child(comments_section( .child(comments_section(
&self.store, &self.store,
+8 -13
View File
@@ -9,10 +9,10 @@ use signed_state::RepoStore;
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::badge::{Badge, BadgeVariant}; use ui::badge::{Badge, BadgeVariant};
use ui::button::Button; use ui::button::Button;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
use utils::relative_time; use utils::relative_time;
@@ -129,12 +129,7 @@ pub(crate) fn sidebar_section(
.picture(profile.picture()) .picture(profile.picture())
.small(), .small(),
) )
.child( .child(div().text_base().text_ellipsis().child(name))
div()
.typeset(TextRole::Body, cx)
.text_ellipsis()
.child(name),
)
.into_any_element() .into_any_element()
})), })),
) )
@@ -146,7 +141,7 @@ pub(crate) fn sidebar_section(
if labels.is_empty() { if labels.is_empty() {
this.child( this.child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("None yet."), .child("None yet."),
) )
@@ -173,7 +168,7 @@ pub(crate) fn comments_section(
v_flex() v_flex()
.gap_4() .gap_4()
.child(div().typeset(TextRole::Caption2, cx).child(title)) .child(div().text_xs().font_medium().child(title))
.children(comments.iter().map(|comment| { .children(comments.iter().map(|comment| {
let profile = directory.read(cx).profile(&comment.pubkey, cx); let profile = directory.read(cx).profile(&comment.pubkey, cx);
let author = profile.name(); let author = profile.name();
@@ -189,7 +184,7 @@ pub(crate) fn comments_section(
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
@@ -212,7 +207,7 @@ pub(crate) fn comments_section(
.child(SharedString::from(age)), .child(SharedString::from(age)),
), ),
) )
.child(div().typeset(TextRole::Body, cx).child(content)) .child(div().text_base().child(content))
})) }))
.into_any_element() .into_any_element()
} }
@@ -241,7 +236,7 @@ pub(crate) fn comment_form(
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child( .child(
Icon::named(IconRole::Markdown) Icon::named(IconRole::Markdown)
+3 -3
View File
@@ -17,7 +17,7 @@ use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::segmented::{Segmented, SegmentedOption}; use ui::segmented::{Segmented, SegmentedOption};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
use self::detail::IssueDetailView; use self::detail::IssueDetailView;
@@ -252,7 +252,7 @@ impl Render for IssuesView {
.gap_1() .gap_1()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(title), .child(title),
@@ -260,7 +260,7 @@ impl Render for IssuesView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Caption, cx) .text_xs()
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
+2 -2
View File
@@ -8,7 +8,7 @@ use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field; use ui::field::Field;
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
pub struct NewIssueDialog { pub struct NewIssueDialog {
handle: DialogHandle, handle: DialogHandle,
@@ -58,7 +58,7 @@ impl Render for NewIssueDialog {
.gap_3() .gap_3()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Report a bug, ask a question, or propose a change."), .child("Report a bug, ask a question, or propose a change."),
) )
@@ -14,7 +14,7 @@ use signed_state::{Backend, Mirrors, RepoStore};
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::button::Button; use ui::button::Button;
use ui::clipboard::ClipboardButton; use ui::clipboard::ClipboardButton;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::InputState; use ui::input::InputState;
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
@@ -22,7 +22,7 @@ use ui::scroll_area::ScrollArea;
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::tabs::{Tab, Tabs}; use ui::tabs::{Tab, Tabs};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
use super::dialogs; use super::dialogs;
@@ -376,7 +376,7 @@ impl PullRequestDetailView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
@@ -397,9 +397,7 @@ impl PullRequestDetailView {
) )
.when(!self.description.is_empty(), |this| { .when(!self.description.is_empty(), |this| {
this.child( this.child(
div() div().text_base().child(self.description.clone()),
.typeset(TextRole::Body, cx)
.child(self.description.clone()),
) )
}), }),
) )
@@ -527,7 +525,8 @@ impl PullRequestDetailView {
div() div()
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.text_ellipsis() .text_ellipsis()
.child(title), .child(title),
), ),
@@ -574,7 +573,7 @@ impl PullRequestDetailView {
h_flex() h_flex()
.gap_1() .gap_1()
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(id.clone()) .child(id.clone())
.child(ClipboardButton::new("pr-commit", &id)), .child(ClipboardButton::new("pr-commit", &id)),
@@ -9,7 +9,7 @@ use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field; use ui::field::Field;
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
pub struct UpdatePrDialog { pub struct UpdatePrDialog {
handle: DialogHandle, handle: DialogHandle,
@@ -55,7 +55,7 @@ impl Render for UpdatePrDialog {
.gap_3() .gap_3()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Publish a new revision with the output of `git format-patch`."), .child("Publish a new revision with the output of `git format-patch`."),
) )
+3 -3
View File
@@ -17,7 +17,7 @@ use ui::layout::panel::Panel;
use ui::menu::MenuItem; use ui::menu::MenuItem;
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::segmented::{Segmented, SegmentedOption}; use ui::segmented::{Segmented, SegmentedOption};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time; use utils::relative_time;
mod detail; mod detail;
@@ -387,7 +387,7 @@ impl Render for PullRequestsView {
.gap_1() .gap_1()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(title), .child(title),
@@ -395,7 +395,7 @@ impl Render for PullRequestsView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Caption, cx) .text_xs()
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
+8 -11
View File
@@ -9,7 +9,7 @@ use gpui::{
use signed_state::{CheckoutsStore, RepoStore}; use signed_state::{CheckoutsStore, RepoStore};
use ui::button::Button; use ui::button::Button;
use ui::combobox::{Combobox, ComboboxState}; use ui::combobox::{Combobox, ComboboxState};
use ui::common::{h_flex, v_flex}; use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
@@ -17,7 +17,7 @@ use ui::menu::Menu;
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::tabs::{Tab, Tabs}; use ui::tabs::{Tab, Tabs};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use super::helpers::{ForkCompare, fork_display_name, truncate_label}; use super::helpers::{ForkCompare, fork_display_name, truncate_label};
use crate::repo::commit_diff::{CommitDiffView, DiffPane}; use crate::repo::commit_diff::{CommitDiffView, DiffPane};
@@ -281,17 +281,17 @@ impl NewPullRequestView {
.child( .child(
v_flex() v_flex()
.gap_1() .gap_1()
.child(label("Merge Into", cx)) .child(label("Merge Into"))
.child(div().w(px(160.)).child(self.base_select.clone())), .child(div().w(px(160.)).child(self.base_select.clone())),
) )
.child( .child(
v_flex() v_flex()
.gap_1() .gap_1()
.child(label("Pull From", cx)) .child(label("Pull From"))
.child(div().w(px(160.)).child(self.compare_select.clone())), .child(div().w(px(160.)).child(self.compare_select.clone())),
) )
.child( .child(
v_flex().gap_1().child(label("Source", cx)).child( v_flex().gap_1().child(label("Source")).child(
Menu::new("pr-source") Menu::new("pr-source")
.open(self.source_open) .open(self.source_open)
.on_change(move |open, _, cx| { .on_change(move |open, _, cx| {
@@ -475,7 +475,7 @@ impl Render for NewPullRequestView {
.when_some(self.error.clone(), |this, error| { .when_some(self.error.clone(), |this, error| {
this.child( this.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().ramps.destructive.base) .text_color(cx.theme().ramps.destructive.base)
.child(error), .child(error),
) )
@@ -493,9 +493,6 @@ impl Render for NewPullRequestView {
} }
} }
fn label(text: &'static str, cx: &App) -> AnyElement { fn label(text: &'static str) -> AnyElement {
div() div().text_xs().font_medium().child(text).into_any_element()
.typeset(TextRole::Caption2, cx)
.child(text)
.into_any_element()
} }
@@ -9,7 +9,7 @@ use ui::common::{h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use crate::workspace::Workspace; use crate::workspace::Workspace;
@@ -148,7 +148,7 @@ impl Render for SendPatchView {
) )
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child( .child(
"You can paste a git diff or a git format-patch patch series here.", "You can paste a git diff or a git format-patch patch series here.",
@@ -162,7 +162,7 @@ impl Render for SendPatchView {
.when_some(self.error.clone(), |this, error| { .when_some(self.error.clone(), |this, error| {
this.child( this.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().ramps.destructive.base) .text_color(cx.theme().ramps.destructive.base)
.child(error), .child(error),
) )
+12 -13
View File
@@ -10,13 +10,13 @@ use gpui::{
use signed_git::{CommitDiff, DiffStatus, FileCommit, FileDiff, Repo}; use signed_git::{CommitDiff, DiffStatus, FileCommit, FileDiff, Repo};
use ui::badge::{Badge, BadgeVariant}; use ui::badge::{Badge, BadgeVariant};
use ui::clipboard::ClipboardButton; use ui::clipboard::ClipboardButton;
use ui::common::{h_flex, v_flex}; use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::layout::resizable::{Resizable, ResizableState}; use ui::layout::resizable::{Resizable, ResizableState};
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tree::{Tree, TreeItem}; use ui::tree::{Tree, TreeItem};
use utils::relative_time_secs; use utils::relative_time_secs;
@@ -283,7 +283,8 @@ impl DiffPane {
.gap_2() .gap_2()
.child( .child(
div() div()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.text_color(status_color) .text_color(status_color)
.child(status_label), .child(status_label),
) )
@@ -291,7 +292,8 @@ impl DiffPane {
div() div()
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(title), .child(title),
@@ -300,7 +302,7 @@ impl DiffPane {
this.child( this.child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Caption, cx) .text_xs()
.child( .child(
div() div()
.text_color(cx.theme().ramps.success.base) .text_color(cx.theme().ramps.success.base)
@@ -447,7 +449,8 @@ impl CommitDiffView {
v_flex() v_flex()
.child( .child(
div() div()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(commit.summary.clone()), .child(commit.summary.clone()),
@@ -455,7 +458,7 @@ impl CommitDiffView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child(SharedString::from(format!("{} committed", commit.author))) .child(SharedString::from(format!("{} committed", commit.author)))
.child( .child(
h_flex() h_flex()
@@ -472,16 +475,12 @@ impl CommitDiffView {
), ),
) )
.when_some(commit.description.as_ref(), |this, description| { .when_some(commit.description.as_ref(), |this, description| {
this.child( this.child(div().text_base().child(SharedString::from(description)))
div()
.typeset(TextRole::Body, cx)
.child(SharedString::from(description)),
)
}) })
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Caption, cx) .text_xs()
.child(Badge::new("commit-files", format!("{files} files changed"))) .child(Badge::new("commit-files", format!("{files} files changed")))
.when(insertions > 0, |this| { .when(insertions > 0, |this| {
this.child( this.child(
+11 -12
View File
@@ -7,9 +7,9 @@ use nostr::prelude::PublicKey;
use signed_core::Announcement; use signed_core::Announcement;
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::clipboard::ClipboardButton; use ui::clipboard::ClipboardButton;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::middle_truncate; use utils::middle_truncate;
pub struct AboutDialog { pub struct AboutDialog {
@@ -61,7 +61,6 @@ fn announcement_rows(
.as_deref() .as_deref()
.map(SharedString::from) .map(SharedString::from)
.unwrap_or_else(|| SharedString::from("-")), .unwrap_or_else(|| SharedString::from("-")),
cx,
), ),
cx, cx,
)); ));
@@ -73,7 +72,6 @@ fn announcement_rows(
.as_deref() .as_deref()
.map(SharedString::from) .map(SharedString::from)
.unwrap_or_else(|| SharedString::from("-")), .unwrap_or_else(|| SharedString::from("-")),
cx,
), ),
cx, cx,
)); ));
@@ -99,13 +97,13 @@ fn announcement_rows(
} }
if let Some(upstream) = &announcement.upstream { if let Some(upstream) = &announcement.upstream {
rows.push(row("Upstream", text(upstream.display(), cx), cx)); rows.push(row("Upstream", text(upstream.display()), cx));
} }
if !announcement.hashtags.is_empty() { if !announcement.hashtags.is_empty() {
rows.push(row( rows.push(row(
"Hashtags", "Hashtags",
text(SharedString::from(announcement.hashtags.join(", ")), cx), text(SharedString::from(announcement.hashtags.join(", "))),
cx, cx,
)); ));
} }
@@ -151,7 +149,8 @@ fn row(label: &'static str, value: AnyElement, cx: &App) -> AnyElement {
.min_w_0() .min_w_0()
.child( .child(
div() div()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(label), .child(label),
) )
@@ -159,12 +158,12 @@ fn row(label: &'static str, value: AnyElement, cx: &App) -> AnyElement {
.into_any_element() .into_any_element()
} }
fn text<T>(value: T, cx: &App) -> AnyElement fn text<T>(value: T) -> AnyElement
where where
T: Into<SharedString>, T: Into<SharedString>,
{ {
div() div()
.typeset(TextRole::Body, cx) .text_base()
.w_full() .w_full()
.min_w_0() .min_w_0()
.child(value.into()) .child(value.into())
@@ -179,7 +178,7 @@ fn copy_value(id: &'static str, value: String, cx: &App) -> AnyElement {
.child( .child(
div() div()
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Caption, cx) .text_xs()
.min_w_0() .min_w_0()
.child(SharedString::from(value.clone())), .child(SharedString::from(value.clone())),
) )
@@ -216,7 +215,7 @@ fn maintainers(
.overflow_hidden() .overflow_hidden()
.whitespace_nowrap() .whitespace_nowrap()
.text_ellipsis() .text_ellipsis()
.typeset(TextRole::Body, cx) .text_base()
.child(name), .child(name),
) )
.into_any_element() .into_any_element()
@@ -243,7 +242,7 @@ fn list(id: &'static str, items: impl IntoIterator<Item = String>, cx: &App) ->
.min_w_0() .min_w_0()
.whitespace_nowrap() .whitespace_nowrap()
.text_ellipsis() .text_ellipsis()
.typeset(TextRole::Body, cx) .text_base()
.child(SharedString::from(middle_truncate(&item, 28, 16))), .child(SharedString::from(middle_truncate(&item, 28, 16))),
) )
.child(ClipboardButton::new( .child(ClipboardButton::new(
@@ -10,8 +10,7 @@ use ui::button::{Button, ButtonVariant};
use ui::common::{Sizable, h_flex, v_flex}; use ui::common::{Sizable, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::switch::Switch; use ui::theme::ActiveTheme as _;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
/// State of the grasp-server section of a publish dialog, so async results can be rendered. /// State of the grasp-server section of a publish dialog, so async results can be rendered.
@@ -72,7 +71,7 @@ pub fn grasp_servers_field(
h_flex() h_flex()
.justify_between() .justify_between()
.items_center() .items_center()
.child(div().typeset(TextRole::Caption, cx).child("Grasp servers")) .child(div().text_xs().child("Grasp servers"))
.child( .child(
Button::new("toggle-grasp-servers") Button::new("toggle-grasp-servers")
.icon(Icon::named(if servers_enabled { .icon(Icon::named(if servers_enabled {
@@ -99,7 +98,7 @@ pub fn grasp_servers_field(
section section
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Where the repository is hosted"), .child("Where the repository is hosted"),
) )
@@ -133,7 +132,7 @@ pub fn grasp_servers_field(
.when(loading_servers, |section| { .when(loading_servers, |section| {
section.child( section.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Loading your grasp servers..."), .child("Loading your grasp servers..."),
) )
@@ -141,7 +140,7 @@ pub fn grasp_servers_field(
.when_some(error, |section, error| { .when_some(error, |section, error| {
section.child( section.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().ramps.destructive.base) .text_color(cx.theme().ramps.destructive.base)
.child(error), .child(error),
) )
@@ -167,7 +166,7 @@ fn render_server_row(
.px_2() .px_2()
.bg(cx.theme().colors.muted) .bg(cx.theme().colors.muted)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.typeset(TextRole::Caption, cx) .text_xs()
.rounded(cx.theme().radius.control) .rounded(cx.theme().radius.control)
.child(server_host(relay)), .child(server_host(relay)),
) )
+3 -3
View File
@@ -16,7 +16,7 @@ use ui::field::Field;
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::select::{Select, SelectOption}; use ui::select::{Select, SelectOption};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers}; use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers};
use crate::repo::RepoDetailView; use crate::repo::RepoDetailView;
@@ -186,7 +186,7 @@ impl Render for InitRepoDialog {
.gap_3() .gap_3()
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Publish this local repository to Nostr."), .child("Publish this local repository to Nostr."),
) )
@@ -209,7 +209,7 @@ impl Render for InitRepoDialog {
.w_full() .w_full()
.px_2() .px_2()
.bg(cx.theme().colors.muted) .bg(cx.theme().colors.muted)
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.rounded(cx.theme().radius.control) .rounded(cx.theme().radius.control)
.child(folder.clone()), .child(folder.clone()),
+4 -7
View File
@@ -6,7 +6,7 @@ use signed_state::RepoStore;
use ui::button::{Button, ButtonVariant}; use ui::button::{Button, ButtonVariant};
use ui::common::v_flex; use ui::common::v_flex;
use ui::dialog::{Dialog, DialogHandle}; use ui::dialog::{Dialog, DialogHandle};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
pub struct ResetRemoteDialog { pub struct ResetRemoteDialog {
handle: DialogHandle, handle: DialogHandle,
@@ -39,16 +39,14 @@ impl Render for ResetRemoteDialog {
v_flex() v_flex()
.gap_2() .gap_2()
.child( .child(
div() div().text_base()
.typeset(TextRole::Body, cx)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child( .child(
"Grasp servers are overwritten to match the local mirror. Refs that do not exist locally are deleted from the servers. This cannot be undone.", "Grasp servers are overwritten to match the local mirror. Refs that do not exist locally are deleted from the servers. This cannot be undone.",
), ),
) )
.child(if deleted.is_empty() { .child(if deleted.is_empty() {
div() div().text_base()
.typeset(TextRole::Body, cx)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("No server refs will be deleted.") .child("No server refs will be deleted.")
.into_any_element() .into_any_element()
@@ -56,8 +54,7 @@ impl Render for ResetRemoteDialog {
v_flex() v_flex()
.gap_1() .gap_1()
.children(deleted.iter().map(|name| { .children(deleted.iter().map(|name| {
div() div().text_base()
.typeset(TextRole::Body, cx)
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.child(name.clone()) .child(name.clone())
})) }))
+6 -5
View File
@@ -9,10 +9,10 @@ use gpui::{
}; };
use signed_git::{FileCommit, Repo, WorktreeSnapshot}; use signed_git::{FileCommit, Repo, WorktreeSnapshot};
use ui::code::CodeViewState; use ui::code::CodeViewState;
use ui::common::{h_flex, v_flex}; use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::markdown::MarkdownViewState; use ui::markdown::MarkdownViewState;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tree::{Tree, TreeItem}; use ui::tree::{Tree, TreeItem};
use super::helpers::{code_language, is_markdown_path, preview_spinner, source_hash}; use super::helpers::{code_language, is_markdown_path, preview_spinner, source_hash};
@@ -352,7 +352,8 @@ impl RepoFilesView {
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child( .child(
div() div()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(pane_title), .child(pane_title),
@@ -364,14 +365,14 @@ impl RepoFilesView {
.gap_1() .gap_1()
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.child(commit.id.clone()), .child(commit.id.clone()),
) )
.child( .child(
div() div()
.max_w(px(250.)) .max_w(px(250.))
.typeset(TextRole::Caption, cx) .text_xs()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(commit.summary.clone()), .child(commit.summary.clone()),
+13 -21
View File
@@ -9,12 +9,12 @@ use signed_state::{Backend, Nip34Kind};
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariant}; use ui::button::{Button, ButtonVariant};
use ui::clipboard::ClipboardButton; use ui::clipboard::ClipboardButton;
use ui::common::{Sizable, h_flex, v_flex}; use ui::common::{Sizable, StyledExt as _, h_flex, v_flex};
use ui::dropdown_menu::DropdownMenu; use ui::dropdown_menu::DropdownMenu;
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::menu::MenuItem; use ui::menu::MenuItem;
use ui::popover::Popover; use ui::popover::Popover;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
use utils::relative_time_secs; use utils::relative_time_secs;
@@ -103,14 +103,15 @@ impl RepoDetailView {
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.child(avatar) .child(avatar)
.child(name), .child(name),
) )
.child( .child(
div() div()
.min_w_0() .min_w_0()
.typeset(TextRole::Callout, cx) .text_sm()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.line_clamp(3) .line_clamp(3)
.child(description), .child(description),
@@ -151,28 +152,24 @@ impl RepoDetailView {
"Clone with ngit", "Clone with ngit",
"copy-ngit", "copy-ngit",
&ngit_for_popover, &ngit_for_popover,
cx,
)) ))
.child(clone_group( .child(clone_group(
"Clone with nak", "Clone with nak",
"copy-nak", "copy-nak",
&nak_for_popover, &nak_for_popover,
cx,
)) ))
.child( .child(
v_flex() v_flex()
.gap_1() .gap_1()
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child("Grasp Servers"), .child("Grasp Servers"),
) )
.when(git_for_popover.is_empty(), |this| { .when(git_for_popover.is_empty(), |this| {
this.child( this.child(
div() div().text_xs().child("No git clone urls."),
.typeset(TextRole::Caption, cx)
.child("No git clone urls."),
) )
}) })
.children(git_for_popover.iter().enumerate().map( .children(git_for_popover.iter().enumerate().map(
@@ -325,7 +322,7 @@ impl RepoDetailView {
.child( .child(
div() div()
.min_w_0() .min_w_0()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(path), .child(path),
) )
@@ -383,21 +380,21 @@ impl RepoDetailView {
.child( .child(
div() div()
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Callout, cx) .text_sm()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(short)), .child(SharedString::from(short)),
) )
.child( .child(
div() div()
.max_w(px(220.)) .max_w(px(220.))
.typeset(TextRole::Callout, cx) .text_sm()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(commit.summary.clone()), .child(commit.summary.clone()),
) )
.child( .child(
div() div()
.typeset(TextRole::Callout, cx) .text_sm()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(relative_time_secs(commit.time)), .child(relative_time_secs(commit.time)),
) )
@@ -434,17 +431,12 @@ impl RepoDetailView {
.picture(owner.picture()) .picture(owner.picture())
.small(), .small(),
) )
.child( .child(div().text_xs().whitespace_nowrap().child(owner_name)),
div()
.typeset(TextRole::Caption, cx)
.whitespace_nowrap()
.child(owner_name),
),
) )
.when(!rest.is_empty(), |this| { .when(!rest.is_empty(), |this| {
this.child( this.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(format!("+{}", rest.len()))), .child(SharedString::from(format!("+{}", rest.len()))),
) )
+13 -21
View File
@@ -14,9 +14,9 @@ use signed_state::{Nip34Binding, RepoListStore, RepoStore};
use ui::avatar::Avatar; use ui::avatar::Avatar;
use ui::clipboard::ClipboardButton; use ui::clipboard::ClipboardButton;
use ui::combobox::ComboboxState; use ui::combobox::ComboboxState;
use ui::common::{Sizable as _, h_flex, v_flex}; use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use utils::relative_time_secs; use utils::relative_time_secs;
use super::RepoDetailView; use super::RepoDetailView;
@@ -52,19 +52,10 @@ pub(super) struct RepoData {
pub(super) head_commit: Option<FileCommit>, pub(super) head_commit: Option<FileCommit>,
} }
pub(super) fn clone_group( pub(super) fn clone_group(label: &str, id: &'static str, command: &SharedString) -> AnyElement {
label: &str,
id: &'static str,
command: &SharedString,
cx: &App,
) -> AnyElement {
v_flex() v_flex()
.gap_1() .gap_1()
.child( .child(div().text_xs().child(SharedString::from(label)))
div()
.typeset(TextRole::Caption, cx)
.child(SharedString::from(label)),
)
.child(ClipboardButton::new(id, command.clone())) .child(ClipboardButton::new(id, command.clone()))
.into_any_element() .into_any_element()
} }
@@ -114,7 +105,7 @@ pub(super) fn fork_row(
let row = h_flex() let row = h_flex()
.gap_1() .gap_1()
.min_w_0() .min_w_0()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(Icon::named(IconRole::GitBranch).small()) .child(Icon::named(IconRole::GitBranch).small())
.child(div().whitespace_nowrap().text_ellipsis().child(label)); .child(div().whitespace_nowrap().text_ellipsis().child(label));
@@ -187,7 +178,7 @@ pub(super) fn bound_repo_label(
h_flex() h_flex()
.flex_shrink_0() .flex_shrink_0()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.child("Initialized by") .child("Initialized by")
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.when_some(profile, |this, profile| { .when_some(profile, |this, profile| {
@@ -208,7 +199,8 @@ pub(super) fn bound_repo_label(
.when_some(binding.identifier.as_deref(), |this, ident| { .when_some(binding.identifier.as_deref(), |this, ident| {
this.child( this.child(
div() div()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.child(SharedString::from(format!("/{ident}"))), .child(SharedString::from(format!("/{ident}"))),
) )
}) })
@@ -292,7 +284,7 @@ pub(super) fn render_diff_row(hunks: &[DiffHunk], row: DiffRow, cx: &App) -> Any
.w_full() .w_full()
.h(px(DIFF_ROW_HEIGHT)) .h(px(DIFF_ROW_HEIGHT))
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Caption, cx) .text_xs()
.bg(cx.theme().colors.muted) .bg(cx.theme().colors.muted)
.border_y_1() .border_y_1()
.border_color(cx.theme().colors.border) .border_color(cx.theme().colors.border)
@@ -318,7 +310,7 @@ fn render_diff_line(line: &DiffLine, cx: &App) -> AnyElement {
.w_full() .w_full()
.h(px(DIFF_ROW_HEIGHT)) .h(px(DIFF_ROW_HEIGHT))
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Caption, cx) .text_xs()
.when_some(bg, |this, bg| this.bg(bg)) .when_some(bg, |this, bg| this.bg(bg))
.child( .child(
div() div()
@@ -379,7 +371,7 @@ pub(crate) fn commit_row(
.child( .child(
div() div()
.font_family(cx.theme().mono_font) .font_family(cx.theme().mono_font)
.typeset(TextRole::Callout, cx) .text_sm()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(commit.id.clone()), .child(commit.id.clone()),
) )
@@ -387,7 +379,7 @@ pub(crate) fn commit_row(
div() div()
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.typeset(TextRole::Callout, cx) .text_sm()
.text_ellipsis() .text_ellipsis()
.whitespace_nowrap() .whitespace_nowrap()
.child(commit.summary.clone()), .child(commit.summary.clone()),
@@ -396,7 +388,7 @@ pub(crate) fn commit_row(
.child( .child(
h_flex() h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(commit.author.clone()) .child(commit.author.clone())
.child(relative_time_secs(commit.time)), .child(relative_time_secs(commit.time)),
+2 -2
View File
@@ -13,7 +13,7 @@ use ui::common::{Sizable as _, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::scrollbar::Scrollbar; use ui::scrollbar::Scrollbar;
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
use super::RepoDetailView; use super::RepoDetailView;
@@ -249,7 +249,7 @@ impl Render for RepoHistoryView {
div() div()
.py_2() .py_2()
.w_full() .w_full()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(format!("Showing {shown} of {total} commits")), .child(format!("Showing {shown} of {total} commits")),
) )
+2 -2
View File
@@ -23,7 +23,7 @@ use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel; use ui::layout::panel::Panel;
use ui::sidebar::{Sidebar, SidebarEntry}; use ui::sidebar::{Sidebar, SidebarEntry};
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
pub mod actions; pub mod actions;
pub mod commit_diff; pub mod commit_diff;
@@ -854,7 +854,7 @@ impl RepoDetailView {
.child(Spinner::new("repo-loading")) .child(Spinner::new("repo-loading"))
.child( .child(
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(label), .child(label),
) )
+8 -8
View File
@@ -6,11 +6,11 @@ use gpui::{
}; };
use settings::{AppearanceMode, EventFetchingStrategy, SettingsStore}; use settings::{AppearanceMode, EventFetchingStrategy, SettingsStore};
use ui::button::Button; use ui::button::Button;
use ui::common::{h_flex, v_flex}; use ui::common::{StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::input::{Input, InputState}; use ui::input::{Input, InputState};
use ui::select::{Select, SelectOption}; use ui::select::{Select, SelectOption};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
use crate::repo::dialogs::grasp_servers::{normalize_server, server_host}; use crate::repo::dialogs::grasp_servers::{normalize_server, server_host};
@@ -31,10 +31,10 @@ pub fn setting_row(
.flex_1() .flex_1()
.min_w_0() .min_w_0()
.gap_1() .gap_1()
.child(div().typeset(TextRole::Headline, cx).child(title.into())) .child(div().text_sm().font_semibold().child(title.into()))
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(description.into()), .child(description.into()),
), ),
@@ -56,10 +56,10 @@ pub fn setting_block(
.child( .child(
v_flex() v_flex()
.gap_1() .gap_1()
.child(div().typeset(TextRole::Headline, cx).child(title.into())) .child(div().text_sm().font_semibold().child(title.into()))
.child( .child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(description.into()), .child(description.into()),
), ),
@@ -127,7 +127,7 @@ pub fn grasp_servers_editor(input: &Entity<InputState>, cx: &App) -> AnyElement
.px_2() .px_2()
.bg(cx.theme().colors.muted) .bg(cx.theme().colors.muted)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.typeset(TextRole::Caption, cx) .text_xs()
.rounded(cx.theme().radius.control) .rounded(cx.theme().radius.control)
.child(display_server(server)), .child(display_server(server)),
) )
@@ -227,7 +227,7 @@ pub fn scan_paths_editor(cx: &App) -> AnyElement {
.px_2() .px_2()
.bg(cx.theme().colors.muted) .bg(cx.theme().colors.muted)
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.typeset(TextRole::Caption, cx) .text_xs()
.rounded(cx.theme().radius.control) .rounded(cx.theme().radius.control)
.child(path.display().to_string()), .child(path.display().to_string()),
) )
+5 -5
View File
@@ -7,7 +7,7 @@ use signed_state::{Backend, BackendEvent, PushStepStatus};
use ui::common::{h_flex, v_flex}; use ui::common::{h_flex, v_flex};
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::spinner::Spinner; use ui::spinner::Spinner;
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
/// Progress of an async dialog action: a busy flag that disables the form and an error shown below it. /// Progress of an async dialog action: a busy flag that disables the form and an error shown below it.
#[derive(Debug, Default)] #[derive(Debug, Default)]
@@ -69,7 +69,7 @@ impl DialogProgress {
pub fn error_row(error: &Option<SharedString>, cx: &App) -> Option<AnyElement> { pub fn error_row(error: &Option<SharedString>, cx: &App) -> Option<AnyElement> {
error.as_ref().map(|message| { error.as_ref().map(|message| {
div() div()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().ramps.destructive.base) .text_color(cx.theme().ramps.destructive.base)
.child(message.clone()) .child(message.clone())
.into_any_element() .into_any_element()
@@ -90,14 +90,14 @@ pub fn push_steps_row(steps: &[PushStepStatus], cx: &App) -> Option<AnyElement>
match status { match status {
PushStepStatus::Running(_) => h_flex() PushStepStatus::Running(_) => h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(Spinner::new("push-step")) .child(Spinner::new("push-step"))
.child(label) .child(label)
.into_any_element(), .into_any_element(),
PushStepStatus::Done(_) => h_flex() PushStepStatus::Done(_) => h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().colors.foreground) .text_color(cx.theme().colors.foreground)
.child( .child(
Icon::named(IconRole::Check) Icon::named(IconRole::Check)
@@ -108,7 +108,7 @@ pub fn push_steps_row(steps: &[PushStepStatus], cx: &App) -> Option<AnyElement>
.into_any_element(), .into_any_element(),
PushStepStatus::Failed(_, reason) => h_flex() PushStepStatus::Failed(_, reason) => h_flex()
.gap_2() .gap_2()
.typeset(TextRole::Body, cx) .text_base()
.text_color(cx.theme().ramps.destructive.base) .text_color(cx.theme().ramps.destructive.base)
.child( .child(
Icon::named(IconRole::Close) Icon::named(IconRole::Close)
+4 -2
View File
@@ -1,9 +1,10 @@
use gpui::{AnyElement, App, IntoElement, ParentElement as _, SharedString, Styled as _, div}; use gpui::{AnyElement, App, IntoElement, ParentElement as _, SharedString, Styled as _, div};
use signed_core::RepoStatus; use signed_core::RepoStatus;
use ui::badge::{Badge, BadgeVariant}; use ui::badge::{Badge, BadgeVariant};
use ui::common::StyledExt as _;
use ui::empty_state::EmptyState; use ui::empty_state::EmptyState;
use ui::icons::{Icon, IconRole}; use ui::icons::{Icon, IconRole};
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
/// The status pill shown on issue and pull-request rows. /// The status pill shown on issue and pull-request rows.
@@ -35,7 +36,8 @@ pub fn empty_state(message: impl Into<SharedString>) -> AnyElement {
/// A one-line muted label used by section headers. /// A one-line muted label used by section headers.
pub fn section_label(text: impl Into<SharedString>, cx: &App) -> AnyElement { pub fn section_label(text: impl Into<SharedString>, cx: &App) -> AnyElement {
div() div()
.typeset(TextRole::Caption2, cx) .text_xs()
.font_medium()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
.child(text.into()) .child(text.into())
.into_any_element() .into_any_element()
@@ -4,7 +4,7 @@ use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
App, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render, Role, App, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render, Role,
SharedString, StatefulInteractiveElement as _, Styled as _, UniformListScrollHandle, Window, SharedString, StatefulInteractiveElement as _, Styled as _, UniformListScrollHandle, Window,
div, px, uniform_list, div, px, rems, uniform_list,
}; };
use metadata::ProfileDirectory; use metadata::ProfileDirectory;
use nostr::prelude::PublicKey; use nostr::prelude::PublicKey;
@@ -16,7 +16,7 @@ use ui::input::{Input, InputState};
use ui::kbd::Kbd; use ui::kbd::Kbd;
use ui::popover::Popover; use ui::popover::Popover;
use ui::separator::Separator; use ui::separator::Separator;
use ui::theme::{ActiveTheme as _, TextRole, Typeset}; use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip; use ui::tooltip::Tooltip;
use super::{CreateRepository, REPOSITORY_KEY_CONTEXT, SwitchRepository}; use super::{CreateRepository, REPOSITORY_KEY_CONTEXT, SwitchRepository};
@@ -153,7 +153,7 @@ impl Render for RepositorySwitcher {
.cloned() .cloned()
.collect(); .collect();
let row_height = theme.sizes.medium.menu_item_height + px(2.); let row_height = rems(2.0).to_pixels(window.rem_size()) + px(2.);
let list_height = (row_height * visible.len() as f32).min(px(280.)); let list_height = (row_height * visible.len() as f32).min(px(280.));
let list_entries = visible.clone(); let list_entries = visible.clone();
let list_directory = directory.clone(); let list_directory = directory.clone();
@@ -189,7 +189,7 @@ impl Render for RepositorySwitcher {
.p_3() .p_3()
.text_color(theme.colors.muted_foreground) .text_color(theme.colors.muted_foreground)
.text_center() .text_center()
.typeset(TextRole::Callout, cx) .text_sm()
.child("No repositories found"), .child("No repositories found"),
) )
} else { } else {
@@ -219,7 +219,7 @@ impl Render for RepositorySwitcher {
.px_3() .px_3()
.gap_2() .gap_2()
.rounded(theme.radius.control) .rounded(theme.radius.control)
.text_size(theme.sizes.medium.text_size) .text_sm()
.hover(|row| row.bg(theme.colors.muted)) .hover(|row| row.bg(theme.colors.muted))
.child(entry.avatar(&list_directory, cx)) .child(entry.avatar(&list_directory, cx))
.child( .child(
+8 -19
View File
@@ -23,7 +23,7 @@ use gpui::{
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _, Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
IntoElement, ParentElement as _, RenderOnce, Role, SharedString, IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, deferred, div, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, deferred, div,
ease_out_quint, ease_out_quint, rems,
}; };
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
@@ -31,10 +31,7 @@ use crate::components::common::{
DismissHandler, ResultLogErr as _, Sizable as _, StyledExt as _, TOAST_LAYER, v_flex, DismissHandler, ResultLogErr as _, Sizable as _, StyledExt as _, TOAST_LAYER, v_flex,
}; };
use crate::icons::{Icon, IconRole}; use crate::icons::{Icon, IconRole};
use crate::theme::{ use crate::theme::{ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE};
ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole,
Typeset as _,
};
/// How alarming an [`Alert`] is; picks the accent color. /// How alarming an [`Alert`] is; picks the accent color.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -166,17 +163,14 @@ impl RenderOnce for Alert {
let foreground = theme.colors.foreground; let foreground = theme.colors.foreground;
let muted_foreground = theme.colors.muted_foreground; let muted_foreground = theme.colors.muted_foreground;
let metrics = theme.sizes.resolve(Size::Medium);
let icon_size = metrics.icon_size;
let dense_icon_size = metrics.dense_icon_size;
let content = v_flex() let content = v_flex()
.flex_1() .flex_1()
.gap_0p5() .gap_0p5()
.when_some(self.title.clone(), |alert, title| { .when_some(self.title.clone(), |alert, title| {
alert.child( alert.child(
div() div()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.text_color(foreground) .text_color(foreground)
.child(title), .child(title),
) )
@@ -187,12 +181,7 @@ impl RenderOnce for Alert {
} else { } else {
foreground foreground
}; };
alert.child( alert.child(div().text_sm().text_color(color).child(message))
div()
.text_size(metrics.text_size)
.text_color(color)
.child(message),
)
}); });
let dismiss = self.on_dismiss.clone().map(|on_dismiss| { let dismiss = self.on_dismiss.clone().map(|on_dismiss| {
@@ -231,7 +220,7 @@ impl RenderOnce for Alert {
.flex() .flex()
.items_center() .items_center()
.h(window.line_height()) .h(window.line_height())
.child(icon_glyph.size(icon_size).color(ramp.base)), .child(icon_glyph.size(rems(1.0)).color(ramp.base)),
) )
}) })
.child(content) .child(content)
@@ -267,10 +256,10 @@ impl RenderOnce for Alert {
.flex() .flex()
.items_center() .items_center()
.justify_center() .justify_center()
.size(theme.sizes.small.avatar_size) .size_6()
.rounded(theme.radius.full) .rounded(theme.radius.full)
.bg(ramp.base) .bg(ramp.base)
.child(icon_glyph.size(dense_icon_size).color(ramp.foreground)), .child(icon_glyph.size(rems(0.75)).color(ramp.foreground)),
) )
}) })
.child(content), .child(content),
+5 -10
View File
@@ -18,7 +18,7 @@ use gpui::{
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, div, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, div,
}; };
use crate::components::common::{Sizable, StyledExt, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt, h_flex};
use crate::theme::{ use crate::theme::{
ActiveTheme as _, Oklch, PIXEL_AVATAR_DARK_FACTOR, PIXEL_AVATAR_DARK_FLOOR, ActiveTheme as _, Oklch, PIXEL_AVATAR_DARK_FACTOR, PIXEL_AVATAR_DARK_FLOOR,
PIXEL_AVATAR_LIGHT_CAP, PIXEL_AVATAR_LIGHT_LIFT, PIXEL_AVATAR_TINT_ALPHA, Size, ThemeVariant, PIXEL_AVATAR_LIGHT_CAP, PIXEL_AVATAR_LIGHT_LIFT, PIXEL_AVATAR_TINT_ALPHA, Size, ThemeVariant,
@@ -103,15 +103,10 @@ impl gpui::Styled for Avatar {
} }
impl RenderOnce for Avatar { impl RenderOnce for Avatar {
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();
// Avatars sit one class below the shared control scale. let size = self.size;
let size = match self.size { let side = size.avatar_rems() * window.rem_size();
Size::XSmall | Size::Small => Size::XSmall,
Size::Medium => Size::Small,
Size::Large => Size::Medium,
};
let side = theme.sizes.resolve(size).avatar_size;
let radius = if self.fully_rounded { let radius = if self.fully_rounded {
theme.radius.full theme.radius.full
@@ -124,7 +119,7 @@ impl RenderOnce for Avatar {
.flex_none() .flex_none()
.justify_center() .justify_center()
.overflow_hidden() .overflow_hidden()
.size(side) .avatar_size(size)
.bg(theme.colors.secondary) .bg(theme.colors.secondary)
.rounded(radius) .rounded(radius)
.role(Role::Image) .role(Role::Image)
+12 -13
View File
@@ -17,7 +17,7 @@ use gpui::{
Window, transparent_black, Window, transparent_black,
}; };
use crate::components::common::{Sizable, StyledExt, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt, h_flex};
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, Size, Theme}; use crate::theme::{ActiveTheme as _, Size, Theme};
@@ -150,15 +150,10 @@ 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 size = self.size;
let label_size = match self.size {
Size::XSmall | Size::Small => metrics.caption_size * 0.9,
Size::Medium | Size::Large => metrics.caption_size,
};
let square = label_size * 2.;
let (background, foreground, border) = self.variant.tokens(theme); let (background, foreground, border) = self.variant.tokens(theme);
h_flex() let badge = h_flex()
.id(self.id.clone()) .id(self.id.clone())
.flex_none() .flex_none()
.justify_center() .justify_center()
@@ -168,12 +163,16 @@ impl RenderOnce for Badge {
.border_color(border) .border_color(border)
.bg(background) .bg(background)
.text_color(foreground) .text_color(foreground)
.text_size(label_size) .control_caption_text(size);
.px(label_size * 0.5) let badge = match size {
.min_w(square) Size::XSmall | Size::Small => badge.h_5().min_w_5().px_1(),
.min_h(square) Size::Medium => badge.h_6().min_w_6().px_1p5(),
Size::Large => badge.h_7().min_w_7().px_2(),
};
badge
.when_some(self.icon, |badge, icon| { .when_some(self.icon, |badge, icon| {
badge.child(icon.size(metrics.dense_icon_size).color(foreground)) badge.child(icon.size(size.dense_icon_rems()).color(foreground))
}) })
.child(self.label) .child(self.label)
.refine_style(&self.style) .refine_style(&self.style)
+20 -23
View File
@@ -21,12 +21,12 @@ use gpui::{
}; };
use crate::components::common::{ use crate::components::common::{
Sizable, StyledExt as _, focus_ring, h_flex, record_anchor_bounds, ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex, record_anchor_bounds,
}; };
use crate::components::spinner::Spinner; use crate::components::spinner::Spinner;
use crate::icons::Icon; use crate::icons::Icon;
use crate::spinner::SpinnerVariant; use crate::spinner::SpinnerVariant;
use crate::theme::{ActiveTheme as _, ControlMetrics, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
/// The single activation handler, shared by pointer, Enter, and Space. /// The single activation handler, shared by pointer, Enter, and Space.
type ClickHandler = Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>; type ClickHandler = Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>;
@@ -70,7 +70,6 @@ pub struct Button {
children: Vec<AnyElement>, children: Vec<AnyElement>,
variant: ButtonVariant, variant: ButtonVariant,
size: Size, size: Size,
custom_metrics: Option<ControlMetrics>,
disabled: bool, disabled: bool,
loading: bool, loading: bool,
padded: bool, padded: bool,
@@ -98,7 +97,6 @@ impl Button {
children: Vec::new(), children: Vec::new(),
variant: ButtonVariant::default(), variant: ButtonVariant::default(),
size: Size::default(), size: Size::default(),
custom_metrics: None,
disabled: false, disabled: false,
loading: false, loading: false,
padded: true, padded: true,
@@ -147,12 +145,6 @@ impl Button {
self self
} }
/// Overrides the theme metrics, allowing sizes beyond the built-in classes.
pub fn custom_size(mut self, metrics: ControlMetrics) -> Self {
self.custom_metrics = Some(metrics);
self
}
/// Sets whether the button is a keyboard tab stop. Dense toolbars typically /// Sets whether the button is a keyboard tab stop. Dense toolbars typically
/// turn this off. /// turn this off.
pub fn tab_stop(mut self, tab_stop: bool) -> Self { pub fn tab_stop(mut self, tab_stop: bool) -> Self {
@@ -187,7 +179,7 @@ impl Button {
self self
} }
/// Renders the button as a pill instead of the control radius. /// Renders the button as a circle instead of the control radius.
pub fn fully_rounded(mut self, fully_rounded: bool) -> Self { pub fn fully_rounded(mut self, fully_rounded: bool) -> Self {
self.fully_rounded = fully_rounded; self.fully_rounded = fully_rounded;
self self
@@ -248,10 +240,6 @@ impl RenderOnce for Button {
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = self
.custom_metrics
.unwrap_or_else(|| theme.sizes.resolve(self.size));
let radius = if self.fully_rounded { let radius = if self.fully_rounded {
theme.radius.full theme.radius.full
} else { } else {
@@ -261,6 +249,12 @@ impl RenderOnce for Button {
let on_click = self.on_click; let on_click = self.on_click;
let a11y_label = self.a11y_label.or_else(|| self.label.clone()); let a11y_label = self.a11y_label.or_else(|| self.label.clone());
let is_icon_only = self.icon.is_some() && self.label.is_none() && self.children.is_empty(); let is_icon_only = self.icon.is_some() && self.label.is_none() && self.children.is_empty();
// A child-only button hugs its content as a circle when fully rounded.
let is_child_only =
self.icon.is_none() && self.label.is_none() && !self.children.is_empty();
let is_round_child = is_child_only && self.fully_rounded;
let icon_trailing = self.side == ButtonSide::Right; let icon_trailing = self.side == ButtonSide::Right;
let (background, foreground, hover, pressed) = match self.variant { let (background, foreground, hover, pressed) = match self.variant {
@@ -320,15 +314,18 @@ impl RenderOnce for Button {
ButtonSide::Left => button.justify_start(), ButtonSide::Left => button.justify_start(),
ButtonSide::Right => button.justify_end(), ButtonSide::Right => button.justify_end(),
}) })
.h(metrics.control_height) .control_height(self.size)
.when(is_icon_only, |button| button.w(metrics.control_height)) .when(is_icon_only || is_round_child, |button| {
.when(self.full_width, |button| button.w_full()) button.control_width(self.size)
.when(!is_icon_only && self.padded, |button| {
button.px(metrics.padding_x)
}) })
.when(self.full_width, |button| button.w_full())
.when(self.padded && !is_icon_only && !is_round_child, |button| {
button.control_padding_x(self.size)
})
.when(is_round_child, |button| button.overflow_hidden())
.line_height(relative(1.0)) .line_height(relative(1.0))
.rounded(radius) .rounded(radius)
.text_size(metrics.text_size) .control_text(self.size)
.border_1() .border_1()
.border_color(border) .border_color(border)
.when_some(background, |button, background| button.bg(background)) .when_some(background, |button, background| button.bg(background))
@@ -346,12 +343,12 @@ impl RenderOnce for Button {
.when_some(self.label, |content, label| content.child(label)) .when_some(self.label, |content, label| content.child(label))
.children(self.children) .children(self.children)
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size)) content.child(icon.size(self.size.icon_rems()))
}) })
} else { } else {
content content
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size)) content.child(icon.size(self.size.icon_rems()))
}) })
.when_some(self.label, |content, label| content.child(label)) .when_some(self.label, |content, label| content.child(label))
.children(self.children) .children(self.children)
+5 -5
View File
@@ -19,7 +19,7 @@ use gpui::{
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex};
use crate::icons::{IconRole, icon}; use crate::icons::{IconRole, icon};
use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
@@ -126,7 +126,7 @@ impl RenderOnce for Checkbox {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let on_change = self.on_change; let on_change = self.on_change;
let next = !self.checked; let next = !self.checked;
let a11y_label = self.a11y_label.or_else(|| self.label.clone()); let a11y_label = self.a11y_label.or_else(|| self.label.clone());
@@ -134,7 +134,7 @@ impl RenderOnce for Checkbox {
h_flex() h_flex()
.id(self.id) .id(self.id)
.gap_2() .gap_2()
.text_size(metrics.text_size) .control_text(size)
.refine_style(&self.style) .refine_style(&self.style)
.when_some(self.debug_selector, |checkbox, selector| { .when_some(self.debug_selector, |checkbox, selector| {
checkbox.debug_selector(move || selector()) checkbox.debug_selector(move || selector())
@@ -157,7 +157,7 @@ impl RenderOnce for Checkbox {
h_flex() h_flex()
.justify_center() .justify_center()
.flex_none() .flex_none()
.size(metrics.indicator_size) .control_indicator(size)
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.border_1() .border_1()
.when(self.checked, |indicator| { .when(self.checked, |indicator| {
@@ -171,7 +171,7 @@ impl RenderOnce for Checkbox {
}) })
.child( .child(
icon(IconRole::Check) icon(IconRole::Check)
.size(metrics.dense_icon_size) .size(size.dense_icon_rems())
.color(colors.primary_foreground), .color(colors.primary_foreground),
) )
}) })
+9 -8
View File
@@ -31,7 +31,7 @@ use gpui::{
IntoElement, KeyBinding, KeyBindingContextPredicate, MouseButton, MouseDownEvent, IntoElement, KeyBinding, KeyBindingContextPredicate, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Render, ScrollStrategy, MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Render, ScrollStrategy,
SharedString, StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle, SharedString, StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle,
Window, actions, canvas, div, uniform_list, Window, actions, canvas, div, rems, uniform_list,
}; };
use crate::components::highlight::{HighlightedCode, Language, Role, highlight}; use crate::components::highlight::{HighlightedCode, Language, Role, highlight};
@@ -297,14 +297,14 @@ impl gpui::Focusable for CodeViewState {
} }
impl Render for CodeViewState { impl Render for CodeViewState {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let mono_font = theme.mono_font; let mono_font = theme.mono_font;
let text_size = theme.sizes.small.text_size; let text_size = rems(0.75).to_pixels(window.rem_size());
let line_height = text_size * CODE_LINE_HEIGHT; let line_height = text_size * CODE_LINE_HEIGHT;
let char_width = text_size * MONO_ADVANCE_RATIO; let char_width = text_size * MONO_ADVANCE_RATIO;
let root_font_size = theme.root_font_size; let text_offset = rems(1.0).to_pixels(window.rem_size());
let id = self.id.clone(); let id = self.id.clone();
let state = cx.entity(); let state = cx.entity();
@@ -334,7 +334,7 @@ impl Render for CodeViewState {
theme.mono_font, theme.mono_font,
theme.colors, theme.colors,
theme.ramps, theme.ramps,
theme.sizes.small.text_size, text_size,
line_height, line_height,
cx, cx,
) )
@@ -350,7 +350,7 @@ impl Render for CodeViewState {
.id((id.clone(), "view")) .id((id.clone(), "view"))
.relative() .relative()
.size_full() .size_full()
.text_size(text_size) .text_xs()
.font_family(mono_font) .font_family(mono_font)
.text_color(colors.foreground) .text_color(colors.foreground)
.key_context(CODE_VIEW_CONTEXT) .key_context(CODE_VIEW_CONTEXT)
@@ -366,7 +366,7 @@ impl Render for CodeViewState {
return; return;
}; };
let text_x = bounds.origin.x + gutter_width + root_font_size; let text_x = bounds.origin.x + gutter_width + text_offset;
let point = { let point = {
let code = state.read(cx); let code = state.read(cx);
code.position_at( code.position_at(
@@ -403,7 +403,7 @@ impl Render for CodeViewState {
return; return;
}; };
let text_x = bounds.origin.x + gutter_width + root_font_size; let text_x = bounds.origin.x + gutter_width + text_offset;
let point = { let point = {
let code = state.read(cx); let code = state.read(cx);
code.position_at( code.position_at(
@@ -584,6 +584,7 @@ fn render_row(
.debug_selector(move || format!("{id}-row-{line_ix}")) .debug_selector(move || format!("{id}-row-{line_ix}"))
.id(("code-row", line_ix)) .id(("code-row", line_ix))
.w_full() .w_full()
.text_xs()
.h(line_height) .h(line_height)
.flex() .flex()
.items_center() .items_center()
+11 -11
View File
@@ -37,7 +37,7 @@ use gpui::{
}; };
use crate::components::common::{ use crate::components::common::{
OVERLAY_LAYER, ResultLogErr as _, Sizable, StyledExt as _, h_flex, v_flex, ControlSizing, OVERLAY_LAYER, ResultLogErr as _, Sizable, StyledExt as _, h_flex, v_flex,
}; };
use crate::components::input::{Input, InputState, InputStateEvent}; use crate::components::input::{Input, InputState, InputStateEvent};
use crate::components::scroll_area::ScrollArea; use crate::components::scroll_area::ScrollArea;
@@ -511,12 +511,10 @@ where
T: Clone + PartialEq + 'static, T: Clone + PartialEq + 'static,
{ {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let (metrics, colors, radius, panel_border, shadows) = { let (colors, radius, panel_border, shadows) = {
let theme = cx.theme(); let theme = cx.theme();
let metrics = theme.sizes.resolve(self.size);
( (
metrics,
theme.colors, theme.colors,
theme.radius, theme.radius,
theme.colors.border, theme.colors.border,
@@ -524,7 +522,6 @@ where
) )
}; };
let icon_size = metrics.dense_icon_size;
let id = self.id.clone(); let id = self.id.clone();
let state = cx.entity(); let state = cx.entity();
let open = self.highlight.is_some(); let open = self.highlight.is_some();
@@ -556,7 +553,7 @@ where
}) })
.child( .child(
icon(IconRole::ChevronDown) icon(IconRole::ChevronDown)
.size(icon_size) .size(self.size.dense_icon_rems())
.color(colors.muted_foreground), .color(colors.muted_foreground),
); );
@@ -616,8 +613,10 @@ where
.child( .child(
h_flex() h_flex()
.absolute() .absolute()
.right(metrics.dense_padding_x) .right(self.size.dense_padding_x_rems())
.top((metrics.input_height - icon_size) / 2.) .top_0()
.bottom_0()
.items_center()
.child(chevron), .child(chevron),
) )
.when(open, |wrapper| { .when(open, |wrapper| {
@@ -648,7 +647,8 @@ where
.gap_2() .gap_2()
.px_2() .px_2()
.py_1() .py_1()
.min_h(metrics.control_height) .control_height(self.size)
.control_text(self.size)
.rounded(radius.sm) .rounded(radius.sm)
.when(highlighted, |row| row.bg(colors.muted)) .when(highlighted, |row| row.bg(colors.muted))
.when(!highlighted, |row| row.hover(|row| row.bg(colors.muted))) .when(!highlighted, |row| row.hover(|row| row.bg(colors.muted)))
@@ -683,7 +683,7 @@ where
.when(checked, |row| { .when(checked, |row| {
row.child( row.child(
icon(IconRole::Check) icon(IconRole::Check)
.size(icon_size) .size(self.size.dense_icon_rems())
.color(colors.foreground), .color(colors.foreground),
) )
}) })
@@ -695,7 +695,7 @@ where
div() div()
.px_2() .px_2()
.py_1() .py_1()
.text_size(metrics.caption_size) .control_caption_text(self.size)
.text_color(colors.muted_foreground) .text_color(colors.muted_foreground)
.child("No matches") .child("No matches")
.into_any_element() .into_any_element()
+8 -9
View File
@@ -31,14 +31,14 @@ use gpui::{
AnyElement, App, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding, AnyElement, App, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding,
MouseButton, ParentElement as _, Render, Role, ScrollHandle, SharedString, MouseButton, ParentElement as _, Render, Role, ScrollHandle, SharedString,
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Subscription, Window, actions, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Subscription, Window, actions,
canvas, deferred, div, relative, canvas, deferred, div, relative, rems,
}; };
use crate::components::common::{DIALOG_LAYER, StyledExt as _, h_flex, v_flex}; use crate::components::common::{DIALOG_LAYER, StyledExt as _, h_flex, v_flex};
use crate::components::input::{Input, InputState, InputStateEvent}; use crate::components::input::{Input, InputState, InputStateEvent};
use crate::components::scroll_area::{ScrollArea, ScrollAxes}; use crate::components::scroll_area::{ScrollArea, ScrollAxes};
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size}; use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT};
actions!( actions!(
command_palette, command_palette,
@@ -371,12 +371,11 @@ impl Render for CommandPaletteState {
return div().into_any_element(); return div().into_any_element();
} }
let (colors, radius, metrics, panel_border, shadows, titlebar_height) = { let (colors, radius, panel_border, shadows, titlebar_height) = {
let theme = cx.theme(); let theme = cx.theme();
( (
theme.colors, theme.colors,
theme.radius, theme.radius,
theme.sizes.resolve(Size::default()),
theme.colors.border, theme.colors.border,
theme.elevations.dialog.shadows(), theme.elevations.dialog.shadows(),
theme.titlebar_height, theme.titlebar_height,
@@ -407,8 +406,8 @@ impl Render for CommandPaletteState {
.gap_2() .gap_2()
.px_2() .px_2()
.py_1() .py_1()
.min_h(metrics.control_height) .min_h_8()
.text_size(metrics.text_size) .text_sm()
.line_height(relative(1.0)) .line_height(relative(1.0))
.rounded(radius.sm) .rounded(radius.sm)
.when(highlighted, |row| row.bg(colors.muted)) .when(highlighted, |row| row.bg(colors.muted))
@@ -431,7 +430,7 @@ impl Render for CommandPaletteState {
} }
}) })
.when_some(command.icon.clone(), |row, icon| { .when_some(command.icon.clone(), |row, icon| {
row.child(icon.size(metrics.icon_size).color(colors.foreground)) row.child(icon.size(rems(1.0)).color(colors.foreground))
}) })
.child( .child(
div() div()
@@ -446,7 +445,7 @@ impl Render for CommandPaletteState {
row.child( row.child(
div() div()
.flex_shrink_0() .flex_shrink_0()
.text_size(metrics.caption_size) .text_xs()
.text_color(colors.muted_foreground) .text_color(colors.muted_foreground)
.child(hint), .child(hint),
) )
@@ -459,7 +458,7 @@ impl Render for CommandPaletteState {
div() div()
.px_2() .px_2()
.py_1() .py_1()
.text_size(metrics.caption_size) .text_xs()
.text_color(colors.muted_foreground) .text_color(colors.muted_foreground)
.child("No matches") .child("No matches")
.into_any_element() .into_any_element()
+297 -3
View File
@@ -14,9 +14,9 @@ use std::collections::HashMap;
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
App, Bounds, BoxShadow, Div, ElementId, FocusHandle, Global, Hsla, IntoElement, Pixels, App, Bounds, BoxShadow, Div, ElementId, FocusHandle, FontWeight, Global, Hsla, IntoElement,
Refineable as _, StatefulInteractiveElement, StyleRefinement, Styled, Window, WindowId, div, Pixels, Refineable as _, Rems, StatefulInteractiveElement, StyleRefinement, Styled, Window,
px, WindowId, div, px, rems,
}; };
pub use crate::theme::Size; pub use crate::theme::Size;
@@ -59,6 +59,20 @@ pub trait StyledExt: Styled + Sized {
self.style().refine(style); self.style().refine(style);
self self
} }
/// Sets the medium weight.
#[must_use]
fn font_medium(mut self) -> Self {
self.text_style().font_weight = Some(FontWeight::MEDIUM);
self
}
/// Sets the semibold weight.
#[must_use]
fn font_semibold(mut self) -> Self {
self.text_style().font_weight = Some(FontWeight::SEMIBOLD);
self
}
} }
impl<E: Styled> StyledExt for E {} impl<E: Styled> StyledExt for E {}
@@ -230,3 +244,283 @@ pub trait Sizable: Sized {
self.with_size(Size::Large) self.with_size(Size::Large)
} }
} }
/// Resolves a [`Size`] into GPUI's native rem utilities.
pub trait ControlSizing: Styled + Sized {
/// The control's height: `h_5`, `h_7`, `h_8`, `h_10`.
fn control_height(self, size: Size) -> Self;
/// The control's square width: `w_5`, `w_7`, `w_8`, `w_10`.
fn control_width(self, size: Size) -> Self;
/// Horizontal padding inside a control: `px_1`, `px_2`, `px_3`, `px_4`.
fn control_padding_x(self, size: Size) -> Self;
/// Tight horizontal padding: `px_1`, `px_2`, `px_2`, `px_3`.
fn control_dense_padding_x(self, size: Size) -> Self;
/// The control label size: `text_xs`, `text_xs`, `text_sm`, `text_base`.
fn control_text(self, size: Size) -> Self;
/// The dense caption size: `text_xs`, `text_xs`, `text_xs`, `text_sm`.
fn control_caption_text(self, size: Size) -> Self;
/// The selection indicator side: `size_2p5`, `size_3p5`, `size_4`, `size_5`.
fn control_indicator(self, size: Size) -> Self;
/// The inset to a raised inner plate: `p_0`, `p_0p5`, `p_0p5`, `p_1`.
fn control_plate_inset(self, size: Size) -> Self;
/// The avatar side: `size_5`, `size_5`, `size_6`, `size_8`.
fn avatar_size(self, size: Size) -> Self;
/// The switch track height: `h_3p5`, `h_5`, `h_5`, `h_6`.
fn switch_track_height(self, size: Size) -> Self;
/// The switch track width: `w_6`, `w_8`, `w_9`, `w_11`.
fn switch_track_width(self, size: Size) -> Self;
/// The switch knob side: `size_2`, `size_3`, `size_3p5`, `size_5`.
fn switch_knob(self, size: Size) -> Self;
}
impl<E: Styled> ControlSizing for E {
fn control_height(self, size: Size) -> Self {
match size {
Size::XSmall => self.h_5(),
Size::Small => self.h_7(),
Size::Medium => self.h_8(),
Size::Large => self.h_10(),
}
}
fn control_width(self, size: Size) -> Self {
match size {
Size::XSmall => self.w_5(),
Size::Small => self.w_7(),
Size::Medium => self.w_8(),
Size::Large => self.w_10(),
}
}
fn control_padding_x(self, size: Size) -> Self {
match size {
Size::XSmall => self.px_1(),
Size::Small => self.px_2(),
Size::Medium => self.px_3(),
Size::Large => self.px_4(),
}
}
fn control_dense_padding_x(self, size: Size) -> Self {
match size {
Size::XSmall => self.px_1(),
Size::Small => self.px_2(),
Size::Medium => self.px_2(),
Size::Large => self.px_3(),
}
}
fn control_text(self, size: Size) -> Self {
match size {
Size::XSmall => self.text_xs(),
Size::Small => self.text_xs(),
Size::Medium => self.text_sm(),
Size::Large => self.text_base(),
}
}
fn control_caption_text(self, size: Size) -> Self {
match size {
Size::XSmall => self.text_xs(),
Size::Small => self.text_xs(),
Size::Medium => self.text_xs(),
Size::Large => self.text_sm(),
}
}
fn control_indicator(self, size: Size) -> Self {
match size {
Size::XSmall => self.size_2p5(),
Size::Small => self.size_3p5(),
Size::Medium => self.size_4(),
Size::Large => self.size_5(),
}
}
fn control_plate_inset(self, size: Size) -> Self {
match size {
Size::XSmall => self.p_0(),
Size::Small => self.p_0p5(),
Size::Medium => self.p_0p5(),
Size::Large => self.p_1(),
}
}
fn avatar_size(self, size: Size) -> Self {
match size {
Size::XSmall => self.size_5(),
Size::Small => self.size_5(),
Size::Medium => self.size_6(),
Size::Large => self.size_8(),
}
}
fn switch_track_height(self, size: Size) -> Self {
match size {
Size::XSmall => self.h_3p5(),
Size::Small => self.h_5(),
Size::Medium => self.h_5(),
Size::Large => self.h_6(),
}
}
fn switch_track_width(self, size: Size) -> Self {
match size {
Size::XSmall => self.w_6(),
Size::Small => self.w_8(),
Size::Medium => self.w_9(),
Size::Large => self.w_11(),
}
}
fn switch_knob(self, size: Size) -> Self {
match size {
Size::XSmall => self.size_2(),
Size::Small => self.size_3(),
Size::Medium => self.size_3p5(),
Size::Large => self.size_5(),
}
}
}
impl Size {
/// The control height in rems; paints use the pixels this yields.
pub fn control_height_rems(self) -> Rems {
match self {
Size::XSmall => rems(1.25),
Size::Small => rems(1.75),
Size::Medium => rems(2.0),
Size::Large => rems(2.5),
}
}
/// The horizontal control padding in rems.
pub fn padding_x_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.25),
Size::Small => rems(0.5),
Size::Medium => rems(0.75),
Size::Large => rems(1.0),
}
}
/// The tight horizontal control padding in rems.
pub fn dense_padding_x_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.25),
Size::Small => rems(0.5),
Size::Medium => rems(0.5),
Size::Large => rems(0.75),
}
}
/// The label text size in rems, for geometry that layers on the text.
pub fn text_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.75),
Size::Small => rems(0.75),
Size::Medium => rems(0.875),
Size::Large => rems(1.0),
}
}
/// The icon side in rems.
pub fn icon_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.625),
Size::Small => rems(0.875),
Size::Medium => rems(1.0),
Size::Large => rems(1.25),
}
}
/// The icon side for icons inline with dense rows in rems.
pub fn dense_icon_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.5),
Size::Small => rems(0.75),
Size::Medium => rems(0.75),
Size::Large => rems(1.0),
}
}
/// The selection indicator side in rems.
pub fn indicator_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.625),
Size::Small => rems(0.875),
Size::Medium => rems(1.0),
Size::Large => rems(1.25),
}
}
/// The avatar side in rems.
pub fn avatar_rems(self) -> Rems {
match self {
Size::XSmall => rems(1.25),
Size::Small => rems(1.25),
Size::Medium => rems(1.5),
Size::Large => rems(2.0),
}
}
/// The inset between a control's edge and a raised plate in rems.
pub fn plate_inset_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.0),
Size::Small => rems(0.125),
Size::Medium => rems(0.125),
Size::Large => rems(0.25),
}
}
/// The switch track height in rems.
pub fn switch_track_height_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.875),
Size::Small => rems(1.25),
Size::Medium => rems(1.25),
Size::Large => rems(1.5),
}
}
/// The switch track width in rems.
pub fn switch_track_width_rems(self) -> Rems {
match self {
Size::XSmall => rems(1.5),
Size::Small => rems(2.0),
Size::Medium => rems(2.25),
Size::Large => rems(2.75),
}
}
/// The switch knob side in rems.
pub fn switch_knob_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.5),
Size::Small => rems(0.75),
Size::Medium => rems(0.875),
Size::Large => rems(1.25),
}
}
/// The slider row height in rems.
pub fn slider_row_rems(self) -> Rems {
match self {
Size::XSmall => rems(1.5),
Size::Small => rems(2.25),
Size::Medium => rems(2.5),
Size::Large => rems(3.0),
}
}
/// The slider track height in rems.
pub fn slider_track_rems(self) -> Rems {
match self {
Size::XSmall => rems(0.125),
Size::Small => rems(0.25),
Size::Medium => rems(0.25),
Size::Large => rems(0.375),
}
}
}
+8 -7
View File
@@ -26,10 +26,10 @@ use std::rc::Rc;
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, InteractiveElement,
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, RenderOnce, Role, ScrollHandle,
RenderOnce, Role, ScrollHandle, SharedString, StatefulInteractiveElement as _, StyleRefinement, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, canvas,
Styled as _, Window, canvas, deferred, div, ease_out_quint, relative, deferred, div, ease_out_quint, relative,
}; };
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
@@ -38,7 +38,7 @@ use crate::components::grain::grain;
use crate::components::scroll_area::ScrollArea; use crate::components::scroll_area::ScrollArea;
use crate::icons::IconRole; use crate::icons::IconRole;
use crate::layout::h_flex; use crate::layout::h_flex;
use crate::theme::{ActiveTheme as _, DIALOG_MIN_WIDTH, TextRole, Typeset as _}; use crate::theme::{ActiveTheme as _, DIALOG_MIN_WIDTH};
/// Requests the dialog's close: `false` closes. /// Requests the dialog's close: `false` closes.
pub type ChangeHandler = Rc<dyn Fn(bool, &mut Window, &mut App)>; pub type ChangeHandler = Rc<dyn Fn(bool, &mut Window, &mut App)>;
@@ -336,13 +336,14 @@ impl RenderOnce for Dialog {
.px_2() .px_2()
.gap_2() .gap_2()
.justify_between() .justify_between()
.child(div().size_5()) .when(show_close, |row| row.child(div().w_7()))
.when_some(self.title.clone(), |row, title| { .when_some(self.title.clone(), |row, title| {
row.child( row.child(
div() div()
.flex_1() .flex_1()
.text_center() .text_center()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.child(title), .child(title),
) )
}) })
+7 -7
View File
@@ -33,7 +33,7 @@ use gpui::{
App, Context, ElementId, HighlightStyle, InteractiveElement as _, IntoElement, App, Context, ElementId, HighlightStyle, InteractiveElement as _, IntoElement,
ListHorizontalSizingBehavior, ParentElement as _, Pixels, Render, ScrollStrategy, SharedString, ListHorizontalSizingBehavior, ParentElement as _, Pixels, Render, ScrollStrategy, SharedString,
StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle, Window, div, StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle, Window, div,
point, uniform_list, point, rems, uniform_list,
}; };
use similar::{Change, ChangeTag, TextDiff}; use similar::{Change, ChangeTag, TextDiff};
@@ -459,9 +459,8 @@ impl DiffViewState {
} }
impl Render for DiffViewState { impl Render for DiffViewState {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme(); let text_size = rems(0.75).to_pixels(window.rem_size());
let text_size = theme.sizes.small.text_size;
let id = self.id.clone(); let id = self.id.clone();
let state = cx.entity(); let state = cx.entity();
@@ -479,6 +478,7 @@ impl Render for DiffViewState {
&diff.row_layouts[row_index], &diff.row_layouts[row_index],
row_index, row_index,
options, options,
text_size,
cx, cx,
) )
}) })
@@ -497,7 +497,7 @@ impl Render for DiffViewState {
.id((id.clone(), "view")) .id((id.clone(), "view"))
.relative() .relative()
.size_full() .size_full()
.text_size(text_size) .text_xs()
.when_some(self.a11y_label.clone(), |view, label| { .when_some(self.a11y_label.clone(), |view, label| {
view.aria_label(label) view.aria_label(label)
}) })
@@ -518,13 +518,13 @@ fn render_row(
layout: &RowLayout, layout: &RowLayout,
row_index: usize, row_index: usize,
options: DiffViewOptions, options: DiffViewOptions,
text_size: Pixels,
cx: &App, cx: &App,
) -> gpui::AnyElement { ) -> gpui::AnyElement {
let theme = cx.theme(); let theme = cx.theme();
let mono_font = theme.mono_font; let mono_font = theme.mono_font;
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let text_size = theme.sizes.small.text_size;
let line_height = text_size * 1.5; let line_height = text_size * 1.5;
let char_width = text_size * MONO_ADVANCE_RATIO; let char_width = text_size * MONO_ADVANCE_RATIO;
@@ -534,7 +534,7 @@ fn render_row(
.w_full() .w_full()
.h(line_height) .h(line_height)
.font_family(mono_font) .font_family(mono_font)
.text_size(text_size) .text_xs()
.overflow_hidden(); .overflow_hidden();
if row.kind == DiffRowKind::Hunk { if row.kind == DiffRowKind::Hunk {
+11 -14
View File
@@ -24,7 +24,9 @@ use gpui::{
}; };
use crate::components::button::ButtonVariant; use crate::components::button::ButtonVariant;
use crate::components::common::{Sizable, StyledExt as _, focus_handle, focus_ring, h_flex}; use crate::components::common::{
ControlSizing, Sizable, StyledExt as _, focus_handle, focus_ring, h_flex,
};
use crate::components::menu::{ use crate::components::menu::{
ChangeHandler, MenuChrome, MenuItem, MenuPanelSpec, TriggerBoundsCell, anchored_menu_panel, ChangeHandler, MenuChrome, MenuItem, MenuPanelSpec, TriggerBoundsCell, anchored_menu_panel,
}; };
@@ -193,7 +195,6 @@ impl RenderOnce for DropdownMenu {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = theme.sizes.resolve(self.size);
let radius = theme.radius.control; let radius = theme.radius.control;
let ring = colors.ring; let ring = colors.ring;
@@ -277,16 +278,12 @@ impl RenderOnce for DropdownMenu {
.when(icon_only, |zone| zone.w_full()) .when(icon_only, |zone| zone.w_full())
.gap_2() .gap_2()
.line_height(relative(1.0)) .line_height(relative(1.0))
.text_size(metrics.text_size) .control_text(self.size)
.text_color(foreground) .text_color(foreground)
.role(Role::Button) .role(Role::Button)
.when_some(a11y_label, |zone, label| zone.aria_label(label)) .when_some(a11y_label, |zone, label| zone.aria_label(label))
.aria_expanded(self.open) .aria_expanded(self.open)
.px(if icon_only { .when(!icon_only, |zone| zone.control_padding_x(self.size))
gpui::Pixels::ZERO
} else {
metrics.padding_x
})
.when(split, |zone| zone.rounded_l(radius)) .when(split, |zone| zone.rounded_l(radius))
.when(!split, |zone| { .when(!split, |zone| {
zone.rounded(radius) zone.rounded(radius)
@@ -295,7 +292,7 @@ impl RenderOnce for DropdownMenu {
.when(!icon_only && !split, |zone| { .when(!icon_only && !split, |zone| {
zone.child( zone.child(
icon(IconRole::ChevronDown) icon(IconRole::ChevronDown)
.size(metrics.dense_icon_size) .size(self.size.dense_icon_rems())
.color(foreground), .color(foreground),
) )
}) })
@@ -304,7 +301,7 @@ impl RenderOnce for DropdownMenu {
.gap_2() .gap_2()
.when(self.loading, |content| content.invisible()) .when(self.loading, |content| content.invisible())
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size).color(foreground)) content.child(icon.size(self.size.icon_rems()).color(foreground))
}) })
.when_some(self.label, |content, label| content.child(label)), .when_some(self.label, |content, label| content.child(label)),
) )
@@ -361,7 +358,7 @@ impl RenderOnce for DropdownMenu {
}) })
.relative() .relative()
.h_full() .h_full()
.px(metrics.dense_padding_x) .control_dense_padding_x(self.size)
.rounded_r(radius) .rounded_r(radius)
.rounded_l_none() .rounded_l_none()
.border_l_1() .border_l_1()
@@ -374,7 +371,7 @@ impl RenderOnce for DropdownMenu {
}) })
.child( .child(
icon(IconRole::ChevronDown) icon(IconRole::ChevronDown)
.size(metrics.dense_icon_size) .size(self.size.dense_icon_rems())
.color(foreground), .color(foreground),
) )
.child( .child(
@@ -394,8 +391,8 @@ impl RenderOnce for DropdownMenu {
let id = self.id.clone(); let id = self.id.clone();
move || format!("{id}-trigger") move || format!("{id}-trigger")
}) })
.h(metrics.control_height) .control_height(self.size)
.when(icon_only, |trigger| trigger.w(metrics.control_height)) .when(icon_only, |trigger| trigger.control_width(self.size))
.rounded(radius) .rounded(radius)
.border_1() .border_1()
.border_color(border) .border_color(border)
+6 -12
View File
@@ -12,12 +12,12 @@
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _, App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _,
Window, div, Window, div, rems,
}; };
use crate::components::common::{StyledExt, v_flex}; use crate::components::common::{StyledExt, v_flex};
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, Size, TextRole, Typeset as _}; use crate::theme::ActiveTheme as _;
/// The centered "nothing here yet" panel for lists, tables, and searches. /// The centered "nothing here yet" panel for lists, tables, and searches.
#[derive(IntoElement)] #[derive(IntoElement)]
@@ -82,10 +82,8 @@ impl gpui::Styled for EmptyState {
impl RenderOnce for EmptyState { impl RenderOnce for EmptyState {
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(Size::Medium);
let muted_foreground = theme.colors.muted_foreground; let muted_foreground = theme.colors.muted_foreground;
let foreground = theme.colors.foreground; let foreground = theme.colors.foreground;
let illustration = metrics.icon_size * 2.0;
v_flex() v_flex()
.w_full() .w_full()
@@ -97,22 +95,18 @@ impl RenderOnce for EmptyState {
state.child( state.child(
div() div()
.mb_2() .mb_2()
.child(icon.size(illustration).color(muted_foreground)), .child(icon.size(rems(2.0)).color(muted_foreground)),
) )
}) })
.child( .child(
div() div()
.typeset(TextRole::Title3, cx) .text_base()
.font_semibold()
.text_color(foreground) .text_color(foreground)
.child(self.headline), .child(self.headline),
) )
.when_some(self.hint, |state, hint| { .when_some(self.hint, |state, hint| {
state.child( state.child(div().text_sm().text_color(muted_foreground).child(hint))
div()
.typeset(TextRole::Subheadline, cx)
.text_color(muted_foreground)
.child(hint),
)
}) })
.when_some(self.action, |state, action| { .when_some(self.action, |state, action| {
state.child(div().mt_3().child(action)) state.child(div().mt_3().child(action))
+5 -8
View File
@@ -19,7 +19,7 @@ use gpui::{
}; };
use crate::components::common::{StyledExt, h_flex, v_flex}; use crate::components::common::{StyledExt, h_flex, v_flex};
use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; use crate::theme::ActiveTheme as _;
/// The arrangement of a [`Field`]'s label and control. /// The arrangement of a [`Field`]'s label and control.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -102,7 +102,6 @@ impl Styled for Field {
impl RenderOnce for Field { impl RenderOnce for Field {
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.medium;
let error_color = theme.ramps.destructive.base; let error_color = theme.ramps.destructive.base;
let id = self.id.clone(); let id = self.id.clone();
@@ -112,11 +111,9 @@ impl RenderOnce for Field {
move || format!("{id}-label") move || format!("{id}-label")
}) })
.when(self.description.is_some(), |title| { .when(self.description.is_some(), |title| {
title.typeset(TextRole::Headline, cx) title.text_sm().font_semibold()
})
.when(self.description.is_none(), |title| {
title.typeset(TextRole::Callout, cx)
}) })
.when(self.description.is_none(), |title| title.text_sm())
.child(self.label.clone()); .child(self.label.clone());
let control = h_flex() let control = h_flex()
@@ -134,14 +131,14 @@ impl RenderOnce for Field {
let id = id.clone(); let id = id.clone();
move || format!("{id}-error") move || format!("{id}-error")
}) })
.text_size(metrics.caption_size) .text_xs()
.text_color(error_color) .text_color(error_color)
.child(error) .child(error)
}); });
let description_text = |cx: &App| { let description_text = |cx: &App| {
div() div()
.text_size(metrics.caption_size) .text_xs()
.text_color(cx.theme().colors.muted_foreground) .text_color(cx.theme().colors.muted_foreground)
}; };
+19 -15
View File
@@ -38,7 +38,7 @@ use gpui::{
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
use crate::components::common::{Sizable, StyledExt as _, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, h_flex};
use crate::icons::IconRole; use crate::icons::IconRole;
use crate::theme::{ use crate::theme::{
ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH, ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH,
@@ -2017,7 +2017,11 @@ impl RenderOnce for Input {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let radius = theme.radius; let radius = theme.radius;
let metrics = theme.sizes.resolve(self.size); let rem = window.rem_size();
let input_height = self.size.control_height_rems().to_pixels(rem);
let text_size = self.size.text_rems().to_pixels(rem);
let padding_x = self.size.padding_x_rems().to_pixels(rem);
let dense_padding_x = self.size.dense_padding_x_rems().to_pixels(rem);
let focus_handle = self.state.read(cx).focus_handle.clone(); let focus_handle = self.state.read(cx).focus_handle.clone();
let focused = focus_handle.is_focused(window); let focused = focus_handle.is_focused(window);
@@ -2027,17 +2031,17 @@ impl RenderOnce for Input {
let multiline = self.state.read(cx).is_multiline(); let multiline = self.state.read(cx).is_multiline();
let recording = focused && !self.disabled && !self.state.read(cx).is_read_only(); let recording = focused && !self.disabled && !self.state.read(cx).is_read_only();
let small = theme.sizes.resolve(Size::Small); let docked_height = Size::Small.control_height_rems().to_pixels(rem);
let docked_height = small.control_height; let edge_inset = ((input_height - docked_height) / 2.0).max(Pixels::ZERO);
let edge_inset = ((metrics.input_height - docked_height) / 2.0).max(Pixels::ZERO);
let vertical_inset = metrics.dense_padding_x * 0.5; let vertical_inset = dense_padding_x * 0.5;
let reveal_width = small.dense_padding_x * 2.0 + small.icon_size; let reveal_width = Size::Small.dense_padding_x_rems().to_pixels(rem) * 2.0
+ Size::Small.icon_rems().to_pixels(rem);
let field_padding = FieldPadding { let field_padding = FieldPadding {
left: Pixels::ZERO, left: Pixels::ZERO,
right: if is_password { right: if is_password {
(edge_inset + reveal_width - metrics.dense_padding_x).max(Pixels::ZERO) (edge_inset + reveal_width - dense_padding_x).max(Pixels::ZERO)
} else { } else {
Pixels::ZERO Pixels::ZERO
}, },
@@ -2045,11 +2049,11 @@ impl RenderOnce for Input {
}; };
let line_height = multiline.then(|| match window.text_style().line_height { let line_height = multiline.then(|| match window.text_style().line_height {
DefiniteLength::Fraction(ratio) => metrics.text_size * ratio, DefiniteLength::Fraction(ratio) => text_size * ratio,
DefiniteLength::Absolute(length) => length.to_pixels(window.rem_size()), DefiniteLength::Absolute(length) => length.to_pixels(window.rem_size()),
}); });
let field_height = line_height.map_or(metrics.input_height, |line_height| { let field_height = line_height.map_or(input_height, |line_height| {
line_height * self.rows as f32 + vertical_inset * 2.0 line_height * self.rows as f32 + vertical_inset * 2.0
}); });
@@ -2176,14 +2180,14 @@ impl RenderOnce for Input {
.w_full() .w_full()
.h(field_height) .h(field_height)
.pl(if self.prefix.is_some() { .pl(if self.prefix.is_some() {
metrics.padding_x padding_x
} else { } else {
metrics.dense_padding_x dense_padding_x
}) })
.pr(if self.suffix.is_some() { .pr(if self.suffix.is_some() {
metrics.padding_x padding_x
} else { } else {
metrics.dense_padding_x dense_padding_x
}) })
.gap_2() .gap_2()
.rounded(if self.fully_rounded { .rounded(if self.fully_rounded {
@@ -2192,7 +2196,7 @@ impl RenderOnce for Input {
radius.control radius.control
}) })
.bg(colors.input) .bg(colors.input)
.text_size(metrics.text_size) .control_text(self.size)
.text_color(colors.foreground) .text_color(colors.foreground)
.border_1() .border_1()
.border_color(colors.border) .border_color(colors.border)
+4 -4
View File
@@ -14,9 +14,9 @@
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
Action, AnyElement, App, FocusHandle, FontWeight, InteractiveElement as _, IntoElement, Action, AnyElement, App, FocusHandle, InteractiveElement as _, IntoElement, KeyBinding,
KeyBinding, KeyContext, Keystroke, OperatingSystem, ParentElement as _, RenderOnce, KeyContext, Keystroke, OperatingSystem, ParentElement as _, RenderOnce, SharedString,
SharedString, StyleRefinement, Styled as _, Window, div, relative, StyleRefinement, Styled as _, Window, div, relative,
}; };
use crate::components::common::{StyledExt as _, h_flex}; use crate::components::common::{StyledExt as _, h_flex};
@@ -267,7 +267,7 @@ impl RenderOnce for Kbd {
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.text_center() .text_center()
.line_height(relative(1.)) .line_height(relative(1.))
.text_size(theme.typography.caption.size) .text_xs()
}) })
.refine_style(&self.style) .refine_style(&self.style)
.child(label) .child(label)
+3 -3
View File
@@ -21,7 +21,7 @@ use gpui::{
Window, Window,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex};
use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
/// The handler called with the [`gpui::ClickEvent`], replacing the default `href` opening. /// The handler called with the [`gpui::ClickEvent`], replacing the default `href` opening.
@@ -119,7 +119,7 @@ impl RenderOnce for Link {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let on_click = self.on_click; let on_click = self.on_click;
let href = self.href; let href = self.href;
@@ -127,7 +127,7 @@ impl RenderOnce for Link {
h_flex() h_flex()
.id(self.id) .id(self.id)
.text_size(metrics.text_size) .control_text(size)
.text_color(ramps.primary.base) .text_color(ramps.primary.base)
.underline() .underline()
.refine_style(&self.style) .refine_style(&self.style)
+6 -7
View File
@@ -22,14 +22,14 @@ use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent, AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent,
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
StyleRefinement, Styled as _, Window, div, StyleRefinement, Styled as _, Window, div, rems,
}; };
use crate::components::common::{ use crate::components::common::{
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color, StyledExt as _, nav_key, paint_selectable_row, selectable_label_color,
}; };
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; use crate::theme::ActiveTheme as _;
/// The change reporter, fired with the next selection by pointer and keys. /// The change reporter, fired with the next selection by pointer and keys.
type ChangeHandler = Rc<dyn Fn(Option<usize>, &mut Window, &mut App)>; type ChangeHandler = Rc<dyn Fn(Option<usize>, &mut Window, &mut App)>;
@@ -173,7 +173,6 @@ impl RenderOnce for List {
.collect(); .collect();
let focus = crate::components::common::focus_handle(&self.id, window, cx); let focus = crate::components::common::focus_handle(&self.id, window, cx);
let theme = cx.theme();
let label = self let label = self
.a11y_label .a11y_label
@@ -200,7 +199,7 @@ impl RenderOnce for List {
.flex() .flex()
.flex_col() .flex_col()
.gap_0p5() .gap_0p5()
.text_size(theme.sizes.medium.text_size) .text_sm()
.refine_style(&self.style) .refine_style(&self.style)
.track_focus(&focus) .track_focus(&focus)
.focusable() .focusable()
@@ -246,7 +245,7 @@ impl ListItem {
.gap_2() .gap_2()
.px_2() .px_2()
.py_1() .py_1()
.min_h(theme.sizes.medium.control_height) .min_h_8()
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.role(Role::ListItem) .role(Role::ListItem)
.aria_selected(selected) .aria_selected(selected)
@@ -266,7 +265,7 @@ impl ListItem {
}) })
}) })
.when_some(self.icon.clone(), |row, icon| { .when_some(self.icon.clone(), |row, icon| {
row.child(icon.size(theme.sizes.medium.icon_size).color(label_color)) row.child(icon.size(rems(1.0)).color(label_color))
}) })
.child( .child(
div() div()
@@ -278,7 +277,7 @@ impl ListItem {
row.child( row.child(
div() div()
.flex_none() .flex_none()
.typeset(TextRole::Subheadline, cx) .text_sm()
.text_color(if selected { .text_color(if selected {
theme.colors.primary_foreground theme.colors.primary_foreground
} else { } else {
+50 -114
View File
@@ -34,42 +34,25 @@ use std::sync::Arc;
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle, AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle,
GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _, InteractiveText, FontWeight, GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _,
IntoElement, KeyBinding, KeyBindingContextPredicate, LayoutId, ListAlignment, ListOffset, InteractiveText, IntoElement, KeyBinding, KeyBindingContextPredicate, LayoutId, ListAlignment,
ListState, MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels, ListOffset, ListState, MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit,
Refineable as _, Render, SharedString, StatefulInteractiveElement as _, StrikethroughStyle, ParentElement as _, Pixels, Refineable as _, Rems, Render, SharedString,
StyleRefinement, Styled, StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window, StatefulInteractiveElement as _, StrikethroughStyle, StyleRefinement, Styled, StyledImage as _,
actions, div, img, list, px, relative, StyledText, TextLayout, UnderlineStyle, Window, actions, div, img, list, px, relative, rems,
}; };
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd}; use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
use crate::components::checkbox::Checkbox; use crate::components::checkbox::Checkbox;
use crate::components::common::Sizable as _; use crate::components::common::{Sizable as _, StyledExt as _};
use crate::components::highlight::{HighlightedCode, Language, highlight, plain}; use crate::components::highlight::{HighlightedCode, Language, highlight, plain};
use crate::components::scrollbar::{Scrollbar, ScrollbarVisibility}; use crate::components::scrollbar::{Scrollbar, ScrollbarVisibility};
use crate::components::utils::code_line; use crate::components::utils::code_line;
use crate::theme::{ use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size};
ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size, TextRole,
Typeset as _,
};
/// The bottom padding between sibling blocks, in root font sizes.
const BLOCK_GAP: f32 = 0.75;
/// The tighter bottom padding between list items, in root font sizes.
const ITEM_GAP: f32 = 0.2;
/// The room a list marker column takes, in root font sizes.
const MARKER_WIDTH: f32 = 1.75;
/// The text inset behind a quote bar, in root font sizes.
const QUOTE_INSET: f32 = 1.0;
/// The indent each list level adds, in root font sizes.
const INDENT_STEP: f32 = 1.5;
/// The body line height. /// The body line height.
const BODY_LINE_HEIGHT: f32 = 1.6; const BODY_LINE_HEIGHT: f32 = 1.6;
/// The tallest a standalone image renders, in root font sizes.
const IMAGE_MAX_HEIGHT: f32 = 14.0;
/// The side of an inline image atom relative to the body text size.
const INLINE_IMAGE_SCALE: f32 = 1.15;
/// The key context the text view declares while it holds focus. /// The key context the text view declares while it holds focus.
pub const TEXT_VIEW_CONTEXT: &str = "TextView"; pub const TEXT_VIEW_CONTEXT: &str = "TextView";
@@ -1431,8 +1414,7 @@ fn render_block(
ctx: &BlockContext, ctx: &BlockContext,
cx: &App, cx: &App,
) -> AnyElement { ) -> AnyElement {
let theme = cx.theme(); let gap = rems(0.75);
let gap = theme.root_font_size * BLOCK_GAP;
match block { match block {
MarkdownBlock::Heading { MarkdownBlock::Heading {
@@ -1445,7 +1427,11 @@ fn render_block(
spans, spans,
*indent, *indent,
*quote, *quote,
if block_index == 0 { px(0.) } else { gap * 0.5 }, if block_index == 0 {
Rems::ZERO
} else {
rems(0.375)
},
ctx, ctx,
cx, cx,
), ),
@@ -1459,15 +1445,7 @@ fn render_block(
items, items,
indent, indent,
quote, quote,
} => text_row( } => text_row(items, *indent, *quote, rems(0.2), Some(*marker), ctx, cx),
items,
*indent,
*quote,
theme.root_font_size * ITEM_GAP,
Some(*marker),
ctx,
cx,
),
MarkdownBlock::Image { MarkdownBlock::Image {
source, source,
alt, alt,
@@ -1490,7 +1468,7 @@ fn render_block(
} }
/// The shared block frame: ambient text style, spacing, quote bar. /// The shared block frame: ambient text style, spacing, quote bar.
fn block_frame(quote: bool, top: Pixels, bottom: Pixels, id: &ElementId, cx: &App) -> Div { fn block_frame(quote: bool, top: Rems, bottom: Rems, id: &ElementId, cx: &App) -> Div {
let theme = cx.theme(); let theme = cx.theme();
div() div()
.debug_selector({ .debug_selector({
@@ -1501,25 +1479,25 @@ fn block_frame(quote: bool, top: Pixels, bottom: Pixels, id: &ElementId, cx: &Ap
.flex() .flex()
.flex_col() .flex_col()
.font_family(".SystemUIFont") .font_family(".SystemUIFont")
.text_size(theme.sizes.small.text_size) .text_xs()
.line_height(relative(BODY_LINE_HEIGHT)) .line_height(relative(BODY_LINE_HEIGHT))
.text_color(theme.colors.foreground) .text_color(theme.colors.foreground)
.pt(top) .pt(top)
.pb(bottom) .pb(bottom)
.when(quote, |frame| { .when(quote, |frame| {
frame frame
.border_l(BORDER_WIDTH * 2.0) .border_l_2()
.border_color(theme.colors.border) .border_color(theme.colors.border)
.pl(theme.root_font_size * QUOTE_INSET) .pl(rems(1.0))
}) })
} }
/// Wraps the finished block in the list indent. /// Wraps the finished block in the list indent.
fn indented_frame(indent: usize, frame: Div, cx: &App) -> Div { fn indented_frame(indent: usize, frame: Div) -> Div {
let indent_px = cx.theme().root_font_size * INDENT_STEP * indent as f32; let indent = rems(1.5 * indent as f32);
if indent_px > px(0.) { if indent.0 > 0.0 {
div().w_full().pl(indent_px).child(frame) div().w_full().pl(indent).child(frame)
} else { } else {
frame frame
} }
@@ -1531,30 +1509,23 @@ fn heading_row(
spans: &[InlineSpan], spans: &[InlineSpan],
indent: usize, indent: usize,
quote: bool, quote: bool,
top: Pixels, top: Rems,
ctx: &BlockContext, ctx: &BlockContext,
cx: &App, cx: &App,
) -> AnyElement { ) -> AnyElement {
let theme = cx.theme(); let frame = block_frame(quote, top, rems(0.75), ctx.block_id, cx);
let role = match level { let frame = match level {
MarkdownHeading::H1 => TextRole::Title, MarkdownHeading::H1 => frame.text_xl().font_semibold(),
MarkdownHeading::H2 => TextRole::Title2, MarkdownHeading::H2 => frame.text_lg().font_semibold(),
MarkdownHeading::H3 => TextRole::Title3, MarkdownHeading::H3 => frame.text_base().font_semibold(),
MarkdownHeading::H4 | MarkdownHeading::H5 | MarkdownHeading::H6 => TextRole::Headline, MarkdownHeading::H4 | MarkdownHeading::H5 | MarkdownHeading::H6 => {
frame.text_sm().font_semibold()
}
}; };
indented_frame( indented_frame(
indent, indent,
block_frame( frame.child(text_child(spans, ctx.block_id, ctx.piece_context(0), cx)),
quote,
top,
theme.root_font_size * BLOCK_GAP,
ctx.block_id,
cx,
)
.typeset(role, cx)
.child(text_child(spans, ctx.block_id, ctx.piece_context(0), cx)),
cx,
) )
.into_any_element() .into_any_element()
} }
@@ -1563,7 +1534,7 @@ fn text_row(
items: &[InlineItem], items: &[InlineItem],
indent: usize, indent: usize,
quote: bool, quote: bool,
bottom: Pixels, bottom: Rems,
marker: Option<ListMarker>, marker: Option<ListMarker>,
ctx: &BlockContext, ctx: &BlockContext,
cx: &App, cx: &App,
@@ -1572,12 +1543,12 @@ fn text_row(
indented_frame( indented_frame(
indent, indent,
block_frame(quote, px(0.), bottom, ctx.block_id, cx).map(|frame| match marker { block_frame(quote, Rems::ZERO, bottom, ctx.block_id, cx).map(|frame| match marker {
Some(marker) => { Some(marker) => {
let line_height = theme.sizes.small.text_size * BODY_LINE_HEIGHT; let line_height = rems(1.2);
let marker_cell = div() let marker_cell = div()
.flex_none() .flex_none()
.w(theme.root_font_size * MARKER_WIDTH) .w(rems(1.75))
.h(line_height) .h(line_height)
.flex() .flex()
.items_center() .items_center()
@@ -1608,7 +1579,6 @@ fn text_row(
} }
None => frame.child(paragraph_child(items, ctx, cx)), None => frame.child(paragraph_child(items, ctx, cx)),
}), }),
cx,
) )
.into_any_element() .into_any_element()
} }
@@ -1658,8 +1628,7 @@ fn paragraph_child(items: &[InlineItem], ctx: &BlockContext, cx: &App) -> AnyEle
return text_child(spans, ctx.block_id, ctx.piece_context(0), cx); return text_child(spans, ctx.block_id, ctx.piece_context(0), cx);
} }
let theme = cx.theme(); let side = rems(0.8625);
let side = theme.sizes.small.text_size * INLINE_IMAGE_SCALE;
let mut flow = div().flex().flex_wrap().items_center(); let mut flow = div().flex().flex_wrap().items_center();
let mut segment: Vec<&InlineSpan> = Vec::new(); let mut segment: Vec<&InlineSpan> = Vec::new();
let mut segment_index = 0; let mut segment_index = 0;
@@ -1709,21 +1678,13 @@ fn image_row(
let theme = cx.theme(); let theme = cx.theme();
indented_frame( indented_frame(
indent, indent,
block_frame( block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(
quote,
px(0.),
theme.root_font_size * BLOCK_GAP,
ctx.block_id,
cx,
)
.child(
img(source.clone()) img(source.clone())
.max_h(theme.root_font_size * IMAGE_MAX_HEIGHT) .max_h(rems(14.0))
.max_w_full() .max_w_full()
.rounded(theme.radius.control) .rounded(theme.radius.control)
.overflow_hidden(), .overflow_hidden(),
), ),
cx,
) )
.id((ctx.block_id.clone(), "image")) .id((ctx.block_id.clone(), "image"))
.when(!alt.is_empty(), |frame| frame.aria_label(alt.clone())) .when(!alt.is_empty(), |frame| frame.aria_label(alt.clone()))
@@ -1744,7 +1705,7 @@ fn code_row(
cx: &App, cx: &App,
) -> AnyElement { ) -> AnyElement {
let theme = cx.theme(); let theme = cx.theme();
let text_size = theme.sizes.small.text_size; let text_size = rems(0.75).to_pixels(theme.root_font_size);
let line_height = text_size * CODE_LINE_HEIGHT; let line_height = text_size * CODE_LINE_HEIGHT;
let plain = lines let plain = lines
.lines .lines
@@ -1761,7 +1722,7 @@ fn code_row(
.when_some(language.cloned(), |row, language| { .when_some(language.cloned(), |row, language| {
row.child( row.child(
div() div()
.typeset(TextRole::Caption, cx) .text_xs()
.text_color(theme.colors.muted_foreground) .text_color(theme.colors.muted_foreground)
.child(language), .child(language),
) )
@@ -1784,7 +1745,7 @@ fn code_row(
.bg(theme.colors.muted) .bg(theme.colors.muted)
.p_2() .p_2()
.font_family(theme.mono_font) .font_family(theme.mono_font)
.text_size(text_size) .text_xs()
.line_height(relative(CODE_LINE_HEIGHT)) .line_height(relative(CODE_LINE_HEIGHT))
.overflow_hidden() .overflow_hidden()
.child(actions_row) .child(actions_row)
@@ -1804,15 +1765,7 @@ fn code_row(
indented_frame( indented_frame(
indent, indent,
block_frame( block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(plate),
quote,
px(0.),
theme.root_font_size * BLOCK_GAP,
ctx.block_id,
cx,
)
.child(plate),
cx,
) )
.into_any_element() .into_any_element()
} }
@@ -1821,15 +1774,8 @@ fn rule_row(indent: usize, quote: bool, ctx: &BlockContext, cx: &App) -> AnyElem
let theme = cx.theme(); let theme = cx.theme();
indented_frame( indented_frame(
indent, indent,
block_frame( block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx)
quote, .child(div().h_px().w_full().bg(theme.colors.border)),
px(0.),
theme.root_font_size * BLOCK_GAP,
ctx.block_id,
cx,
)
.child(div().h(BORDER_WIDTH).w_full().bg(theme.colors.border)),
cx,
) )
.into_any_element() .into_any_element()
} }
@@ -1884,9 +1830,7 @@ fn table_row(
.min_w_0() .min_w_0()
.px_2() .px_2()
.py_1() .py_1()
.when(row.header, |cell_element| { .when(row.header, |cell_element| cell_element.font_semibold())
cell_element.font_weight(theme.typography.headline.weight)
})
.child(text_child(&cell.spans, &cell_id, piece, cx)) .child(text_child(&cell.spans, &cell_id, piece, cx))
}) })
// Ragged tables pad missing cells so rows align. // Ragged tables pad missing cells so rows align.
@@ -1899,15 +1843,7 @@ fn table_row(
indented_frame( indented_frame(
indent, indent,
block_frame( block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(grid),
quote,
px(0.),
theme.root_font_size * BLOCK_GAP,
ctx.block_id,
cx,
)
.child(grid),
cx,
) )
.into_any_element() .into_any_element()
} }
@@ -2021,7 +1957,7 @@ where
InlineStyle::Strong => highlights.push(( InlineStyle::Strong => highlights.push((
range, range,
HighlightStyle { HighlightStyle {
font_weight: Some(theme.typography.headline.weight), font_weight: Some(FontWeight::SEMIBOLD),
..Default::default() ..Default::default()
}, },
)), )),
@@ -2029,7 +1965,7 @@ where
range, range,
HighlightStyle { HighlightStyle {
font_style: Some(FontStyle::Italic), font_style: Some(FontStyle::Italic),
font_weight: Some(theme.typography.headline.weight), font_weight: Some(FontWeight::SEMIBOLD),
..Default::default() ..Default::default()
}, },
)), )),
+9 -17
View File
@@ -29,13 +29,13 @@ use gpui::{
DispatchPhase, ElementId, Entity, FocusHandle, InteractiveElement as _, IntoElement, DispatchPhase, ElementId, Entity, FocusHandle, InteractiveElement as _, IntoElement,
KeyDownEvent, MouseButton, MouseDownEvent, ParentElement as _, Pixels, Point, RenderOnce, Role, KeyDownEvent, MouseButton, MouseDownEvent, ParentElement as _, Pixels, Point, RenderOnce, Role,
ScrollHandle, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, ScrollHandle, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _,
Window, anchored, canvas, deferred, div, ease_out_quint, point, px, relative, Window, anchored, canvas, deferred, div, ease_out_quint, point, px, relative, rems,
}; };
use crate::components::common::{OVERLAY_LAYER, StyledExt as _, focus_handle, v_flex}; use crate::components::common::{OVERLAY_LAYER, StyledExt as _, focus_handle, v_flex};
use crate::components::scroll_area::{ScrollArea, ScrollAxes}; use crate::components::scroll_area::{ScrollArea, ScrollAxes};
use crate::icons::{Icon, IconRole, icon as icon_glyph}; use crate::icons::{Icon, IconRole, icon as icon_glyph};
use crate::theme::{ActiveTheme as _, BORDER_WIDTH, MENU_MIN_WIDTH, POPUP_MAX_HEIGHT}; use crate::theme::{ActiveTheme as _, MENU_MIN_WIDTH, POPUP_MAX_HEIGHT};
/// Runs the item's action. The menu closes itself before the handler runs. /// Runs the item's action. The menu closes itself before the handler runs.
pub type ItemHandler = Rc<dyn Fn(&mut Window, &mut App)>; pub type ItemHandler = Rc<dyn Fn(&mut Window, &mut App)>;
@@ -201,10 +201,6 @@ pub(crate) struct MenuChrome {
destructive_foreground: gpui::Hsla, destructive_foreground: gpui::Hsla,
radius_overlay: Pixels, radius_overlay: Pixels,
radius_sm: Pixels, radius_sm: Pixels,
icon_size: Pixels,
dense_icon_size: Pixels,
menu_item_height: Pixels,
text_size: Pixels,
shadow: Vec<BoxShadow>, shadow: Vec<BoxShadow>,
} }
@@ -242,10 +238,6 @@ impl MenuChrome {
destructive_foreground: theme.colors.destructive_foreground, destructive_foreground: theme.colors.destructive_foreground,
radius_overlay: theme.radius.overlay, radius_overlay: theme.radius.overlay,
radius_sm: theme.radius.sm, radius_sm: theme.radius.sm,
icon_size: theme.sizes.medium.icon_size,
dense_icon_size: theme.sizes.medium.dense_icon_size,
menu_item_height: theme.sizes.medium.menu_item_height,
text_size: theme.sizes.medium.text_size,
shadow: theme.elevations.popover.shadows(), shadow: theme.elevations.popover.shadows(),
}, },
theme.motion.overlay, theme.motion.overlay,
@@ -813,7 +805,7 @@ fn render_item(
) -> AnyElement { ) -> AnyElement {
match &item.kind { match &item.kind {
MenuItemKind::Separator => div() MenuItemKind::Separator => div()
.h(BORDER_WIDTH) .h_px()
.debug_selector(move || format!("{}-separator-{index}", env.debug_prefix)) .debug_selector(move || format!("{}-separator-{index}", env.debug_prefix))
.mx_2() .mx_2()
.my_1() .my_1()
@@ -846,7 +838,7 @@ fn render_item(
} }
}) })
.when_some(icon, |row, icon| { .when_some(icon, |row, icon| {
row.child(icon.size(env.chrome.icon_size).color(label_color)) row.child(icon.size(rems(1.0)).color(label_color))
}) })
.child( .child(
div() div()
@@ -868,7 +860,7 @@ fn render_item(
.when(checked, |row| { .when(checked, |row| {
row.child( row.child(
icon_glyph(IconRole::Check) icon_glyph(IconRole::Check)
.size(env.chrome.dense_icon_size) .size(rems(0.75))
.color(label_color), .color(label_color),
) )
}) })
@@ -901,7 +893,7 @@ fn render_item(
) )
.child( .child(
icon_glyph(IconRole::ChevronRight) icon_glyph(IconRole::ChevronRight)
.size(chrome.dense_icon_size) .size(rems(0.75))
.color(label_color), .color(label_color),
) )
.aria_expanded(open) .aria_expanded(open)
@@ -948,7 +940,7 @@ fn render_item(
} }
} }
/// The shared row shell: metrics, highlight, and hover-selection. /// The shared row shell: dimensions, highlight, and hover-selection.
fn row_shell( fn row_shell(
cx: &App, cx: &App,
item: &MenuItem, item: &MenuItem,
@@ -972,9 +964,9 @@ fn row_shell(
.flex() .flex()
.items_center() .items_center()
.gap_2() .gap_2()
.min_h(chrome.menu_item_height) .min_h_8()
.px_4() .px_4()
.text_size(chrome.text_size) .text_sm()
.line_height(relative(1.0)) .line_height(relative(1.0))
.rounded(chrome.radius_sm) .rounded(chrome.radius_sm)
.map(|row| { .map(|row| {
+10 -11
View File
@@ -81,11 +81,17 @@ impl RenderOnce for Progress {
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let radius = theme.radius; let radius = theme.radius;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let track_height = metrics.icon_size / 4.0;
let value = self.value.clamp(0.0, 1.0); let value = self.value.clamp(0.0, 1.0);
let track = div().w_full().rounded(radius.full).bg(colors.border);
let track = match size {
Size::XSmall => track.h_0p5(),
Size::Small | Size::Medium => track.h_1(),
Size::Large => track.h_1p5(),
};
div() div()
.id(self.id) .id(self.id)
.w_full() .w_full()
@@ -100,13 +106,7 @@ impl RenderOnce for Progress {
.aria_min_numeric_value(0.0) .aria_min_numeric_value(0.0)
.aria_max_numeric_value(1.0) .aria_max_numeric_value(1.0)
}) })
.child( .child(track.child(if self.indeterminate {
div()
.w_full()
.h(track_height)
.rounded(radius.full)
.bg(colors.border)
.child(if self.indeterminate {
div() div()
.h_full() .h_full()
.w(relative(0.3)) .w(relative(0.3))
@@ -127,7 +127,6 @@ impl RenderOnce for Progress {
.rounded(radius.full) .rounded(radius.full)
.bg(ramps.primary.base) .bg(ramps.primary.base)
.into_any_element() .into_any_element()
}), }))
)
} }
} }
+14 -10
View File
@@ -19,7 +19,9 @@ use gpui::{
div, div,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex, v_flex}; use crate::components::common::{
ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex, v_flex,
};
use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
/// The group's change reporter, fired with the clicked radio's value. /// The group's change reporter, fired with the clicked radio's value.
@@ -178,7 +180,7 @@ where
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let radius = theme.radius; let radius = theme.radius;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let selected = self.selected; let selected = self.selected;
let on_change = self.on_change; let on_change = self.on_change;
let group_label = self.a11y_label; let group_label = self.a11y_label;
@@ -186,7 +188,7 @@ where
v_flex() v_flex()
.id(self.id) .id(self.id)
.gap_2() .gap_2()
.text_size(metrics.text_size) .control_text(size)
.refine_style(&self.style) .refine_style(&self.style)
.role(Role::RadioGroup) .role(Role::RadioGroup)
.when_some(group_label.clone(), |group, label| group.aria_label(label)) .when_some(group_label.clone(), |group, label| group.aria_label(label))
@@ -223,7 +225,7 @@ where
h_flex() h_flex()
.justify_center() .justify_center()
.flex_none() .flex_none()
.size(metrics.indicator_size) .control_indicator(size)
.rounded(radius.full) .rounded(radius.full)
.border_1() .border_1()
.when(is_selected, |indicator| { .when(is_selected, |indicator| {
@@ -235,12 +237,14 @@ where
.bg(ramps.primary.hover) .bg(ramps.primary.hover)
.border_color(ramps.primary.hover) .border_color(ramps.primary.hover)
}) })
.child( .child({
div() let dot = match size {
.size(metrics.indicator_size / 2.0) Size::XSmall => div().size_1p5(),
.rounded(radius.full) Size::Small | Size::Medium => div().size_2(),
.bg(colors.primary_foreground), Size::Large => div().size_2p5(),
) };
dot.rounded(radius.full).bg(colors.primary_foreground)
})
}) })
.when(!is_selected, |indicator| { .when(!is_selected, |indicator| {
indicator indicator
+11 -16
View File
@@ -22,7 +22,9 @@ use gpui::{
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window, canvas, div, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window, canvas, div,
}; };
use crate::components::common::{Sizable, StyledExt, focus_handle, focus_ring, h_flex}; use crate::components::common::{
ControlSizing, Sizable, StyledExt, focus_handle, focus_ring, h_flex,
};
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, CONTROL_SPRING, Size}; use crate::theme::{ActiveTheme as _, CONTROL_SPRING, Size};
@@ -168,7 +170,6 @@ where
{ {
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 muted = theme.colors.muted; let muted = theme.colors.muted;
let surface = theme.colors.surface; let surface = theme.colors.surface;
let foreground = theme.colors.foreground; let foreground = theme.colors.foreground;
@@ -177,12 +178,6 @@ where
let radius = theme.radius.full; let radius = theme.radius.full;
let plate_shadow = theme.elevations.control.shadows(); let plate_shadow = theme.elevations.control.shadows();
let track_height = metrics.strip_height;
let track_inset = metrics.plate_inset;
let horizontal_padding = metrics.dense_padding_x;
let text_size = metrics.text_size;
let icon_size = metrics.icon_size;
let selected_index = self let selected_index = self
.options .options
.iter() .iter()
@@ -238,9 +233,9 @@ where
.justify_center() .justify_center()
.cursor_pointer() .cursor_pointer()
.h_full() .h_full()
.px(horizontal_padding) .control_dense_padding_x(self.size)
.rounded(radius) .rounded(radius)
.text_size(text_size) .control_text(self.size)
.text_color(content_color) .text_color(content_color)
.when(!is_selected, |segment| { .when(!is_selected, |segment| {
segment.hover(|style| style.bg(surface)) segment.hover(|style| style.bg(surface))
@@ -249,7 +244,7 @@ where
.aria_label(segment.label.clone()) .aria_label(segment.label.clone())
.aria_toggled(Toggled::from(is_selected)) .aria_toggled(Toggled::from(is_selected))
.when_some(segment.icon.clone(), |segment, icon| { .when_some(segment.icon.clone(), |segment, icon| {
segment.child(icon.size(icon_size).color(content_color)) segment.child(icon.size(self.size.icon_rems()).color(content_color))
}) })
.child(segment.label.clone()) .child(segment.label.clone())
.child( .child(
@@ -296,11 +291,11 @@ where
.gap_1() .gap_1()
.relative() .relative()
.flex_none() .flex_none()
.h(track_height) .control_height(self.size)
.p(track_inset) .control_plate_inset(self.size)
.rounded(radius) .rounded(radius)
.bg(muted) .bg(muted)
.text_size(metrics.text_size) .control_text(self.size)
.child( .child(
canvas( canvas(
{ {
@@ -321,8 +316,8 @@ where
.id("segmented-plate") .id("segmented-plate")
.debug_selector(|| "segmented-plate".to_string()) .debug_selector(|| "segmented-plate".to_string())
.absolute() .absolute()
.top(track_inset) .top(self.size.plate_inset_rems())
.bottom(track_inset) .bottom(self.size.plate_inset_rems())
.rounded(radius) .rounded(radius)
.bg(surface) .bg(surface)
.shadow(plate_shadow.clone()) .shadow(plate_shadow.clone())
+7 -9
View File
@@ -20,10 +20,10 @@ use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
App, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement as _, App, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement as _,
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _,
Window, canvas, Window, canvas, rems,
}; };
use crate::components::common::{Sizable, StyledExt, focus_handle, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt, focus_handle, h_flex};
use crate::components::menu::{Menu, MenuItem}; use crate::components::menu::{Menu, MenuItem};
use crate::icons::{Icon, IconRole, icon}; use crate::icons::{Icon, IconRole, icon};
use crate::theme::{ActiveTheme as _, Size}; use crate::theme::{ActiveTheme as _, Size};
@@ -188,7 +188,6 @@ where
{ {
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 border = theme.colors.border; let border = theme.colors.border;
let ring = theme.colors.ring; let ring = theme.colors.ring;
let input = theme.colors.input; let input = theme.colors.input;
@@ -196,7 +195,6 @@ where
let foreground = theme.colors.foreground; let foreground = theme.colors.foreground;
let muted_foreground = theme.colors.muted_foreground; let muted_foreground = theme.colors.muted_foreground;
let radius = theme.radius.control; let radius = theme.radius.control;
let icon_size = metrics.dense_icon_size;
let label = self let label = self
.a11y_label .a11y_label
@@ -271,14 +269,14 @@ where
.justify_between() .justify_between()
.gap_3() .gap_3()
.w_full() .w_full()
.h(metrics.input_height) .control_height(self.size)
.pl(metrics.dense_padding_x) .control_dense_padding_x(self.size)
.pr(metrics.plate_inset * 2.0) .pr(rems(self.size.plate_inset_rems().0 * 2.0))
.rounded(radius) .rounded(radius)
.border_1() .border_1()
.border_color(rest_border) .border_color(rest_border)
.bg(input) .bg(input)
.text_size(metrics.text_size) .control_text(self.size)
.text_color(if trigger_has_value { .text_color(if trigger_has_value {
foreground foreground
} else { } else {
@@ -288,7 +286,7 @@ where
.child(trigger_text.clone()) .child(trigger_text.clone())
.child( .child(
icon(IconRole::ChevronDown) icon(IconRole::ChevronDown)
.size(icon_size) .size(self.size.dense_icon_rems())
.color(muted_foreground), .color(muted_foreground),
) )
.child( .child(
+6 -5
View File
@@ -30,7 +30,7 @@ use crate::components::common::{
}; };
use crate::components::grain::grain as grain_overlay; use crate::components::grain::grain as grain_overlay;
use crate::components::scroll_area::ScrollArea; use crate::components::scroll_area::ScrollArea;
use crate::theme::{ActiveTheme as _, BORDER_WIDTH, SIDEBAR_DEFAULT_WIDTH, TextRole, Typeset as _}; use crate::theme::{ActiveTheme as _, BORDER_WIDTH, SIDEBAR_DEFAULT_WIDTH};
/// The change reporter, fired with the next selected row by pointer and keys. /// The change reporter, fired with the next selected row by pointer and keys.
type ChangeHandler = Rc<dyn Fn(Option<usize>, &mut Window, &mut App)>; type ChangeHandler = Rc<dyn Fn(Option<usize>, &mut Window, &mut App)>;
@@ -396,7 +396,7 @@ impl RenderOnce for Sidebar {
.debug_selector(move || format!("sidebar-{debug_id}")) .debug_selector(move || format!("sidebar-{debug_id}"))
.h_full() .h_full()
.w(width) .w(width)
.text_size(theme.sizes.medium.text_size) .text_sm()
.when(border_right, |sidebar| { .when(border_right, |sidebar| {
sidebar sidebar
.border_r(BORDER_WIDTH) .border_r(BORDER_WIDTH)
@@ -437,7 +437,8 @@ impl SidebarEntry {
.px_2() .px_2()
.pt_2() .pt_2()
.pb_1() .pb_1()
.typeset(TextRole::Headline, cx) .text_sm()
.font_semibold()
.text_color(theme.colors.muted_foreground) .text_color(theme.colors.muted_foreground)
.role(Role::Heading) .role(Role::Heading)
.when_some(prefix, |header, prefix| header.child(prefix)) .when_some(prefix, |header, prefix| header.child(prefix))
@@ -471,7 +472,7 @@ impl SidebarEntry {
.gap_2() .gap_2()
.px_2() .px_2()
.py_1() .py_1()
.min_h(theme.sizes.medium.control_height) .min_h_8()
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.text_color(label_color) .text_color(label_color)
.role(Role::ListItem) .role(Role::ListItem)
@@ -515,7 +516,7 @@ impl SidebarEntry {
row.child( row.child(
div() div()
.flex_none() .flex_none()
.typeset(TextRole::Subheadline, cx) .text_sm()
.text_color(if selected { .text_color(if selected {
theme.colors.primary_foreground theme.colors.primary_foreground
} else { } else {
+26 -8
View File
@@ -142,11 +142,11 @@ impl RenderOnce for Slider {
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let radius = theme.radius; let radius = theme.radius;
let metrics = theme.sizes.resolve(self.size);
let row_height = metrics.icon_size * 2.5; let rem = window.rem_size();
let track_height = metrics.icon_size / 4.0; let row_height = self.size.slider_row_rems() * rem;
let knob = metrics.indicator_size; let track_height = self.size.slider_track_rems() * rem;
let knob = self.size.indicator_rems() * rem;
let value = self.value.clamp(self.min, self.max); let value = self.value.clamp(self.min, self.max);
let fraction = if self.max > self.min { let fraction = if self.max > self.min {
@@ -188,7 +188,12 @@ impl RenderOnce for Slider {
.id(self.id) .id(self.id)
.relative() .relative()
.w_full() .w_full()
.h(row_height) .map(|slider| match self.size {
Size::XSmall => slider.h_6(),
Size::Small => slider.h_9(),
Size::Medium => slider.h_10(),
Size::Large => slider.h_12(),
})
.refine_style(&self.style) .refine_style(&self.style)
.role(Role::Slider) .role(Role::Slider)
.when_some(self.a11y_label.clone(), |slider, label| { .when_some(self.a11y_label.clone(), |slider, label| {
@@ -284,7 +289,11 @@ impl RenderOnce for Slider {
.absolute() .absolute()
.left_0() .left_0()
.top((row_height - track_height) / 2.0) .top((row_height - track_height) / 2.0)
.h(track_height) .map(|track| match self.size {
Size::XSmall => track.h_0p5(),
Size::Small | Size::Medium => track.h_1(),
Size::Large => track.h_1p5(),
})
.w_full() .w_full()
.rounded(radius.full) .rounded(radius.full)
.bg(colors.border), .bg(colors.border),
@@ -294,7 +303,11 @@ impl RenderOnce for Slider {
.absolute() .absolute()
.left_0() .left_0()
.top((row_height - track_height) / 2.0) .top((row_height - track_height) / 2.0)
.h(track_height) .map(|track| match self.size {
Size::XSmall => track.h_0p5(),
Size::Small | Size::Medium => track.h_1(),
Size::Large => track.h_1p5(),
})
.w(relative(fraction)) .w(relative(fraction))
.rounded(radius.full) .rounded(radius.full)
.bg(ramps.primary.base), .bg(ramps.primary.base),
@@ -310,7 +323,12 @@ impl RenderOnce for Slider {
.items_center() .items_center()
.child( .child(
div() div()
.size(knob) .map(|dot| match self.size {
Size::XSmall => dot.size_2p5(),
Size::Small => dot.size_3p5(),
Size::Medium => dot.size_4(),
Size::Large => dot.size_5(),
})
.flex_none() .flex_none()
.rounded(radius.full) .rounded(radius.full)
.bg(colors.primary_foreground) .bg(colors.primary_foreground)
+12 -12
View File
@@ -32,10 +32,10 @@ use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
App, Context, ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement, App, Context, ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement,
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
StyleRefinement, Styled, Subscription, Task, WeakEntity, Window, div, relative, StyleRefinement, Styled, Subscription, Task, WeakEntity, Window, div, relative, rems,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex};
use crate::components::spinner::{Spinner, SpinnerVariant}; use crate::components::spinner::{Spinner, SpinnerVariant};
use crate::components::tooltip::Tooltip; use crate::components::tooltip::Tooltip;
use crate::icons::{IconRole, icon}; use crate::icons::{IconRole, icon};
@@ -745,7 +745,7 @@ impl RenderOnce for SpeechButton {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let id: ElementId = ("speech-button", self.speech.entity_id()).into(); let id: ElementId = ("speech-button", self.speech.entity_id()).into();
let group = SharedString::from(format!( let group = SharedString::from(format!(
@@ -768,8 +768,8 @@ impl RenderOnce for SpeechButton {
.group(group.clone()) .group(group.clone())
.role(Role::Button) .role(Role::Button)
.justify_center() .justify_center()
.h(metrics.control_height) .control_height(size)
.px(metrics.dense_padding_x) .control_dense_padding_x(size)
.gap_0p5() .gap_0p5()
.rounded(theme.radius.control) .rounded(theme.radius.control)
.text_color(foreground) .text_color(foreground)
@@ -794,13 +794,13 @@ impl RenderOnce for SpeechButton {
}; };
h_flex() h_flex()
.id(("speech-bars", self.speech.entity_id())) .id(("speech-bars", self.speech.entity_id()))
.h(metrics.icon_size) .h(size.icon_rems())
.items_end() .items_end()
.gap_0p5() .gap_0p5()
.children(bars.iter().map(|level| { .children(bars.iter().map(|level| {
div() div()
.flex_none() .flex_none()
.w(metrics.dense_icon_size / 4.) .w(rems(size.dense_icon_rems().0 / 4.0))
.h(relative(bar_height(*level))) .h(relative(bar_height(*level)))
.rounded(theme.radius.full) .rounded(theme.radius.full)
.bg(theme.ramps.primary.base) .bg(theme.ramps.primary.base)
@@ -809,7 +809,7 @@ impl RenderOnce for SpeechButton {
.into_any_element() .into_any_element()
} else { } else {
icon(IconRole::Microphone) icon(IconRole::Microphone)
.size(metrics.icon_size) .size(size.icon_rems())
.color(foreground) .color(foreground)
.into_any_element() .into_any_element()
}) })
@@ -820,7 +820,7 @@ impl RenderOnce for SpeechButton {
.group_hover(group, |style| style.visible()) .group_hover(group, |style| style.visible())
.child( .child(
icon(IconRole::Stop) icon(IconRole::Stop)
.size(metrics.icon_size) .size(size.icon_rems())
.color(foreground), .color(foreground),
), ),
) )
@@ -887,7 +887,7 @@ impl RenderOnce for SpeechWaveform {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let bar_height = |level: f32| { let bar_height = |level: f32| {
if reduce_motion { if reduce_motion {
STILL_HEIGHT STILL_HEIGHT
@@ -901,13 +901,13 @@ impl RenderOnce for SpeechWaveform {
.items_end() .items_end()
.justify_end() .justify_end()
.gap_0p5() .gap_0p5()
.h(metrics.icon_size) .h(size.icon_rems())
.w(SPEECH_WAVEFORM_WIDTH) .w(SPEECH_WAVEFORM_WIDTH)
.overflow_hidden() .overflow_hidden()
.children(levels.iter().map(|level| { .children(levels.iter().map(|level| {
div() div()
.flex_none() .flex_none()
.w(metrics.dense_icon_size / 4.) .w(rems(size.dense_icon_rems().0 / 4.0))
.h(relative(bar_height(*level))) .h(relative(bar_height(*level)))
.rounded(theme.radius.full) .rounded(theme.radius.full)
.bg(if *level <= 0.0 { .bg(if *level <= 0.0 {
+2 -2
View File
@@ -113,9 +113,9 @@ impl Sizable for Spinner {
} }
impl RenderOnce for Spinner { impl RenderOnce for Spinner {
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 side = theme.sizes.resolve(self.size).icon_size; let side = self.size.icon_rems() * window.rem_size();
let stroke = side * RING_STROKE; let stroke = side * RING_STROKE;
let track = theme.colors.border; let track = theme.colors.border;
let accent = self.color.unwrap_or(theme.ramps.primary.base); let accent = self.color.unwrap_or(theme.ramps.primary.base);
+10 -6
View File
@@ -104,18 +104,22 @@ impl Styled for StatusDot {
impl RenderOnce for StatusDot { impl RenderOnce for StatusDot {
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 size = self.size;
let side = metrics.icon_size / 2.;
let color = self.variant.color(theme); let color = self.variant.color(theme);
div() let dot = div()
.id(self.id.clone()) .id(self.id.clone())
.debug_selector(move || self.id.to_string()) .debug_selector(move || self.id.to_string())
.flex_none() .flex_none()
.size(side)
.rounded(theme.radius.full) .rounded(theme.radius.full)
.bg(color) .bg(color);
.when_some(self.label, |dot, label| { let dot = match size {
Size::XSmall => dot.size_1p5(),
Size::Small | Size::Medium => dot.size_2(),
Size::Large => dot.size_2p5(),
};
dot.when_some(self.label, |dot, label| {
dot.role(Role::Status).aria_label(label) dot.role(Role::Status).aria_label(label)
}) })
.refine_style(&self.style) .refine_style(&self.style)
+10 -10
View File
@@ -18,7 +18,7 @@ use gpui::{
StyleRefinement, Styled as _, Toggled, Window, div, px, StyleRefinement, Styled as _, Toggled, Window, div, px,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex};
use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CONTROL_SPRING, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CONTROL_SPRING, DISABLED_OPACITY, Size};
/// The change reporter, fired with the next value by pointer, Enter, and Space. /// The change reporter, fired with the next value by pointer, Enter, and Space.
@@ -109,16 +109,16 @@ impl Sizable for Switch {
} }
impl RenderOnce for Switch { impl RenderOnce for Switch {
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 colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = theme.sizes.resolve(self.size);
let track_height = metrics.switch_height; let rem = window.rem_size();
let track_width = metrics.switch_width; let track_height = self.size.switch_track_height_rems() * rem;
let track_width = self.size.switch_track_width_rems() * rem;
let knob = metrics.switch_knob; let knob = self.size.switch_knob_rems() * rem;
// Absolute children sit inside the track's border, so remove it from the inset. // Absolute children sit inside the track's border, so remove it from the inset.
let inset = (track_height - knob) / 2. - BORDER_WIDTH; let inset = (track_height - knob) / 2. - BORDER_WIDTH;
let travel = track_width - BORDER_WIDTH * 2. - knob - inset * 2.; let travel = track_width - BORDER_WIDTH * 2. - knob - inset * 2.;
@@ -134,7 +134,7 @@ impl RenderOnce for Switch {
h_flex() h_flex()
.id(self.id) .id(self.id)
.gap_2() .gap_2()
.text_size(metrics.text_size) .control_text(self.size)
.refine_style(&self.style) .refine_style(&self.style)
.role(Role::Switch) .role(Role::Switch)
.when_some(a11y_label, |switch, label| switch.aria_label(label)) .when_some(a11y_label, |switch, label| switch.aria_label(label))
@@ -155,8 +155,8 @@ impl RenderOnce for Switch {
.flex_none() .flex_none()
.relative() .relative()
.debug_selector(move || format!("{id}-track")) .debug_selector(move || format!("{id}-track"))
.w(track_width) .switch_track_width(self.size)
.h(track_height) .switch_track_height(self.size)
.rounded(theme.radius.full) .rounded(theme.radius.full)
.border_1() .border_1()
.when(self.checked, |track| { .when(self.checked, |track| {
@@ -177,7 +177,7 @@ impl RenderOnce for Switch {
.absolute() .absolute()
.top(inset) .top(inset)
.left(inset) .left(inset)
.size(knob) .switch_knob(self.size)
.rounded(theme.radius.full) .rounded(theme.radius.full)
.bg(colors.primary_foreground) .bg(colors.primary_foreground)
.with_spring("switch-thumb", anim, move |thumb, offset| { .with_spring("switch-thumb", anim, move |thumb, offset| {
+24 -42
View File
@@ -25,7 +25,7 @@ use gpui::{
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels, InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels,
Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _, Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _,
StyleRefinement, Styled as _, TextOverflow, Window, canvas, div, linear_color_stop, StyleRefinement, Styled as _, TextOverflow, Window, canvas, div, linear_color_stop,
linear_gradient, px, linear_gradient, px, rems,
}; };
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
@@ -35,10 +35,7 @@ use crate::components::scroll_area::{ScrollArea, ScrollAxes};
use crate::components::spinner::Spinner; use crate::components::spinner::Spinner;
use crate::components::tooltip::Tooltip; use crate::components::tooltip::Tooltip;
use crate::icons::IconRole; use crate::icons::IconRole;
use crate::theme::{ use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, TAB_MAX_WIDTH, TAB_MIN_WIDTH};
ActiveTheme as _, ControlMetrics, POPUP_MAX_HEIGHT, Size, TAB_INDICATOR_WIDTH, TAB_MAX_WIDTH,
TAB_MIN_WIDTH,
};
/// Reports the next selected tab by pointer and keys. /// Reports the next selected tab by pointer and keys.
type ChangeHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>; type ChangeHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
@@ -215,7 +212,7 @@ impl Render for TabDragPreview {
.border_1() .border_1()
.border_color(theme.colors.border) .border_color(theme.colors.border)
.bg(theme.colors.background) .bg(theme.colors.background)
.text_size(theme.sizes.medium.text_size) .text_sm()
.text_color(theme.colors.foreground) .text_color(theme.colors.foreground)
.shadow(theme.elevations.control.shadows()) .shadow(theme.elevations.control.shadows())
.child(self.label.clone()) .child(self.label.clone())
@@ -620,8 +617,6 @@ impl Tabs {
.clone(); .clone();
let theme = cx.theme(); let theme = cx.theme();
let metrics = theme.sizes.resolve(Size::default());
let small = theme.sizes.small;
let group_key = group_key(&tabs_id, &kind); let group_key = group_key(&tabs_id, &kind);
let label_color = match ctx.variant { let label_color = match ctx.variant {
@@ -671,13 +666,13 @@ impl Tabs {
.py_1() .py_1()
.rounded_tl(theme.radius.sm) .rounded_tl(theme.radius.sm)
.rounded_tr(theme.radius.sm) .rounded_tr(theme.radius.sm)
.border_b(TAB_INDICATOR_WIDTH) .border_b_2()
.border_color(gpui::transparent_black()) .border_color(gpui::transparent_black())
.when(active, |chip| chip.border_color(theme.ramps.primary.base)), .when(active, |chip| chip.border_color(theme.ramps.primary.base)),
TabsVariant::Pill | TabsVariant::Titlebar => chip TabsVariant::Pill | TabsVariant::Titlebar => chip
.h(small.control_height + metrics.plate_inset * 2.0) .h_8()
.px(metrics.dense_padding_x) .px_2()
.pr(metrics.plate_inset) .pr_0p5()
.rounded(match ctx.variant { .rounded(match ctx.variant {
TabsVariant::Titlebar => theme.radius.full, TabsVariant::Titlebar => theme.radius.full,
_ => theme.radius.control, _ => theme.radius.control,
@@ -692,7 +687,7 @@ impl Tabs {
}) })
.child(SharedString::from(format!("{kind} ({count})"))) .child(SharedString::from(format!("{kind} ({count})")))
.when(ctx.variant.is_capsule(), |chip| { .when(ctx.variant.is_capsule(), |chip| {
chip.child(div().flex_none().w(metrics.padding_x * 1.5)) chip.child(div().flex_none().w_4())
}) })
.when_some(ctx.measure.clone(), |chip, measure| { .when_some(ctx.measure.clone(), |chip, measure| {
let key = measure.key.clone(); let key = measure.key.clone();
@@ -799,17 +794,13 @@ impl RenderOnce for Tabs {
let focus = crate::components::common::focus_handle(&self.id, window, cx); let focus = crate::components::common::focus_handle(&self.id, window, cx);
// Theme reads end here, so the strip's group chips can take `cx` mutably. // Theme reads end here, so the strip's group chips can take `cx` mutably.
let (medium_text_size, border_color, shadow_bleed) = { let (border_color, shadow_bleed) = {
let theme = cx.theme(); let theme = cx.theme();
let shadow_bleed = match self.variant { let shadow_bleed = match self.variant {
TabsVariant::Pill | TabsVariant::Titlebar => theme.elevations.control.bleed(), TabsVariant::Pill | TabsVariant::Titlebar => theme.elevations.control.bleed(),
TabsVariant::Underline => Pixels::ZERO, TabsVariant::Underline => Pixels::ZERO,
}; };
( (theme.colors.border, shadow_bleed)
theme.sizes.medium.text_size,
theme.colors.border,
shadow_bleed,
)
}; };
let label = self let label = self
@@ -880,7 +871,7 @@ impl RenderOnce for Tabs {
div() div()
.id(self.id.clone()) .id(self.id.clone())
.flex() .flex()
.text_size(medium_text_size) .text_sm()
.refine_style(&self.style) .refine_style(&self.style)
.track_focus(&focus) .track_focus(&focus)
.focusable() .focusable()
@@ -1038,8 +1029,6 @@ impl Tab {
let active = selected || self.pinned; let active = selected || self.pinned;
let theme = cx.theme(); let theme = cx.theme();
let metrics = theme.sizes.resolve(Size::default());
let small = theme.sizes.small;
let label_color = match ctx.variant { let label_color = match ctx.variant {
TabsVariant::Underline => { TabsVariant::Underline => {
@@ -1069,14 +1058,8 @@ impl Tab {
let titlebar = ctx.variant == TabsVariant::Titlebar; let titlebar = ctx.variant == TabsVariant::Titlebar;
let group = SharedString::from(format!("{}-tab-{}", ctx.id, self.key)); let group = SharedString::from(format!("{}-tab-{}", ctx.id, self.key));
let close = (self.closeable && ctx.on_close.is_some() && !self.disabled).then(|| { let close = (self.closeable && ctx.on_close.is_some() && !self.disabled)
let close_metrics = ControlMetrics { .then(|| self.render_tab_close(&ctx.id, index, &ctx.on_close));
control_height: small.control_height - metrics.plate_inset * 2.0,
icon_size: theme.sizes.xsmall.icon_size,
..small
};
self.render_tab_close(&ctx.id, index, &ctx.on_close, close_metrics)
});
let label = div() let label = div()
.flex_grow(1.0) .flex_grow(1.0)
@@ -1093,8 +1076,8 @@ impl Tab {
theme.colors.muted_hover theme.colors.muted_hover
}; };
let fade_width = metrics.padding_x; let fade_width = rems(0.75);
let hover_fade_width = metrics.padding_x * 2.0; let hover_fade_width = rems(1.5);
label label
.min_w_0() .min_w_0()
@@ -1166,15 +1149,15 @@ impl Tab {
.py_1() .py_1()
.rounded_tl(theme.radius.sm) .rounded_tl(theme.radius.sm)
.rounded_tr(theme.radius.sm) .rounded_tr(theme.radius.sm)
.border_b(TAB_INDICATOR_WIDTH) .border_b_2()
.border_color(gpui::transparent_black()) .border_color(gpui::transparent_black())
.when(active, |strip_tab| { .when(active, |strip_tab| {
strip_tab.border_color(theme.ramps.primary.base) strip_tab.border_color(theme.ramps.primary.base)
}), }),
TabsVariant::Pill | TabsVariant::Titlebar => strip_tab TabsVariant::Pill | TabsVariant::Titlebar => strip_tab
.h(small.control_height + metrics.plate_inset * 2.0) .h_8()
.px(metrics.dense_padding_x) .px_2()
.pr(metrics.plate_inset) .pr_0p5()
.rounded(match ctx.variant { .rounded(match ctx.variant {
TabsVariant::Titlebar => theme.radius.full, TabsVariant::Titlebar => theme.radius.full,
_ => theme.radius.control, _ => theme.radius.control,
@@ -1194,7 +1177,7 @@ impl Tab {
.when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead)) .when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead))
.child(label) .child(label)
.when(ctx.variant == TabsVariant::Pill, |strip_tab| { .when(ctx.variant == TabsVariant::Pill, |strip_tab| {
strip_tab.child(div().flex_none().w(metrics.padding_x * 1.5)) strip_tab.child(div().flex_none().w_4())
}) })
.when(self.busy && !self.disabled, |strip_tab| { .when(self.busy && !self.disabled, |strip_tab| {
strip_tab.child( strip_tab.child(
@@ -1226,9 +1209,9 @@ impl Tab {
div() div()
.absolute() .absolute()
.left_0() .left_0()
.top(TAB_INDICATOR_WIDTH) .top_0p5()
.bottom(TAB_INDICATOR_WIDTH) .bottom_0p5()
.w(TAB_INDICATOR_WIDTH) .w_0p5()
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.bg(theme.ramps.primary.base), .bg(theme.ramps.primary.base),
) )
@@ -1351,12 +1334,11 @@ impl Tab {
tabs_id: &ElementId, tabs_id: &ElementId,
index: usize, index: usize,
on_close: &Option<CloseHandler>, on_close: &Option<CloseHandler>,
metrics: ControlMetrics,
) -> AnyElement { ) -> AnyElement {
Button::new((self.key.clone(), "tab-close")) Button::new((self.key.clone(), "tab-close"))
.icon(IconRole::Close) .icon(IconRole::Close)
.variant(ButtonVariant::Ghost) .variant(ButtonVariant::Ghost)
.custom_size(metrics) .xsmall()
.fully_rounded(true) .fully_rounded(true)
.tab_stop(false) .tab_stop(false)
.debug_selector({ .debug_selector({
+3 -5
View File
@@ -20,7 +20,7 @@ use gpui::{
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _, Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
IntoElement, ParentElement as _, RenderOnce, Role, SharedString, IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Task, Window, deferred, div, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Task, Window, deferred, div,
ease_out_quint, px, ease_out_quint, px, rems,
}; };
use crate::components::button::{Button, ButtonVariant}; use crate::components::button::{Button, ButtonVariant};
@@ -291,8 +291,6 @@ impl ToastEntry {
let foreground = theme.colors.foreground; let foreground = theme.colors.foreground;
let radius = theme.radius.full; let radius = theme.radius.full;
let shadows = theme.elevations.popover.shadows(); let shadows = theme.elevations.popover.shadows();
let icon_size = theme.sizes.medium.icon_size;
let text_size = theme.sizes.medium.text_size;
let toast = &self.toast; let toast = &self.toast;
let toasts = toasts.clone(); let toasts = toasts.clone();
let id = self.id; let id = self.id;
@@ -320,7 +318,7 @@ impl ToastEntry {
.flex_none() .flex_none()
.flex() .flex()
.items_center() .items_center()
.child(icon.size(icon_size).color(foreground)), .child(icon.size(rems(1.0)).color(foreground)),
) )
}) })
.child( .child(
@@ -328,7 +326,7 @@ impl ToastEntry {
.flex_1() .flex_1()
.min_w(px(0.)) .min_w(px(0.))
.truncate() .truncate()
.text_size(text_size) .text_sm()
.text_color(foreground) .text_color(foreground)
.child(toast.message.clone()), .child(toast.message.clone()),
) )
+7 -9
View File
@@ -17,7 +17,7 @@ use gpui::{
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Toggled, Window,
}; };
use crate::components::common::{Sizable, StyledExt as _, focus_ring, h_flex}; use crate::components::common::{ControlSizing, Sizable, StyledExt as _, focus_ring, h_flex};
use crate::icons::Icon; use crate::icons::Icon;
use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
@@ -124,7 +124,7 @@ impl RenderOnce for Toggle {
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors; let colors = theme.colors;
let ramps = theme.ramps; let ramps = theme.ramps;
let metrics = theme.sizes.resolve(self.size); let size = self.size;
let on_change = self.on_change; let on_change = self.on_change;
let next = !self.pressed; let next = !self.pressed;
let a11y_label = self.a11y_label.or_else(|| self.label.clone()); let a11y_label = self.a11y_label.or_else(|| self.label.clone());
@@ -133,13 +133,11 @@ impl RenderOnce for Toggle {
h_flex() h_flex()
.id(self.id) .id(self.id)
.justify_center() .justify_center()
.h(metrics.control_height) .control_height(size)
.when(icon_only, |toggle| { .when(icon_only, |toggle| toggle.control_width(size).px_0())
toggle.w(metrics.control_height).px(gpui::Pixels::ZERO) .when(!icon_only, |toggle| toggle.control_dense_padding_x(size))
})
.when(!icon_only, |toggle| toggle.px(metrics.dense_padding_x))
.rounded(theme.radius.control) .rounded(theme.radius.control)
.text_size(metrics.text_size) .control_text(size)
.text_color(colors.foreground) .text_color(colors.foreground)
.role(Role::Button) .role(Role::Button)
.when_some(a11y_label, |toggle, label| toggle.aria_label(label)) .when_some(a11y_label, |toggle, label| toggle.aria_label(label))
@@ -170,7 +168,7 @@ impl RenderOnce for Toggle {
h_flex() h_flex()
.gap_2() .gap_2()
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size)) content.child(icon.size(size.icon_rems()))
}) })
.when_some(self.label, |content, label| content.child(label)), .when_some(self.label, |content, label| content.child(label)),
) )
+2 -5
View File
@@ -80,8 +80,6 @@ impl Render for Tooltip {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
// Copied out: the mutable reads below need `cx` free of this borrow. // Copied out: the mutable reads below need `cx` free of this borrow.
let theme = cx.theme(); let theme = cx.theme();
let text_size = theme.sizes.medium.text_size;
let line_height = theme.typography.callout.line_height;
let surface = theme.colors.surface; let surface = theme.colors.surface;
let surface_foreground = theme.colors.surface_foreground; let surface_foreground = theme.colors.surface_foreground;
let radius_sm = theme.radius.sm; let radius_sm = theme.radius.sm;
@@ -102,8 +100,7 @@ impl Render for Tooltip {
.border_color(border) .border_color(border)
.rounded(radius_sm) .rounded(radius_sm)
.shadow(shadows.clone()) .shadow(shadows.clone())
.text_size(text_size) .text_sm()
.line_height(line_height)
.text_color(surface_foreground) .text_color(surface_foreground)
.child(self.text.clone()) .child(self.text.clone())
}; };
@@ -119,7 +116,7 @@ impl Render for Tooltip {
cx, cx,
) )
.map(|bounds| bounds.size.height) .map(|bounds| bounds.size.height)
.unwrap_or_else(|| line_height + px(8.) + BORDER_WIDTH * 2.0); .unwrap_or_else(|| window.line_height() + px(8.) + BORDER_WIDTH * 2.0);
let below = viewport_height - px(4.) - parent.bottom(); let below = viewport_height - px(4.) - parent.bottom();
let above = parent.top() - px(4.); let above = parent.top() - px(4.);
+8 -9
View File
@@ -21,7 +21,7 @@ use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent, AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent,
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
StyleRefinement, Styled as _, Window, div, StyleRefinement, Styled as _, Window, div, rems,
}; };
use crate::components::common::{ use crate::components::common::{
@@ -254,7 +254,6 @@ impl RenderOnce for Tree {
.collect(); .collect();
let focus = crate::components::common::focus_handle(&self.id, window, cx); let focus = crate::components::common::focus_handle(&self.id, window, cx);
let theme = cx.theme();
let label = self let label = self
.a11y_label .a11y_label
@@ -286,7 +285,7 @@ impl RenderOnce for Tree {
.flex() .flex()
.flex_col() .flex_col()
.gap_0p5() .gap_0p5()
.text_size(theme.sizes.medium.text_size) .text_sm()
.refine_style(&self.style) .refine_style(&self.style)
.track_focus(&focus) .track_focus(&focus)
.focusable() .focusable()
@@ -364,7 +363,7 @@ impl TreeItem {
let disabled = self.disabled; let disabled = self.disabled;
let depth = u32::try_from(self.depth).unwrap_or(u32::MAX) as f32; let depth = u32::try_from(self.depth).unwrap_or(u32::MAX) as f32;
let indent = theme.sizes.medium.padding_x * if self.depth == 0 { 0.5 } else { depth + 1.0 }; let indent = rems(0.75 * if self.depth == 0 { 0.5 } else { depth + 1.0 });
div() div()
.id((self.key.clone(), "tree-item")) .id((self.key.clone(), "tree-item"))
@@ -375,7 +374,7 @@ impl TreeItem {
.pl(indent) .pl(indent)
.pr_2() .pr_2()
.py_1() .py_1()
.min_h(theme.sizes.medium.control_height) .min_h_8()
.rounded(theme.radius.sm) .rounded(theme.radius.sm)
.role(Role::TreeItem) .role(Role::TreeItem)
.aria_selected(selected) .aria_selected(selected)
@@ -407,7 +406,7 @@ impl TreeItem {
let step = u32::try_from(level).unwrap_or(u32::MAX) as f32; let step = u32::try_from(level).unwrap_or(u32::MAX) as f32;
div() div()
.absolute() .absolute()
.left(theme.sizes.medium.padding_x * (step + 0.5)) .left(rems(0.75 * (step + 0.5)))
.top_0() .top_0()
.bottom_0() .bottom_0()
.border_l_1() .border_l_1()
@@ -418,7 +417,7 @@ impl TreeItem {
self.icon self.icon
.clone() .clone()
.or_else(|| (!self.expandable).then(|| icon(IconRole::File))), .or_else(|| (!self.expandable).then(|| icon(IconRole::File))),
|row, icon| row.child(icon.size(theme.sizes.medium.icon_size).color(label_color)), |row, icon| row.child(icon.size(rems(1.0)).color(label_color)),
) )
.child( .child(
div() div()
@@ -440,7 +439,7 @@ impl TreeItem {
// Only expandable rows draw a chevron; the empty cell keeps labels aligned with folders. // Only expandable rows draw a chevron; the empty cell keeps labels aligned with folders.
div() div()
.flex_none() .flex_none()
.size(theme.sizes.medium.icon_size) .size_4()
.flex() .flex()
.items_center() .items_center()
.justify_center() .justify_center()
@@ -451,7 +450,7 @@ impl TreeItem {
} else { } else {
IconRole::ChevronRight IconRole::ChevronRight
}) })
.size(theme.sizes.medium.dense_icon_size) .size(rems(0.75))
.color(glyph_color), .color(glyph_color),
) )
}) })
+1 -1
View File
@@ -72,7 +72,7 @@ where
.justify_center() .justify_center()
.flex_none() .flex_none()
.font_family(theme.mono_font) .font_family(theme.mono_font)
.text_size(theme.sizes.small.text_size) .text_xs()
.line_height(gpui::relative(1.0)) .line_height(gpui::relative(1.0))
.text_color(color) .text_color(color)
.child(content) .child(content)
+15 -13
View File
@@ -4,13 +4,14 @@ use std::time::Duration;
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
use gpui::{ use gpui::{
AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, RenderOnce, AbsoluteLength, AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, Rems,
SharedString, Styled as _, TimedTransformation, Transformation, Window, div, px, svg, RenderOnce, SharedString, Styled as _, TimedTransformation, Transformation, Window, div, rems,
svg,
}; };
const SMALL_ICON_SIZE: Pixels = px(14.0); const SMALL_ICON_SIZE: Rems = rems(0.875);
const DEFAULT_ICON_SIZE: Pixels = px(16.0); const DEFAULT_ICON_SIZE: Rems = rems(1.0);
const LARGE_ICON_SIZE: Pixels = px(20.0); const LARGE_ICON_SIZE: Rems = rems(1.25);
/// The spin presents at most this rate, rotating a sprite needs no more frames. /// The spin presents at most this rate, rotating a sprite needs no more frames.
const SPIN_MAX_FPS: f32 = 60.0; const SPIN_MAX_FPS: f32 = 60.0;
@@ -137,7 +138,7 @@ enum Glyph {
#[derive(Clone, IntoElement)] #[derive(Clone, IntoElement)]
pub struct Icon { pub struct Icon {
glyph: Glyph, glyph: Glyph,
size: Pixels, size: AbsoluteLength,
color: Option<Hsla>, color: Option<Hsla>,
transformation: Option<Transformation>, transformation: Option<Transformation>,
rotation_period: Option<Duration>, rotation_period: Option<Duration>,
@@ -147,7 +148,7 @@ pub struct Icon {
pub fn icon(role: IconRole) -> Icon { pub fn icon(role: IconRole) -> Icon {
Icon { Icon {
glyph: Glyph::Role(role), glyph: Glyph::Role(role),
size: DEFAULT_ICON_SIZE, size: AbsoluteLength::Rems(DEFAULT_ICON_SIZE),
color: None, color: None,
transformation: None, transformation: None,
rotation_period: None, rotation_period: None,
@@ -162,33 +163,33 @@ impl Icon {
{ {
Self { Self {
glyph: Glyph::Named(named.path()), glyph: Glyph::Named(named.path()),
size: DEFAULT_ICON_SIZE, size: AbsoluteLength::Rems(DEFAULT_ICON_SIZE),
color: None, color: None,
transformation: None, transformation: None,
rotation_period: None, rotation_period: None,
} }
} }
pub fn size(mut self, size: Pixels) -> Self { pub fn size(mut self, size: impl Into<AbsoluteLength>) -> Self {
self.size = size; self.size = size.into();
self self
} }
/// The small size. /// The small size.
pub fn small(mut self) -> Self { pub fn small(mut self) -> Self {
self.size = SMALL_ICON_SIZE; self.size = AbsoluteLength::Rems(SMALL_ICON_SIZE);
self self
} }
/// The default medium size. /// The default medium size.
pub fn medium(mut self) -> Self { pub fn medium(mut self) -> Self {
self.size = DEFAULT_ICON_SIZE; self.size = AbsoluteLength::Rems(DEFAULT_ICON_SIZE);
self self
} }
/// The large size. /// The large size.
pub fn large(mut self) -> Self { pub fn large(mut self) -> Self {
self.size = LARGE_ICON_SIZE; self.size = AbsoluteLength::Rems(LARGE_ICON_SIZE);
self self
} }
@@ -260,6 +261,7 @@ impl RenderOnce for Icon {
rotation_period, rotation_period,
} = self; } = self;
let size = size.to_pixels(window.rem_size());
let color = color.unwrap_or_else(|| window.text_style().color); let color = color.unwrap_or_else(|| window.text_style().color);
match glyph { match glyph {
+2 -3
View File
@@ -12,7 +12,7 @@ use gpui::{
use crate::layout::window_controls::{WindowControls, titlebar_strip}; use crate::layout::window_controls::{WindowControls, titlebar_strip};
use crate::layout::{StyledExt as _, h_flex}; use crate::layout::{StyledExt as _, h_flex};
use crate::theme::{ActiveTheme as _, Size, TRAFFIC_LIGHT_PAD}; use crate::theme::{ActiveTheme as _, TRAFFIC_LIGHT_PAD};
/// The window's titlebar. /// The window's titlebar.
#[derive(IntoElement)] #[derive(IntoElement)]
@@ -86,7 +86,6 @@ impl RenderOnce for Titlebar {
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 height = theme.titlebar_height; let height = theme.titlebar_height;
let padding_x = theme.sizes.resolve(Size::default()).padding_x;
let shadow_bleed = theme.elevations.control.bleed(); let shadow_bleed = theme.elevations.control.bleed();
let id = self.id; let id = self.id;
@@ -101,7 +100,7 @@ impl RenderOnce for Titlebar {
.h(height) .h(height)
.gap_2() .gap_2()
.when(!self.transparent, |bar| bar.bg(theme.colors.muted)) .when(!self.transparent, |bar| bar.bg(theme.colors.muted))
.px(padding_x) .px_3()
.refine_style(&self.style) .refine_style(&self.style)
.when(cfg!(target_os = "macos"), |bar| bar.pl(TRAFFIC_LIGHT_PAD)) .when(cfg!(target_os = "macos"), |bar| bar.pl(TRAFFIC_LIGHT_PAD))
.when(!self.prefix.is_empty(), |bar| { .when(!self.prefix.is_empty(), |bar| {
+4 -6
View File
@@ -13,7 +13,7 @@ use gpui::Styled as _;
#[cfg(any(target_os = "windows", target_os = "linux"))] #[cfg(any(target_os = "windows", target_os = "linux"))]
use gpui::prelude::FluentBuilder as _; use gpui::prelude::FluentBuilder as _;
#[cfg(any(target_os = "windows", target_os = "linux"))] #[cfg(any(target_os = "windows", target_os = "linux"))]
use gpui::{AnyElement, ParentElement as _}; use gpui::{AnyElement, ParentElement as _, rems};
use gpui::{ use gpui::{
App, ClickEvent, Div, ElementId, InteractiveElement as _, IntoElement, MouseButton, RenderOnce, App, ClickEvent, Div, ElementId, InteractiveElement as _, IntoElement, MouseButton, RenderOnce,
Stateful, StatefulInteractiveElement as _, Window, WindowControlArea, div, Stateful, StatefulInteractiveElement as _, Window, WindowControlArea, div,
@@ -229,7 +229,6 @@ fn caption_button(
close: bool, close: bool,
) -> AnyElement { ) -> AnyElement {
let theme = cx.theme(); let theme = cx.theme();
let glyph_size = theme.sizes.small.dense_icon_size;
let hover = if close { let hover = if close {
WINDOWS_CLOSE_HOVER WINDOWS_CLOSE_HOVER
@@ -275,7 +274,7 @@ fn caption_button(
.text_color(theme.colors.foreground) .text_color(theme.colors.foreground)
}) })
}) })
.child(icon(role).size(glyph_size)) .child(icon(role).size(rems(0.75)))
.into_any_element() .into_any_element()
} }
@@ -287,7 +286,6 @@ where
F: Fn(&mut Window, &mut App) + 'static, F: Fn(&mut Window, &mut App) + 'static,
{ {
let theme = cx.theme(); let theme = cx.theme();
let small = theme.sizes.small;
div() div()
.id(id) .id(id)
@@ -295,7 +293,7 @@ where
.flex() .flex()
.items_center() .items_center()
.justify_center() .justify_center()
.size(small.control_height) .size_7()
.rounded(theme.radius.full) .rounded(theme.radius.full)
.text_color(if enabled { .text_color(if enabled {
theme.colors.foreground theme.colors.foreground
@@ -311,6 +309,6 @@ where
action(window, cx); action(window, cx);
}) })
}) })
.child(icon(role).size(small.dense_icon_size)) .child(icon(role).size(rems(0.75)))
.into_any_element() .into_any_element()
} }
-188
View File
@@ -13,7 +13,6 @@ mod ramps;
mod resolve; mod resolve;
mod source; mod source;
mod system; mod system;
mod typography;
use std::time::Duration; use std::time::Duration;
@@ -25,12 +24,9 @@ use gpui::{
pub use ramps::{AccentShades, Oklch}; pub use ramps::{AccentShades, Oklch};
pub use resolve::{Ramps, ResolvedTheme}; pub use resolve::{Ramps, ResolvedTheme};
pub use system::{AccessibilityPreferences, SourceKind, SystemTheme}; pub use system::{AccessibilityPreferences, SourceKind, SystemTheme};
pub use typography::{TextRole, TypeMetrics, Typeset, Typography};
/// The hairline width of the control border every button and field paints. /// The hairline width of the control border every button and field paints.
pub const BORDER_WIDTH: Pixels = px(1.0); pub const BORDER_WIDTH: Pixels = px(1.0);
/// The underline and drop indicators a tab strip paints.
pub const TAB_INDICATOR_WIDTH: Pixels = px(2.0);
/// The widest a titlebar tab grows before its label fades. /// The widest a titlebar tab grows before its label fades.
pub const TAB_MAX_WIDTH: Pixels = px(240.0); pub const TAB_MAX_WIDTH: Pixels = px(240.0);
/// The narrowest a titlebar tab shrinks, keeping short labels clear of the fade. /// The narrowest a titlebar tab shrinks, keeping short labels clear of the fade.
@@ -201,9 +197,6 @@ pub struct Theme {
pub root_font_size: Pixels, pub root_font_size: Pixels,
/// The monospace family, for code surfaces. /// The monospace family, for code surfaces.
pub mono_font: &'static str, pub mono_font: &'static str,
/// The type ladder, resolved at the root font size.
pub typography: Typography,
pub sizes: SizeTable,
pub accessibility: AccessibilityPreferences, pub accessibility: AccessibilityPreferences,
/// The material a window should open with, after accessibility. /// The material a window should open with, after accessibility.
pub window_background: WindowBackgroundAppearance, pub window_background: WindowBackgroundAppearance,
@@ -230,8 +223,6 @@ impl Theme {
titlebar_height: resolved.titlebar_height, titlebar_height: resolved.titlebar_height,
root_font_size: resolved.root_font_size, root_font_size: resolved.root_font_size,
mono_font: resolved.mono_font, mono_font: resolved.mono_font,
typography: resolved.typography,
sizes: resolved.sizes,
accessibility: resolved.accessibility, accessibility: resolved.accessibility,
window_background: resolved.window_background, window_background: resolved.window_background,
} }
@@ -455,185 +446,6 @@ impl Default for Scrollbar {
} }
} }
/// The control metrics for one size class.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ControlMetrics {
/// Push buttons, toggles, and field rows.
pub control_height: Pixels,
/// Text fields; slightly taller than buttons, as native fields are.
pub input_height: Pixels,
/// Horizontal padding inside controls.
pub padding_x: Pixels,
/// Label text size.
pub text_size: Pixels,
/// Icons and on/off indicators.
pub icon_size: Pixels,
/// Icons inline with dense content — menu rows, badges, chevrons.
pub dense_icon_size: Pixels,
/// Selection indicators — checkboxes, radios, and switch knobs.
pub indicator_size: Pixels,
/// Avatars.
pub avatar_size: Pixels,
/// Dense label text.
pub caption_size: Pixels,
/// Tight horizontal padding inside pills, segments, fields, and icon-only buttons.
pub dense_padding_x: Pixels,
/// The inset between a control's edge and a raised inner plate.
pub plate_inset: Pixels,
/// The band height of multi-segment strips.
pub strip_height: Pixels,
/// The height of one menu row.
pub menu_item_height: Pixels,
/// Switch track height, width, and knob size.
pub switch_height: Pixels,
pub switch_width: Pixels,
pub switch_knob: Pixels,
}
/// The control metrics for every size class.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SizeTable {
pub xsmall: ControlMetrics,
pub small: ControlMetrics,
pub medium: ControlMetrics,
pub large: ControlMetrics,
}
impl SizeTable {
pub fn with_root_font_size(rem_size: Pixels) -> Self {
struct ClassFactors {
control_height: f32,
input_height: f32,
padding_x: f32,
text_size: f32,
icon_size: f32,
dense_icon_size: f32,
indicator_size: f32,
avatar_size: f32,
caption_size: f32,
dense_padding_x: f32,
plate_inset: f32,
strip_height: f32,
menu_item_height: f32,
switch_height: f32,
switch_width: f32,
switch_knob: f32,
}
let xsmall = ClassFactors {
control_height: 1.25,
input_height: 1.25,
padding_x: 0.25,
text_size: 0.6875,
icon_size: 0.625,
dense_icon_size: 0.5,
indicator_size: 0.625,
avatar_size: 1.125,
caption_size: 0.625,
dense_padding_x: 0.25,
plate_inset: 0.0,
strip_height: 1.25,
menu_item_height: 1.25,
switch_height: 0.875,
switch_width: 1.5,
switch_knob: 0.5,
};
let small = ClassFactors {
control_height: 1.75,
input_height: 1.75,
padding_x: 0.5,
text_size: 0.75,
icon_size: 0.875,
dense_icon_size: 0.75,
indicator_size: 0.875,
avatar_size: 1.5,
caption_size: 0.75,
dense_padding_x: 0.5,
plate_inset: 0.125,
strip_height: 1.75,
menu_item_height: 1.75,
switch_height: 1.125,
switch_width: 2.0,
switch_knob: 0.75,
};
let medium = ClassFactors {
control_height: 2.0,
input_height: 2.0,
padding_x: 0.75,
text_size: 0.875,
icon_size: 1.0,
dense_icon_size: 0.75,
indicator_size: 1.0,
avatar_size: 2.0,
caption_size: 0.75,
dense_padding_x: 0.5,
plate_inset: 0.125,
strip_height: 2.0,
menu_item_height: 2.0,
switch_height: 1.25,
switch_width: 2.25,
switch_knob: 0.875,
};
let large = ClassFactors {
control_height: 2.5,
input_height: 2.5,
padding_x: 1.0,
text_size: 1.0,
icon_size: 1.25,
dense_icon_size: 0.9375,
indicator_size: 1.25,
avatar_size: 2.5,
caption_size: 0.875,
dense_padding_x: 0.75,
plate_inset: 0.1875,
strip_height: 2.5,
menu_item_height: 2.25,
switch_height: 1.5,
switch_width: 2.75,
switch_knob: 1.125,
};
let metrics = |f: &ClassFactors| ControlMetrics {
control_height: rem_size * f.control_height,
input_height: rem_size * f.input_height,
padding_x: rem_size * f.padding_x,
text_size: rem_size * f.text_size,
icon_size: rem_size * f.icon_size,
dense_icon_size: rem_size * f.dense_icon_size,
indicator_size: rem_size * f.indicator_size,
avatar_size: rem_size * f.avatar_size,
caption_size: rem_size * f.caption_size,
dense_padding_x: rem_size * f.dense_padding_x,
plate_inset: rem_size * f.plate_inset,
strip_height: rem_size * f.strip_height,
menu_item_height: rem_size * f.menu_item_height,
switch_height: rem_size * f.switch_height,
switch_width: rem_size * f.switch_width,
switch_knob: rem_size * f.switch_knob,
};
Self {
xsmall: metrics(&xsmall),
small: metrics(&small),
medium: metrics(&medium),
large: metrics(&large),
}
}
/// The metrics for `size`.
pub fn resolve(&self, size: Size) -> ControlMetrics {
match size {
Size::XSmall => self.xsmall,
Size::Small => self.small,
Size::Medium => self.medium,
Size::Large => self.large,
}
}
}
/// User customizations layered over the resolved theme. /// User customizations layered over the resolved theme.
#[derive(Clone, Copy, Debug, Default, PartialEq)] #[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct CustomTheme { pub struct CustomTheme {
+3 -9
View File
@@ -4,8 +4,8 @@ use crate::theme::definition::ThemeDefinition;
use crate::theme::ramps::{AccentShades, Oklch, contrast_foreground, derive_shades, mix}; use crate::theme::ramps::{AccentShades, Oklch, contrast_foreground, derive_shades, mix};
use crate::theme::system::{SourceKind, SystemTheme}; use crate::theme::system::{SourceKind, SystemTheme};
use crate::theme::{ use crate::theme::{
ColorTokens, CustomTheme, Elevations, MaterialTokens, Motion, Radius, Scrollbar, SizeTable, AccessibilityPreferences, ColorTokens, CustomTheme, Elevations, MaterialTokens, Motion, Radius,
ThemeVariant, Typography, Scrollbar, ThemeVariant,
}; };
/// Derived state shades for the colors that get pressed and hovered. /// Derived state shades for the colors that get pressed and hovered.
@@ -37,10 +37,7 @@ pub struct ResolvedTheme {
pub root_font_size: gpui::Pixels, pub root_font_size: gpui::Pixels,
/// The monospace family, for code surfaces. /// The monospace family, for code surfaces.
pub mono_font: &'static str, pub mono_font: &'static str,
/// The type ladder, resolved at the root font size. pub accessibility: AccessibilityPreferences,
pub typography: Typography,
pub sizes: SizeTable,
pub accessibility: crate::theme::system::AccessibilityPreferences,
/// The material a window should open with, after accessibility. /// The material a window should open with, after accessibility.
pub window_background: WindowBackgroundAppearance, pub window_background: WindowBackgroundAppearance,
} }
@@ -140,7 +137,6 @@ pub(crate) fn resolve(
// A custom theme's stated font size wins over the 16px design root. // A custom theme's stated font size wins over the 16px design root.
let root_font_size = custom.root_font_size.unwrap_or(px(16.)); let root_font_size = custom.root_font_size.unwrap_or(px(16.));
let sizes = SizeTable::with_root_font_size(root_font_size);
let titlebar_height = root_font_size * 2.5; let titlebar_height = root_font_size * 2.5;
let mut radius = Radius::default(); let mut radius = Radius::default();
@@ -221,8 +217,6 @@ pub(crate) fn resolve(
titlebar_height, titlebar_height,
root_font_size, root_font_size,
mono_font: mono_font(), mono_font: mono_font(),
typography: Typography::resolve(root_font_size),
sizes,
accessibility, accessibility,
window_background, window_background,
} }
-146
View File
@@ -1,146 +0,0 @@
//! One type ladder shared by every platform, scaled by the theme's root font
//! size.
use gpui::{App, FontWeight, Pixels, Styled, px};
use crate::theme::ActiveTheme;
/// The shared ladder at a 16px root: size, line height, then weight.
const LADDER: [Rung; 11] = [
(24.0, 32.0, FontWeight::SEMIBOLD),
(20.0, 28.0, FontWeight::SEMIBOLD),
(18.0, 24.0, FontWeight::SEMIBOLD),
(16.0, 24.0, FontWeight::SEMIBOLD),
(14.0, 20.0, FontWeight::SEMIBOLD),
(16.0, 24.0, FontWeight::NORMAL),
(14.0, 20.0, FontWeight::NORMAL),
(14.0, 20.0, FontWeight::NORMAL),
(13.0, 18.0, FontWeight::NORMAL),
(12.0, 16.0, FontWeight::NORMAL),
(12.0, 16.0, FontWeight::MEDIUM),
];
/// One rung: size and line height at a 16px root, then the weight.
type Rung = (f32, f32, FontWeight);
/// A role in the unified type ladder.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum TextRole {
/// The largest heading — hero panels, greeters, welcome screens.
LargeTitle,
/// Window and page titles.
Title,
/// Section titles.
Title2,
/// Sub-section and dialog headings.
Title3,
/// Body-sized emphasis, list row titles, group labels.
Headline,
/// Control labels and reading text.
Body,
/// Slightly smaller body text.
Callout,
/// Secondary lines under a body row.
Subheadline,
/// Hints and auxiliary notes.
Footnote,
/// Timestamps, badges, and dense metadata.
Caption,
/// Emphasized captions.
Caption2,
}
/// One role as it paints: size, line height, and weight.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct TypeMetrics {
pub size: Pixels,
pub line_height: Pixels,
pub weight: FontWeight,
}
/// The unified type ladder, resolved at the theme's root font size.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Typography {
pub large_title: TypeMetrics,
pub title: TypeMetrics,
pub title2: TypeMetrics,
pub title3: TypeMetrics,
pub headline: TypeMetrics,
pub body: TypeMetrics,
pub callout: TypeMetrics,
pub subheadline: TypeMetrics,
pub footnote: TypeMetrics,
pub caption: TypeMetrics,
pub caption2: TypeMetrics,
}
impl Typography {
pub(crate) fn resolve(root_font_size: Pixels) -> Self {
let scale = root_font_size / px(16.);
let metrics = |(size, line_height, weight): Rung| TypeMetrics {
size: px(size) * scale,
line_height: px(line_height) * scale,
weight,
};
let [
large_title,
title,
title2,
title3,
headline,
body,
callout,
subheadline,
footnote,
caption,
caption2,
] = LADDER.map(metrics);
Self {
large_title,
title,
title2,
title3,
headline,
body,
callout,
subheadline,
footnote,
caption,
caption2,
}
}
/// The metrics for `role`.
pub fn get(&self, role: TextRole) -> TypeMetrics {
match role {
TextRole::LargeTitle => self.large_title,
TextRole::Title => self.title,
TextRole::Title2 => self.title2,
TextRole::Title3 => self.title3,
TextRole::Headline => self.headline,
TextRole::Body => self.body,
TextRole::Callout => self.callout,
TextRole::Subheadline => self.subheadline,
TextRole::Footnote => self.footnote,
TextRole::Caption => self.caption,
TextRole::Caption2 => self.caption2,
}
}
}
/// Paints a [`TextRole`] from the resolved theme, on anything styled.
pub trait Typeset: Styled + Sized {
/// Sizes, leads, and weights the element as `role`.
fn typeset(self, role: TextRole, cx: &App) -> Self {
let theme = cx.theme();
let metrics = theme.typography.get(role);
self.text_size(metrics.size)
.line_height(metrics.line_height)
.font_weight(metrics.weight)
}
}
impl<E: Styled> Typeset for E {}
+31
View File
@@ -29,6 +29,25 @@ impl Render for Harness {
.xsmall() .xsmall()
.debug_selector(|| "xsmall-height-probe".to_string()), .debug_selector(|| "xsmall-height-probe".to_string()),
) )
.child(
Button::new("small-height-probe")
.label("Probe")
.small()
.debug_selector(|| "small-height-probe".to_string()),
)
.child(
Button::new("large-height-probe")
.label("Probe")
.large()
.debug_selector(|| "large-height-probe".to_string()),
)
.child(
Button::new("child-only-probe")
.fully_rounded(true)
.padded(false)
.child(div().size(px(24.)))
.debug_selector(|| "child-only-probe".to_string()),
)
.child( .child(
DropdownMenu::new("icon-only-dropdown") DropdownMenu::new("icon-only-dropdown")
.icon(IconRole::More) .icon(IconRole::More)
@@ -49,11 +68,23 @@ fn buttons_render_at_their_token_heights(cx: &mut TestAppContext) {
let xsmall = cx let xsmall = cx
.debug_bounds("xsmall-height-probe") .debug_bounds("xsmall-height-probe")
.expect("xsmall button laid out"); .expect("xsmall button laid out");
let small = cx
.debug_bounds("small-height-probe")
.expect("small button laid out");
let large = cx
.debug_bounds("large-height-probe")
.expect("large button laid out");
let icon_only = cx let icon_only = cx
.debug_bounds("icon-only-dropdown-trigger") .debug_bounds("icon-only-dropdown-trigger")
.expect("icon-only dropdown laid out"); .expect("icon-only dropdown laid out");
let child_only = cx
.debug_bounds("child-only-probe")
.expect("child-only button laid out");
assert_eq!(medium.size.height, px(32.0)); assert_eq!(medium.size.height, px(32.0));
assert_eq!(xsmall.size.height, px(20.0)); assert_eq!(xsmall.size.height, px(20.0));
assert_eq!(small.size.height, px(28.0));
assert_eq!(large.size.height, px(40.0));
assert_eq!(icon_only.size, size(px(32.0), px(32.0))); assert_eq!(icon_only.size, size(px(32.0), px(32.0)));
assert_eq!(child_only.size, size(px(32.0), px(32.0)));
} }
-36
View File
@@ -1,36 +0,0 @@
# ui gaps
Known Signed features `ui` does not currently support. Recorded instead of
modifying it or reimplementing a parallel mechanism.
1. **Custom themes.** `Signed Light`/`Signed Dark`, theme registry names, font
sizes, radii, focus ring, and shadows are removed. `ui` derives colors,
radii, fonts, and chrome from the OS; `AppearanceMode` is preserved through
`set_mode_override`/`follow_system`.
2. **Tab bar navigation.** The previous/next tab buttons and
`tab_bar.hide_navigation_buttons` are removed; `ui` tab strip has none.
3. **Traffic-light placement.** Custom macOS traffic-light position and the 44px
tab bar are removed. `ui` uses `theme.titlebar_height` and a fixed 78px
traffic-light pad.
4. **Virtual list.** `ui` has no data-driven virtual list. Screens keep
`gpui::uniform_list` for fixed-height lists and `ScrollArea` for the Inbox.
5. **Editable code field.** `ui` code view is read-only and supports four
grammars. Signed only previews files read-only; other extensions render as
plain text.
6. **Hunk-only diffs.** The `ui` `DiffViewState` needs the full old and new texts;
`CommitDiff` carries hunks only. The custom hunk rows are retained.
7. **Tree data.** `ui` tree is flat with caller-managed expansion.
Folder rows use `IconRole::Folder` and file rows use `IconRole::File`.
8. **Dock panels.** `ui` has no dock, tab-group, or view registry API: `Panel`
covers one split row and `Resizable` stacked panes. Per-repository panels
register a builder keyed by a unique id and stay in the builder map. No dock
persistence, zoom, or bottom/right placement; splits only.
9. **Dialogs.** Dialogs are elements mounted at the window root; there is no
`window.open_dialog`, dialog stack, or non-dismissible option. A single-slot
`DialogHost` is used, and the passphrase dialog ignores dismiss requests.
10. **Notifications.** `ui` toast shows one toast at a time; backend errors
queue but only the current toast is visible.
11. **Segmented badges.** `Segmented` has no badge slot; filter counts fold
into labels.
12. **Combobox trigger.** `Combobox` has no custom trigger renderer; branch/tag
selectors lose the leading git icon and custom caret.