chore: replace pixel metrics with rem-based sizing across ui
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Context, Entity, FontWeight, IntoElement, ParentElement as _, Render, SharedString,
|
||||
Styled as _, Window, div,
|
||||
App, Context, Entity, IntoElement, ParentElement as _, Render, SharedString, Styled as _,
|
||||
Window, div,
|
||||
};
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::common::{StyledExt as _, v_flex};
|
||||
use ui::layout::panel::Panel;
|
||||
|
||||
use crate::identity::import::ImportDialog;
|
||||
@@ -47,12 +47,7 @@ impl Render for SignedOutView {
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap_4()
|
||||
.child(
|
||||
div()
|
||||
.text_2xl()
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.child("Signed"),
|
||||
)
|
||||
.child(div().text_2xl().font_semibold().child("Signed"))
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
|
||||
@@ -7,9 +7,9 @@ use metadata::ProfileDirectory;
|
||||
use signed_core::Announcement;
|
||||
use signed_state::{RepoListStore, Timestamp};
|
||||
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::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
use crate::repo::actions::open_repo_panel;
|
||||
@@ -111,7 +111,8 @@ pub(super) fn render_card(
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.whitespace_nowrap()
|
||||
.text_ellipsis()
|
||||
.child(name),
|
||||
@@ -120,7 +121,7 @@ pub(super) fn render_card(
|
||||
this.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.whitespace_nowrap()
|
||||
.child(
|
||||
@@ -136,7 +137,7 @@ pub(super) fn render_card(
|
||||
div()
|
||||
.h_16()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.line_clamp(2)
|
||||
.child(description),
|
||||
@@ -157,7 +158,7 @@ pub(super) fn render_card(
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.whitespace_nowrap()
|
||||
.child(owner_name),
|
||||
@@ -167,7 +168,7 @@ pub(super) fn render_card(
|
||||
h_flex()
|
||||
.flex_1()
|
||||
.justify_end()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.whitespace_nowrap()
|
||||
.child(activity),
|
||||
|
||||
@@ -6,7 +6,7 @@ use signed_state::Backend;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
pub struct ExitDialog {
|
||||
handle: DialogHandle,
|
||||
@@ -31,8 +31,7 @@ impl Render for ExitDialog {
|
||||
.content(|_, cx| {
|
||||
v_flex()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
div().text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(
|
||||
"You will be signed out on this device and will need to sign in again on the next session.",
|
||||
|
||||
@@ -9,7 +9,7 @@ use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
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};
|
||||
|
||||
@@ -163,7 +163,7 @@ impl Render for ImportDialog {
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(description),
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
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};
|
||||
|
||||
@@ -96,7 +96,7 @@ impl Render for OnboardingDialog {
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Set up your Signed identity to get started."),
|
||||
)
|
||||
|
||||
@@ -9,10 +9,10 @@ use ui::avatar::Avatar;
|
||||
use ui::badge::Badge;
|
||||
use ui::common::{Sizable as _, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
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_12()
|
||||
.w_full()
|
||||
@@ -20,7 +20,7 @@ pub fn repo_header(id: SharedString, name: SharedString, unread: usize, cx: &App
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.whitespace_nowrap()
|
||||
.text_ellipsis()
|
||||
.child(name),
|
||||
@@ -36,7 +36,7 @@ pub fn empty_section_row(cx: &App) -> AnyElement {
|
||||
.h_12()
|
||||
.w_full()
|
||||
.px_3()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.bg(cx.theme().colors.secondary)
|
||||
.rounded(cx.theme().radius.control)
|
||||
@@ -78,7 +78,7 @@ pub fn thread(
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(
|
||||
h_flex()
|
||||
.size_6()
|
||||
@@ -134,7 +134,7 @@ fn sub_activity(
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.gap_1()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.child(
|
||||
Avatar::new(event.pubkey)
|
||||
.name(name.clone())
|
||||
@@ -184,7 +184,7 @@ pub fn empty_state(message: &'static str, cx: &App) -> AnyElement {
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(SharedString::from(message)),
|
||||
)
|
||||
|
||||
@@ -12,11 +12,10 @@ use nostr::prelude::{Event, EventId, Kind, PublicKey, Timestamp};
|
||||
use signed_core::{InboxItem, InboxReadState, RepoAddr};
|
||||
use signed_state::{Backend, BackendEvent, Inbox, RefreshGate, RefreshRequest, RepoListStore};
|
||||
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::layout::panel::Panel;
|
||||
use ui::scroll_area::ScrollArea;
|
||||
use ui::theme::{TextRole, Typeset as _};
|
||||
|
||||
mod helpers;
|
||||
|
||||
@@ -351,7 +350,7 @@ impl InboxView {
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default()
|
||||
));
|
||||
repo_header(id, name, section.unread, cx)
|
||||
repo_header(id, name, section.unread)
|
||||
}
|
||||
InboxRow::Entry(section_ix, entry_ix) => {
|
||||
let Some(section) = self.sections.get(section_ix) else {
|
||||
@@ -416,7 +415,8 @@ impl Render for InboxView {
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.child(SharedString::from("Inbox")),
|
||||
)
|
||||
.child(div().flex_1())
|
||||
|
||||
@@ -7,12 +7,12 @@ use nostr::prelude::{EventId, PublicKey};
|
||||
use signed_core::GitEvent;
|
||||
use signed_state::RepoStore;
|
||||
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::input::InputState;
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::scroll_area::ScrollArea;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
use crate::issues::helpers::{comment_form, comments_section, issue_roots, sidebar_section};
|
||||
@@ -147,7 +147,8 @@ impl Render for IssueDetailView {
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.child(title),
|
||||
),
|
||||
)
|
||||
@@ -160,7 +161,7 @@ impl Render for IssueDetailView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
@@ -187,9 +188,7 @@ impl Render for IssueDetailView {
|
||||
.child(SharedString::from(age)),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div().typeset(TextRole::Body, cx).child(content),
|
||||
),
|
||||
.child(div().text_base().child(content)),
|
||||
)
|
||||
.child(comments_section(
|
||||
&self.store,
|
||||
|
||||
@@ -9,10 +9,10 @@ use signed_state::RepoStore;
|
||||
use ui::avatar::Avatar;
|
||||
use ui::badge::{Badge, BadgeVariant};
|
||||
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::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
use utils::relative_time;
|
||||
|
||||
@@ -129,12 +129,7 @@ pub(crate) fn sidebar_section(
|
||||
.picture(profile.picture())
|
||||
.small(),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_ellipsis()
|
||||
.child(name),
|
||||
)
|
||||
.child(div().text_base().text_ellipsis().child(name))
|
||||
.into_any_element()
|
||||
})),
|
||||
)
|
||||
@@ -146,7 +141,7 @@ pub(crate) fn sidebar_section(
|
||||
if labels.is_empty() {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("None yet."),
|
||||
)
|
||||
@@ -173,7 +168,7 @@ pub(crate) fn comments_section(
|
||||
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child(div().typeset(TextRole::Caption2, cx).child(title))
|
||||
.child(div().text_xs().font_medium().child(title))
|
||||
.children(comments.iter().map(|comment| {
|
||||
let profile = directory.read(cx).profile(&comment.pubkey, cx);
|
||||
let author = profile.name();
|
||||
@@ -189,7 +184,7 @@ pub(crate) fn comments_section(
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
@@ -212,7 +207,7 @@ pub(crate) fn comments_section(
|
||||
.child(SharedString::from(age)),
|
||||
),
|
||||
)
|
||||
.child(div().typeset(TextRole::Body, cx).child(content))
|
||||
.child(div().text_base().child(content))
|
||||
}))
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -241,7 +236,7 @@ pub(crate) fn comment_form(
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(
|
||||
Icon::named(IconRole::Markdown)
|
||||
|
||||
@@ -17,7 +17,7 @@ use ui::icons::{Icon, IconRole};
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::segmented::{Segmented, SegmentedOption};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
use self::detail::IssueDetailView;
|
||||
@@ -252,7 +252,7 @@ impl Render for IssuesView {
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(title),
|
||||
@@ -260,7 +260,7 @@ impl Render for IssuesView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
|
||||
@@ -8,7 +8,7 @@ use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
pub struct NewIssueDialog {
|
||||
handle: DialogHandle,
|
||||
@@ -58,7 +58,7 @@ impl Render for NewIssueDialog {
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.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::button::Button;
|
||||
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::input::InputState;
|
||||
use ui::layout::panel::Panel;
|
||||
@@ -22,7 +22,7 @@ use ui::scroll_area::ScrollArea;
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::spinner::Spinner;
|
||||
use ui::tabs::{Tab, Tabs};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
use super::dialogs;
|
||||
@@ -376,7 +376,7 @@ impl PullRequestDetailView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
@@ -397,9 +397,7 @@ impl PullRequestDetailView {
|
||||
)
|
||||
.when(!self.description.is_empty(), |this| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.child(self.description.clone()),
|
||||
div().text_base().child(self.description.clone()),
|
||||
)
|
||||
}),
|
||||
)
|
||||
@@ -527,7 +525,8 @@ impl PullRequestDetailView {
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.text_ellipsis()
|
||||
.child(title),
|
||||
),
|
||||
@@ -574,7 +573,7 @@ impl PullRequestDetailView {
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(id.clone())
|
||||
.child(ClipboardButton::new("pr-commit", &id)),
|
||||
|
||||
@@ -9,7 +9,7 @@ use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
pub struct UpdatePrDialog {
|
||||
handle: DialogHandle,
|
||||
@@ -55,7 +55,7 @@ impl Render for UpdatePrDialog {
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Publish a new revision with the output of `git format-patch`."),
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ use ui::layout::panel::Panel;
|
||||
use ui::menu::MenuItem;
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::segmented::{Segmented, SegmentedOption};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time;
|
||||
|
||||
mod detail;
|
||||
@@ -387,7 +387,7 @@ impl Render for PullRequestsView {
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(title),
|
||||
@@ -395,7 +395,7 @@ impl Render for PullRequestsView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
|
||||
@@ -9,7 +9,7 @@ use gpui::{
|
||||
use signed_state::{CheckoutsStore, RepoStore};
|
||||
use ui::button::Button;
|
||||
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::input::{Input, InputState};
|
||||
use ui::layout::panel::Panel;
|
||||
@@ -17,7 +17,7 @@ use ui::menu::Menu;
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::spinner::Spinner;
|
||||
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 crate::repo::commit_diff::{CommitDiffView, DiffPane};
|
||||
@@ -281,17 +281,17 @@ impl NewPullRequestView {
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(label("Merge Into", cx))
|
||||
.child(label("Merge Into"))
|
||||
.child(div().w(px(160.)).child(self.base_select.clone())),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(label("Pull From", cx))
|
||||
.child(label("Pull From"))
|
||||
.child(div().w(px(160.)).child(self.compare_select.clone())),
|
||||
)
|
||||
.child(
|
||||
v_flex().gap_1().child(label("Source", cx)).child(
|
||||
v_flex().gap_1().child(label("Source")).child(
|
||||
Menu::new("pr-source")
|
||||
.open(self.source_open)
|
||||
.on_change(move |open, _, cx| {
|
||||
@@ -475,7 +475,7 @@ impl Render for NewPullRequestView {
|
||||
.when_some(self.error.clone(), |this, error| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().ramps.destructive.base)
|
||||
.child(error),
|
||||
)
|
||||
@@ -493,9 +493,6 @@ impl Render for NewPullRequestView {
|
||||
}
|
||||
}
|
||||
|
||||
fn label(text: &'static str, cx: &App) -> AnyElement {
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.child(text)
|
||||
.into_any_element()
|
||||
fn label(text: &'static str) -> AnyElement {
|
||||
div().text_xs().font_medium().child(text).into_any_element()
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use ui::common::{h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
@@ -148,7 +148,7 @@ impl Render for SendPatchView {
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(
|
||||
"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| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().ramps.destructive.base)
|
||||
.child(error),
|
||||
)
|
||||
|
||||
@@ -10,13 +10,13 @@ use gpui::{
|
||||
use signed_git::{CommitDiff, DiffStatus, FileCommit, FileDiff, Repo};
|
||||
use ui::badge::{Badge, BadgeVariant};
|
||||
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::layout::panel::Panel;
|
||||
use ui::layout::resizable::{Resizable, ResizableState};
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::spinner::Spinner;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tree::{Tree, TreeItem};
|
||||
use utils::relative_time_secs;
|
||||
|
||||
@@ -283,7 +283,8 @@ impl DiffPane {
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_color(status_color)
|
||||
.child(status_label),
|
||||
)
|
||||
@@ -291,7 +292,8 @@ impl DiffPane {
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(title),
|
||||
@@ -300,7 +302,7 @@ impl DiffPane {
|
||||
this.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.child(
|
||||
div()
|
||||
.text_color(cx.theme().ramps.success.base)
|
||||
@@ -447,7 +449,8 @@ impl CommitDiffView {
|
||||
v_flex()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(commit.summary.clone()),
|
||||
@@ -455,7 +458,7 @@ impl CommitDiffView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(SharedString::from(format!("{} committed", commit.author)))
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -472,16 +475,12 @@ impl CommitDiffView {
|
||||
),
|
||||
)
|
||||
.when_some(commit.description.as_ref(), |this, description| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.child(SharedString::from(description)),
|
||||
)
|
||||
this.child(div().text_base().child(SharedString::from(description)))
|
||||
})
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.child(Badge::new("commit-files", format!("{files} files changed")))
|
||||
.when(insertions > 0, |this| {
|
||||
this.child(
|
||||
|
||||
@@ -7,9 +7,9 @@ use nostr::prelude::PublicKey;
|
||||
use signed_core::Announcement;
|
||||
use ui::avatar::Avatar;
|
||||
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::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::middle_truncate;
|
||||
|
||||
pub struct AboutDialog {
|
||||
@@ -61,7 +61,6 @@ fn announcement_rows(
|
||||
.as_deref()
|
||||
.map(SharedString::from)
|
||||
.unwrap_or_else(|| SharedString::from("-")),
|
||||
cx,
|
||||
),
|
||||
cx,
|
||||
));
|
||||
@@ -73,7 +72,6 @@ fn announcement_rows(
|
||||
.as_deref()
|
||||
.map(SharedString::from)
|
||||
.unwrap_or_else(|| SharedString::from("-")),
|
||||
cx,
|
||||
),
|
||||
cx,
|
||||
));
|
||||
@@ -99,13 +97,13 @@ fn announcement_rows(
|
||||
}
|
||||
|
||||
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() {
|
||||
rows.push(row(
|
||||
"Hashtags",
|
||||
text(SharedString::from(announcement.hashtags.join(", ")), cx),
|
||||
text(SharedString::from(announcement.hashtags.join(", "))),
|
||||
cx,
|
||||
));
|
||||
}
|
||||
@@ -151,7 +149,8 @@ fn row(label: &'static str, value: AnyElement, cx: &App) -> AnyElement {
|
||||
.min_w_0()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(label),
|
||||
)
|
||||
@@ -159,12 +158,12 @@ fn row(label: &'static str, value: AnyElement, cx: &App) -> AnyElement {
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn text<T>(value: T, cx: &App) -> AnyElement
|
||||
fn text<T>(value: T) -> AnyElement
|
||||
where
|
||||
T: Into<SharedString>,
|
||||
{
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.w_full()
|
||||
.min_w_0()
|
||||
.child(value.into())
|
||||
@@ -179,7 +178,7 @@ fn copy_value(id: &'static str, value: String, cx: &App) -> AnyElement {
|
||||
.child(
|
||||
div()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.min_w_0()
|
||||
.child(SharedString::from(value.clone())),
|
||||
)
|
||||
@@ -216,7 +215,7 @@ fn maintainers(
|
||||
.overflow_hidden()
|
||||
.whitespace_nowrap()
|
||||
.text_ellipsis()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(name),
|
||||
)
|
||||
.into_any_element()
|
||||
@@ -243,7 +242,7 @@ fn list(id: &'static str, items: impl IntoIterator<Item = String>, cx: &App) ->
|
||||
.min_w_0()
|
||||
.whitespace_nowrap()
|
||||
.text_ellipsis()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child(SharedString::from(middle_truncate(&item, 28, 16))),
|
||||
)
|
||||
.child(ClipboardButton::new(
|
||||
|
||||
@@ -10,8 +10,7 @@ use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::{Sizable, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::switch::Switch;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
/// 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()
|
||||
.justify_between()
|
||||
.items_center()
|
||||
.child(div().typeset(TextRole::Caption, cx).child("Grasp servers"))
|
||||
.child(div().text_xs().child("Grasp servers"))
|
||||
.child(
|
||||
Button::new("toggle-grasp-servers")
|
||||
.icon(Icon::named(if servers_enabled {
|
||||
@@ -99,7 +98,7 @@ pub fn grasp_servers_field(
|
||||
section
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Where the repository is hosted"),
|
||||
)
|
||||
@@ -133,7 +132,7 @@ pub fn grasp_servers_field(
|
||||
.when(loading_servers, |section| {
|
||||
section.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Loading your grasp servers..."),
|
||||
)
|
||||
@@ -141,7 +140,7 @@ pub fn grasp_servers_field(
|
||||
.when_some(error, |section, error| {
|
||||
section.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().ramps.destructive.base)
|
||||
.child(error),
|
||||
)
|
||||
@@ -167,7 +166,7 @@ fn render_server_row(
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(server_host(relay)),
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ use ui::field::Field;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
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 crate::repo::RepoDetailView;
|
||||
@@ -186,7 +186,7 @@ impl Render for InitRepoDialog {
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Publish this local repository to Nostr."),
|
||||
)
|
||||
@@ -209,7 +209,7 @@ impl Render for InitRepoDialog {
|
||||
.w_full()
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(folder.clone()),
|
||||
|
||||
@@ -6,7 +6,7 @@ use signed_state::RepoStore;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
pub struct ResetRemoteDialog {
|
||||
handle: DialogHandle,
|
||||
@@ -39,16 +39,14 @@ impl Render for ResetRemoteDialog {
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
div().text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.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.",
|
||||
),
|
||||
)
|
||||
.child(if deleted.is_empty() {
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
div().text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("No server refs will be deleted.")
|
||||
.into_any_element()
|
||||
@@ -56,8 +54,7 @@ impl Render for ResetRemoteDialog {
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.children(deleted.iter().map(|name| {
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
div().text_base()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.child(name.clone())
|
||||
}))
|
||||
|
||||
@@ -9,10 +9,10 @@ use gpui::{
|
||||
};
|
||||
use signed_git::{FileCommit, Repo, WorktreeSnapshot};
|
||||
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::markdown::MarkdownViewState;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tree::{Tree, TreeItem};
|
||||
|
||||
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)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(pane_title),
|
||||
@@ -364,14 +365,14 @@ impl RepoFilesView {
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.child(commit.id.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.max_w(px(250.))
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(commit.summary.clone()),
|
||||
|
||||
@@ -9,12 +9,12 @@ use signed_state::{Backend, Nip34Kind};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
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::icons::{Icon, IconRole};
|
||||
use ui::menu::MenuItem;
|
||||
use ui::popover::Popover;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
use utils::relative_time_secs;
|
||||
|
||||
@@ -103,14 +103,15 @@ impl RepoDetailView {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.child(avatar)
|
||||
.child(name),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.line_clamp(3)
|
||||
.child(description),
|
||||
@@ -151,28 +152,24 @@ impl RepoDetailView {
|
||||
"Clone with ngit",
|
||||
"copy-ngit",
|
||||
&ngit_for_popover,
|
||||
cx,
|
||||
))
|
||||
.child(clone_group(
|
||||
"Clone with nak",
|
||||
"copy-nak",
|
||||
&nak_for_popover,
|
||||
cx,
|
||||
))
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Grasp Servers"),
|
||||
)
|
||||
.when(git_for_popover.is_empty(), |this| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.child("No git clone urls."),
|
||||
div().text_xs().child("No git clone urls."),
|
||||
)
|
||||
})
|
||||
.children(git_for_popover.iter().enumerate().map(
|
||||
@@ -325,7 +322,7 @@ impl RepoDetailView {
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(path),
|
||||
)
|
||||
@@ -383,21 +380,21 @@ impl RepoDetailView {
|
||||
.child(
|
||||
div()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(SharedString::from(short)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.max_w(px(220.))
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(commit.summary.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(relative_time_secs(commit.time)),
|
||||
)
|
||||
@@ -434,17 +431,12 @@ impl RepoDetailView {
|
||||
.picture(owner.picture())
|
||||
.small(),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.whitespace_nowrap()
|
||||
.child(owner_name),
|
||||
),
|
||||
.child(div().text_xs().whitespace_nowrap().child(owner_name)),
|
||||
)
|
||||
.when(!rest.is_empty(), |this| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(SharedString::from(format!("+{}", rest.len()))),
|
||||
)
|
||||
|
||||
@@ -14,9 +14,9 @@ use signed_state::{Nip34Binding, RepoListStore, RepoStore};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::clipboard::ClipboardButton;
|
||||
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::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use utils::relative_time_secs;
|
||||
|
||||
use super::RepoDetailView;
|
||||
@@ -52,19 +52,10 @@ pub(super) struct RepoData {
|
||||
pub(super) head_commit: Option<FileCommit>,
|
||||
}
|
||||
|
||||
pub(super) fn clone_group(
|
||||
label: &str,
|
||||
id: &'static str,
|
||||
command: &SharedString,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
pub(super) fn clone_group(label: &str, id: &'static str, command: &SharedString) -> AnyElement {
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.child(SharedString::from(label)),
|
||||
)
|
||||
.child(div().text_xs().child(SharedString::from(label)))
|
||||
.child(ClipboardButton::new(id, command.clone()))
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -114,7 +105,7 @@ pub(super) fn fork_row(
|
||||
let row = h_flex()
|
||||
.gap_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(Icon::named(IconRole::GitBranch).small())
|
||||
.child(div().whitespace_nowrap().text_ellipsis().child(label));
|
||||
@@ -187,7 +178,7 @@ pub(super) fn bound_repo_label(
|
||||
h_flex()
|
||||
.flex_shrink_0()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.child("Initialized by")
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.when_some(profile, |this, profile| {
|
||||
@@ -208,7 +199,8 @@ pub(super) fn bound_repo_label(
|
||||
.when_some(binding.identifier.as_deref(), |this, ident| {
|
||||
this.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.child(SharedString::from(format!("/{ident}"))),
|
||||
)
|
||||
})
|
||||
@@ -292,7 +284,7 @@ pub(super) fn render_diff_row(hunks: &[DiffHunk], row: DiffRow, cx: &App) -> Any
|
||||
.w_full()
|
||||
.h(px(DIFF_ROW_HEIGHT))
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.border_y_1()
|
||||
.border_color(cx.theme().colors.border)
|
||||
@@ -318,7 +310,7 @@ fn render_diff_line(line: &DiffLine, cx: &App) -> AnyElement {
|
||||
.w_full()
|
||||
.h(px(DIFF_ROW_HEIGHT))
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.when_some(bg, |this, bg| this.bg(bg))
|
||||
.child(
|
||||
div()
|
||||
@@ -379,7 +371,7 @@ pub(crate) fn commit_row(
|
||||
.child(
|
||||
div()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(commit.id.clone()),
|
||||
)
|
||||
@@ -387,7 +379,7 @@ pub(crate) fn commit_row(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(commit.summary.clone()),
|
||||
@@ -396,7 +388,7 @@ pub(crate) fn commit_row(
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(commit.author.clone())
|
||||
.child(relative_time_secs(commit.time)),
|
||||
|
||||
@@ -13,7 +13,7 @@ use ui::common::{Sizable as _, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::scrollbar::Scrollbar;
|
||||
use ui::spinner::Spinner;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use super::RepoDetailView;
|
||||
@@ -249,7 +249,7 @@ impl Render for RepoHistoryView {
|
||||
div()
|
||||
.py_2()
|
||||
.w_full()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(format!("Showing {shown} of {total} commits")),
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ use ui::icons::{Icon, IconRole};
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::sidebar::{Sidebar, SidebarEntry};
|
||||
use ui::spinner::Spinner;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
pub mod actions;
|
||||
pub mod commit_diff;
|
||||
@@ -854,7 +854,7 @@ impl RepoDetailView {
|
||||
.child(Spinner::new("repo-loading"))
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(label),
|
||||
)
|
||||
|
||||
@@ -6,11 +6,11 @@ use gpui::{
|
||||
};
|
||||
use settings::{AppearanceMode, EventFetchingStrategy, SettingsStore};
|
||||
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::input::{Input, InputState};
|
||||
use ui::select::{Select, SelectOption};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use crate::repo::dialogs::grasp_servers::{normalize_server, server_host};
|
||||
@@ -31,10 +31,10 @@ pub fn setting_row(
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.gap_1()
|
||||
.child(div().typeset(TextRole::Headline, cx).child(title.into()))
|
||||
.child(div().text_sm().font_semibold().child(title.into()))
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(description.into()),
|
||||
),
|
||||
@@ -56,10 +56,10 @@ pub fn setting_block(
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(div().typeset(TextRole::Headline, cx).child(title.into()))
|
||||
.child(div().text_sm().font_semibold().child(title.into()))
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(description.into()),
|
||||
),
|
||||
@@ -127,7 +127,7 @@ pub fn grasp_servers_editor(input: &Entity<InputState>, cx: &App) -> AnyElement
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(display_server(server)),
|
||||
)
|
||||
@@ -227,7 +227,7 @@ pub fn scan_paths_editor(cx: &App) -> AnyElement {
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(path.display().to_string()),
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ use signed_state::{Backend, BackendEvent, PushStepStatus};
|
||||
use ui::common::{h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
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.
|
||||
#[derive(Debug, Default)]
|
||||
@@ -69,7 +69,7 @@ impl DialogProgress {
|
||||
pub fn error_row(error: &Option<SharedString>, cx: &App) -> Option<AnyElement> {
|
||||
error.as_ref().map(|message| {
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().ramps.destructive.base)
|
||||
.child(message.clone())
|
||||
.into_any_element()
|
||||
@@ -90,14 +90,14 @@ pub fn push_steps_row(steps: &[PushStepStatus], cx: &App) -> Option<AnyElement>
|
||||
match status {
|
||||
PushStepStatus::Running(_) => h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(Spinner::new("push-step"))
|
||||
.child(label)
|
||||
.into_any_element(),
|
||||
PushStepStatus::Done(_) => h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().colors.foreground)
|
||||
.child(
|
||||
Icon::named(IconRole::Check)
|
||||
@@ -108,7 +108,7 @@ pub fn push_steps_row(steps: &[PushStepStatus], cx: &App) -> Option<AnyElement>
|
||||
.into_any_element(),
|
||||
PushStepStatus::Failed(_, reason) => h_flex()
|
||||
.gap_2()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_base()
|
||||
.text_color(cx.theme().ramps.destructive.base)
|
||||
.child(
|
||||
Icon::named(IconRole::Close)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use gpui::{AnyElement, App, IntoElement, ParentElement as _, SharedString, Styled as _, div};
|
||||
use signed_core::RepoStatus;
|
||||
use ui::badge::{Badge, BadgeVariant};
|
||||
use ui::common::StyledExt as _;
|
||||
use ui::empty_state::EmptyState;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
/// 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.
|
||||
pub fn section_label(text: impl Into<SharedString>, cx: &App) -> AnyElement {
|
||||
div()
|
||||
.typeset(TextRole::Caption2, cx)
|
||||
.text_xs()
|
||||
.font_medium()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(text.into())
|
||||
.into_any_element()
|
||||
|
||||
@@ -4,7 +4,7 @@ use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render, Role,
|
||||
SharedString, StatefulInteractiveElement as _, Styled as _, UniformListScrollHandle, Window,
|
||||
div, px, uniform_list,
|
||||
div, px, rems, uniform_list,
|
||||
};
|
||||
use metadata::ProfileDirectory;
|
||||
use nostr::prelude::PublicKey;
|
||||
@@ -16,7 +16,7 @@ use ui::input::{Input, InputState};
|
||||
use ui::kbd::Kbd;
|
||||
use ui::popover::Popover;
|
||||
use ui::separator::Separator;
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use super::{CreateRepository, REPOSITORY_KEY_CONTEXT, SwitchRepository};
|
||||
@@ -153,7 +153,7 @@ impl Render for RepositorySwitcher {
|
||||
.cloned()
|
||||
.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_entries = visible.clone();
|
||||
let list_directory = directory.clone();
|
||||
@@ -189,7 +189,7 @@ impl Render for RepositorySwitcher {
|
||||
.p_3()
|
||||
.text_color(theme.colors.muted_foreground)
|
||||
.text_center()
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_sm()
|
||||
.child("No repositories found"),
|
||||
)
|
||||
} else {
|
||||
@@ -219,7 +219,7 @@ impl Render for RepositorySwitcher {
|
||||
.px_3()
|
||||
.gap_2()
|
||||
.rounded(theme.radius.control)
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_sm()
|
||||
.hover(|row| row.bg(theme.colors.muted))
|
||||
.child(entry.avatar(&list_directory, cx))
|
||||
.child(
|
||||
|
||||
@@ -23,7 +23,7 @@ use gpui::{
|
||||
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
|
||||
IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
|
||||
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, deferred, div,
|
||||
ease_out_quint,
|
||||
ease_out_quint, rems,
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
use crate::icons::{Icon, IconRole};
|
||||
use crate::theme::{
|
||||
ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole,
|
||||
Typeset as _,
|
||||
};
|
||||
use crate::theme::{ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE};
|
||||
|
||||
/// How alarming an [`Alert`] is; picks the accent color.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
@@ -166,17 +163,14 @@ impl RenderOnce for Alert {
|
||||
let foreground = theme.colors.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()
|
||||
.flex_1()
|
||||
.gap_0p5()
|
||||
.when_some(self.title.clone(), |alert, title| {
|
||||
alert.child(
|
||||
div()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.text_color(foreground)
|
||||
.child(title),
|
||||
)
|
||||
@@ -187,12 +181,7 @@ impl RenderOnce for Alert {
|
||||
} else {
|
||||
foreground
|
||||
};
|
||||
alert.child(
|
||||
div()
|
||||
.text_size(metrics.text_size)
|
||||
.text_color(color)
|
||||
.child(message),
|
||||
)
|
||||
alert.child(div().text_sm().text_color(color).child(message))
|
||||
});
|
||||
|
||||
let dismiss = self.on_dismiss.clone().map(|on_dismiss| {
|
||||
@@ -231,7 +220,7 @@ impl RenderOnce for Alert {
|
||||
.flex()
|
||||
.items_center()
|
||||
.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)
|
||||
@@ -267,10 +256,10 @@ impl RenderOnce for Alert {
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.size(theme.sizes.small.avatar_size)
|
||||
.size_6()
|
||||
.rounded(theme.radius.full)
|
||||
.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),
|
||||
|
||||
@@ -18,7 +18,7 @@ use gpui::{
|
||||
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::{
|
||||
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,
|
||||
@@ -103,15 +103,10 @@ impl gpui::Styled 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();
|
||||
// Avatars sit one class below the shared control scale.
|
||||
let size = match self.size {
|
||||
Size::XSmall | Size::Small => Size::XSmall,
|
||||
Size::Medium => Size::Small,
|
||||
Size::Large => Size::Medium,
|
||||
};
|
||||
let side = theme.sizes.resolve(size).avatar_size;
|
||||
let size = self.size;
|
||||
let side = size.avatar_rems() * window.rem_size();
|
||||
|
||||
let radius = if self.fully_rounded {
|
||||
theme.radius.full
|
||||
@@ -124,7 +119,7 @@ impl RenderOnce for Avatar {
|
||||
.flex_none()
|
||||
.justify_center()
|
||||
.overflow_hidden()
|
||||
.size(side)
|
||||
.avatar_size(size)
|
||||
.bg(theme.colors.secondary)
|
||||
.rounded(radius)
|
||||
.role(Role::Image)
|
||||
|
||||
@@ -17,7 +17,7 @@ use gpui::{
|
||||
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::theme::{ActiveTheme as _, Size, Theme};
|
||||
|
||||
@@ -150,15 +150,10 @@ impl gpui::Styled for Badge {
|
||||
impl RenderOnce for Badge {
|
||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(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 size = self.size;
|
||||
let (background, foreground, border) = self.variant.tokens(theme);
|
||||
|
||||
h_flex()
|
||||
let badge = h_flex()
|
||||
.id(self.id.clone())
|
||||
.flex_none()
|
||||
.justify_center()
|
||||
@@ -168,12 +163,16 @@ impl RenderOnce for Badge {
|
||||
.border_color(border)
|
||||
.bg(background)
|
||||
.text_color(foreground)
|
||||
.text_size(label_size)
|
||||
.px(label_size * 0.5)
|
||||
.min_w(square)
|
||||
.min_h(square)
|
||||
.control_caption_text(size);
|
||||
let badge = match size {
|
||||
Size::XSmall | Size::Small => badge.h_5().min_w_5().px_1(),
|
||||
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| {
|
||||
badge.child(icon.size(metrics.dense_icon_size).color(foreground))
|
||||
badge.child(icon.size(size.dense_icon_rems()).color(foreground))
|
||||
})
|
||||
.child(self.label)
|
||||
.refine_style(&self.style)
|
||||
|
||||
@@ -21,12 +21,12 @@ use gpui::{
|
||||
};
|
||||
|
||||
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::icons::Icon;
|
||||
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.
|
||||
type ClickHandler = Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>;
|
||||
@@ -70,7 +70,6 @@ pub struct Button {
|
||||
children: Vec<AnyElement>,
|
||||
variant: ButtonVariant,
|
||||
size: Size,
|
||||
custom_metrics: Option<ControlMetrics>,
|
||||
disabled: bool,
|
||||
loading: bool,
|
||||
padded: bool,
|
||||
@@ -98,7 +97,6 @@ impl Button {
|
||||
children: Vec::new(),
|
||||
variant: ButtonVariant::default(),
|
||||
size: Size::default(),
|
||||
custom_metrics: None,
|
||||
disabled: false,
|
||||
loading: false,
|
||||
padded: true,
|
||||
@@ -147,12 +145,6 @@ impl Button {
|
||||
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
|
||||
/// turn this off.
|
||||
pub fn tab_stop(mut self, tab_stop: bool) -> Self {
|
||||
@@ -187,7 +179,7 @@ impl Button {
|
||||
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 {
|
||||
self.fully_rounded = fully_rounded;
|
||||
self
|
||||
@@ -248,10 +240,6 @@ impl RenderOnce for Button {
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
|
||||
let metrics = self
|
||||
.custom_metrics
|
||||
.unwrap_or_else(|| theme.sizes.resolve(self.size));
|
||||
|
||||
let radius = if self.fully_rounded {
|
||||
theme.radius.full
|
||||
} else {
|
||||
@@ -261,6 +249,12 @@ impl RenderOnce for Button {
|
||||
let on_click = self.on_click;
|
||||
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();
|
||||
|
||||
// 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 (background, foreground, hover, pressed) = match self.variant {
|
||||
@@ -320,15 +314,18 @@ impl RenderOnce for Button {
|
||||
ButtonSide::Left => button.justify_start(),
|
||||
ButtonSide::Right => button.justify_end(),
|
||||
})
|
||||
.h(metrics.control_height)
|
||||
.when(is_icon_only, |button| button.w(metrics.control_height))
|
||||
.when(self.full_width, |button| button.w_full())
|
||||
.when(!is_icon_only && self.padded, |button| {
|
||||
button.px(metrics.padding_x)
|
||||
.control_height(self.size)
|
||||
.when(is_icon_only || is_round_child, |button| {
|
||||
button.control_width(self.size)
|
||||
})
|
||||
.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))
|
||||
.rounded(radius)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.border_1()
|
||||
.border_color(border)
|
||||
.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))
|
||||
.children(self.children)
|
||||
.when_some(self.icon, |content, icon| {
|
||||
content.child(icon.size(metrics.icon_size))
|
||||
content.child(icon.size(self.size.icon_rems()))
|
||||
})
|
||||
} else {
|
||||
content
|
||||
.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))
|
||||
.children(self.children)
|
||||
|
||||
@@ -19,7 +19,7 @@ use gpui::{
|
||||
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::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
|
||||
|
||||
@@ -126,7 +126,7 @@ impl RenderOnce for Checkbox {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let size = self.size;
|
||||
let on_change = self.on_change;
|
||||
let next = !self.checked;
|
||||
let a11y_label = self.a11y_label.or_else(|| self.label.clone());
|
||||
@@ -134,7 +134,7 @@ impl RenderOnce for Checkbox {
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.gap_2()
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(size)
|
||||
.refine_style(&self.style)
|
||||
.when_some(self.debug_selector, |checkbox, selector| {
|
||||
checkbox.debug_selector(move || selector())
|
||||
@@ -157,7 +157,7 @@ impl RenderOnce for Checkbox {
|
||||
h_flex()
|
||||
.justify_center()
|
||||
.flex_none()
|
||||
.size(metrics.indicator_size)
|
||||
.control_indicator(size)
|
||||
.rounded(theme.radius.sm)
|
||||
.border_1()
|
||||
.when(self.checked, |indicator| {
|
||||
@@ -171,7 +171,7 @@ impl RenderOnce for Checkbox {
|
||||
})
|
||||
.child(
|
||||
icon(IconRole::Check)
|
||||
.size(metrics.dense_icon_size)
|
||||
.size(size.dense_icon_rems())
|
||||
.color(colors.primary_foreground),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ use gpui::{
|
||||
IntoElement, KeyBinding, KeyBindingContextPredicate, MouseButton, MouseDownEvent,
|
||||
MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Render, ScrollStrategy,
|
||||
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};
|
||||
@@ -297,14 +297,14 @@ impl gpui::Focusable 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 colors = theme.colors;
|
||||
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 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 state = cx.entity();
|
||||
@@ -334,7 +334,7 @@ impl Render for CodeViewState {
|
||||
theme.mono_font,
|
||||
theme.colors,
|
||||
theme.ramps,
|
||||
theme.sizes.small.text_size,
|
||||
text_size,
|
||||
line_height,
|
||||
cx,
|
||||
)
|
||||
@@ -350,7 +350,7 @@ impl Render for CodeViewState {
|
||||
.id((id.clone(), "view"))
|
||||
.relative()
|
||||
.size_full()
|
||||
.text_size(text_size)
|
||||
.text_xs()
|
||||
.font_family(mono_font)
|
||||
.text_color(colors.foreground)
|
||||
.key_context(CODE_VIEW_CONTEXT)
|
||||
@@ -366,7 +366,7 @@ impl Render for CodeViewState {
|
||||
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 code = state.read(cx);
|
||||
code.position_at(
|
||||
@@ -403,7 +403,7 @@ impl Render for CodeViewState {
|
||||
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 code = state.read(cx);
|
||||
code.position_at(
|
||||
@@ -584,6 +584,7 @@ fn render_row(
|
||||
.debug_selector(move || format!("{id}-row-{line_ix}"))
|
||||
.id(("code-row", line_ix))
|
||||
.w_full()
|
||||
.text_xs()
|
||||
.h(line_height)
|
||||
.flex()
|
||||
.items_center()
|
||||
|
||||
@@ -37,7 +37,7 @@ use gpui::{
|
||||
};
|
||||
|
||||
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::scroll_area::ScrollArea;
|
||||
@@ -511,12 +511,10 @@ where
|
||||
T: Clone + PartialEq + 'static,
|
||||
{
|
||||
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 metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
(
|
||||
metrics,
|
||||
theme.colors,
|
||||
theme.radius,
|
||||
theme.colors.border,
|
||||
@@ -524,7 +522,6 @@ where
|
||||
)
|
||||
};
|
||||
|
||||
let icon_size = metrics.dense_icon_size;
|
||||
let id = self.id.clone();
|
||||
let state = cx.entity();
|
||||
let open = self.highlight.is_some();
|
||||
@@ -556,7 +553,7 @@ where
|
||||
})
|
||||
.child(
|
||||
icon(IconRole::ChevronDown)
|
||||
.size(icon_size)
|
||||
.size(self.size.dense_icon_rems())
|
||||
.color(colors.muted_foreground),
|
||||
);
|
||||
|
||||
@@ -616,8 +613,10 @@ where
|
||||
.child(
|
||||
h_flex()
|
||||
.absolute()
|
||||
.right(metrics.dense_padding_x)
|
||||
.top((metrics.input_height - icon_size) / 2.)
|
||||
.right(self.size.dense_padding_x_rems())
|
||||
.top_0()
|
||||
.bottom_0()
|
||||
.items_center()
|
||||
.child(chevron),
|
||||
)
|
||||
.when(open, |wrapper| {
|
||||
@@ -648,7 +647,8 @@ where
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(metrics.control_height)
|
||||
.control_height(self.size)
|
||||
.control_text(self.size)
|
||||
.rounded(radius.sm)
|
||||
.when(highlighted, |row| row.bg(colors.muted))
|
||||
.when(!highlighted, |row| row.hover(|row| row.bg(colors.muted)))
|
||||
@@ -683,7 +683,7 @@ where
|
||||
.when(checked, |row| {
|
||||
row.child(
|
||||
icon(IconRole::Check)
|
||||
.size(icon_size)
|
||||
.size(self.size.dense_icon_rems())
|
||||
.color(colors.foreground),
|
||||
)
|
||||
})
|
||||
@@ -695,7 +695,7 @@ where
|
||||
div()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.text_size(metrics.caption_size)
|
||||
.control_caption_text(self.size)
|
||||
.text_color(colors.muted_foreground)
|
||||
.child("No matches")
|
||||
.into_any_element()
|
||||
|
||||
@@ -31,14 +31,14 @@ use gpui::{
|
||||
AnyElement, App, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding,
|
||||
MouseButton, ParentElement as _, Render, Role, ScrollHandle, SharedString,
|
||||
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::input::{Input, InputState, InputStateEvent};
|
||||
use crate::components::scroll_area::{ScrollArea, ScrollAxes};
|
||||
use crate::icons::Icon;
|
||||
use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size};
|
||||
use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT};
|
||||
|
||||
actions!(
|
||||
command_palette,
|
||||
@@ -371,12 +371,11 @@ impl Render for CommandPaletteState {
|
||||
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();
|
||||
(
|
||||
theme.colors,
|
||||
theme.radius,
|
||||
theme.sizes.resolve(Size::default()),
|
||||
theme.colors.border,
|
||||
theme.elevations.dialog.shadows(),
|
||||
theme.titlebar_height,
|
||||
@@ -407,8 +406,8 @@ impl Render for CommandPaletteState {
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(metrics.control_height)
|
||||
.text_size(metrics.text_size)
|
||||
.min_h_8()
|
||||
.text_sm()
|
||||
.line_height(relative(1.0))
|
||||
.rounded(radius.sm)
|
||||
.when(highlighted, |row| row.bg(colors.muted))
|
||||
@@ -431,7 +430,7 @@ impl Render for CommandPaletteState {
|
||||
}
|
||||
})
|
||||
.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(
|
||||
div()
|
||||
@@ -446,7 +445,7 @@ impl Render for CommandPaletteState {
|
||||
row.child(
|
||||
div()
|
||||
.flex_shrink_0()
|
||||
.text_size(metrics.caption_size)
|
||||
.text_xs()
|
||||
.text_color(colors.muted_foreground)
|
||||
.child(hint),
|
||||
)
|
||||
@@ -459,7 +458,7 @@ impl Render for CommandPaletteState {
|
||||
div()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.text_size(metrics.caption_size)
|
||||
.text_xs()
|
||||
.text_color(colors.muted_foreground)
|
||||
.child("No matches")
|
||||
.into_any_element()
|
||||
|
||||
@@ -14,9 +14,9 @@ use std::collections::HashMap;
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Bounds, BoxShadow, Div, ElementId, FocusHandle, Global, Hsla, IntoElement, Pixels,
|
||||
Refineable as _, StatefulInteractiveElement, StyleRefinement, Styled, Window, WindowId, div,
|
||||
px,
|
||||
App, Bounds, BoxShadow, Div, ElementId, FocusHandle, FontWeight, Global, Hsla, IntoElement,
|
||||
Pixels, Refineable as _, Rems, StatefulInteractiveElement, StyleRefinement, Styled, Window,
|
||||
WindowId, div, px, rems,
|
||||
};
|
||||
|
||||
pub use crate::theme::Size;
|
||||
@@ -59,6 +59,20 @@ pub trait StyledExt: Styled + Sized {
|
||||
self.style().refine(style);
|
||||
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 {}
|
||||
@@ -230,3 +244,283 @@ pub trait Sizable: Sized {
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ use std::rc::Rc;
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId,
|
||||
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _,
|
||||
RenderOnce, Role, ScrollHandle, SharedString, StatefulInteractiveElement as _, StyleRefinement,
|
||||
Styled as _, Window, canvas, deferred, div, ease_out_quint, relative,
|
||||
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, InteractiveElement,
|
||||
IntoElement, KeyDownEvent, MouseButton, ParentElement as _, RenderOnce, Role, ScrollHandle,
|
||||
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, canvas,
|
||||
deferred, div, ease_out_quint, relative,
|
||||
};
|
||||
|
||||
use crate::components::button::{Button, ButtonVariant};
|
||||
@@ -38,7 +38,7 @@ use crate::components::grain::grain;
|
||||
use crate::components::scroll_area::ScrollArea;
|
||||
use crate::icons::IconRole;
|
||||
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.
|
||||
pub type ChangeHandler = Rc<dyn Fn(bool, &mut Window, &mut App)>;
|
||||
@@ -336,13 +336,14 @@ impl RenderOnce for Dialog {
|
||||
.px_2()
|
||||
.gap_2()
|
||||
.justify_between()
|
||||
.child(div().size_5())
|
||||
.when(show_close, |row| row.child(div().w_7()))
|
||||
.when_some(self.title.clone(), |row, title| {
|
||||
row.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.text_center()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.child(title),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ use gpui::{
|
||||
App, Context, ElementId, HighlightStyle, InteractiveElement as _, IntoElement,
|
||||
ListHorizontalSizingBehavior, ParentElement as _, Pixels, Render, ScrollStrategy, SharedString,
|
||||
StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle, Window, div,
|
||||
point, uniform_list,
|
||||
point, rems, uniform_list,
|
||||
};
|
||||
use similar::{Change, ChangeTag, TextDiff};
|
||||
|
||||
@@ -459,9 +459,8 @@ impl DiffViewState {
|
||||
}
|
||||
|
||||
impl Render for DiffViewState {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let text_size = theme.sizes.small.text_size;
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let text_size = rems(0.75).to_pixels(window.rem_size());
|
||||
|
||||
let id = self.id.clone();
|
||||
let state = cx.entity();
|
||||
@@ -479,6 +478,7 @@ impl Render for DiffViewState {
|
||||
&diff.row_layouts[row_index],
|
||||
row_index,
|
||||
options,
|
||||
text_size,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
@@ -497,7 +497,7 @@ impl Render for DiffViewState {
|
||||
.id((id.clone(), "view"))
|
||||
.relative()
|
||||
.size_full()
|
||||
.text_size(text_size)
|
||||
.text_xs()
|
||||
.when_some(self.a11y_label.clone(), |view, label| {
|
||||
view.aria_label(label)
|
||||
})
|
||||
@@ -518,13 +518,13 @@ fn render_row(
|
||||
layout: &RowLayout,
|
||||
row_index: usize,
|
||||
options: DiffViewOptions,
|
||||
text_size: Pixels,
|
||||
cx: &App,
|
||||
) -> gpui::AnyElement {
|
||||
let theme = cx.theme();
|
||||
let mono_font = theme.mono_font;
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let text_size = theme.sizes.small.text_size;
|
||||
let line_height = text_size * 1.5;
|
||||
let char_width = text_size * MONO_ADVANCE_RATIO;
|
||||
|
||||
@@ -534,7 +534,7 @@ fn render_row(
|
||||
.w_full()
|
||||
.h(line_height)
|
||||
.font_family(mono_font)
|
||||
.text_size(text_size)
|
||||
.text_xs()
|
||||
.overflow_hidden();
|
||||
|
||||
if row.kind == DiffRowKind::Hunk {
|
||||
|
||||
@@ -24,7 +24,9 @@ use gpui::{
|
||||
};
|
||||
|
||||
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::{
|
||||
ChangeHandler, MenuChrome, MenuItem, MenuPanelSpec, TriggerBoundsCell, anchored_menu_panel,
|
||||
};
|
||||
@@ -193,7 +195,6 @@ impl RenderOnce for DropdownMenu {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let radius = theme.radius.control;
|
||||
|
||||
let ring = colors.ring;
|
||||
@@ -277,16 +278,12 @@ impl RenderOnce for DropdownMenu {
|
||||
.when(icon_only, |zone| zone.w_full())
|
||||
.gap_2()
|
||||
.line_height(relative(1.0))
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.text_color(foreground)
|
||||
.role(Role::Button)
|
||||
.when_some(a11y_label, |zone, label| zone.aria_label(label))
|
||||
.aria_expanded(self.open)
|
||||
.px(if icon_only {
|
||||
gpui::Pixels::ZERO
|
||||
} else {
|
||||
metrics.padding_x
|
||||
})
|
||||
.when(!icon_only, |zone| zone.control_padding_x(self.size))
|
||||
.when(split, |zone| zone.rounded_l(radius))
|
||||
.when(!split, |zone| {
|
||||
zone.rounded(radius)
|
||||
@@ -295,7 +292,7 @@ impl RenderOnce for DropdownMenu {
|
||||
.when(!icon_only && !split, |zone| {
|
||||
zone.child(
|
||||
icon(IconRole::ChevronDown)
|
||||
.size(metrics.dense_icon_size)
|
||||
.size(self.size.dense_icon_rems())
|
||||
.color(foreground),
|
||||
)
|
||||
})
|
||||
@@ -304,7 +301,7 @@ impl RenderOnce for DropdownMenu {
|
||||
.gap_2()
|
||||
.when(self.loading, |content| content.invisible())
|
||||
.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)),
|
||||
)
|
||||
@@ -361,7 +358,7 @@ impl RenderOnce for DropdownMenu {
|
||||
})
|
||||
.relative()
|
||||
.h_full()
|
||||
.px(metrics.dense_padding_x)
|
||||
.control_dense_padding_x(self.size)
|
||||
.rounded_r(radius)
|
||||
.rounded_l_none()
|
||||
.border_l_1()
|
||||
@@ -374,7 +371,7 @@ impl RenderOnce for DropdownMenu {
|
||||
})
|
||||
.child(
|
||||
icon(IconRole::ChevronDown)
|
||||
.size(metrics.dense_icon_size)
|
||||
.size(self.size.dense_icon_rems())
|
||||
.color(foreground),
|
||||
)
|
||||
.child(
|
||||
@@ -394,8 +391,8 @@ impl RenderOnce for DropdownMenu {
|
||||
let id = self.id.clone();
|
||||
move || format!("{id}-trigger")
|
||||
})
|
||||
.h(metrics.control_height)
|
||||
.when(icon_only, |trigger| trigger.w(metrics.control_height))
|
||||
.control_height(self.size)
|
||||
.when(icon_only, |trigger| trigger.control_width(self.size))
|
||||
.rounded(radius)
|
||||
.border_1()
|
||||
.border_color(border)
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _,
|
||||
Window, div,
|
||||
Window, div, rems,
|
||||
};
|
||||
|
||||
use crate::components::common::{StyledExt, v_flex};
|
||||
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.
|
||||
#[derive(IntoElement)]
|
||||
@@ -82,10 +82,8 @@ impl gpui::Styled for EmptyState {
|
||||
impl RenderOnce for EmptyState {
|
||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(Size::Medium);
|
||||
let muted_foreground = theme.colors.muted_foreground;
|
||||
let foreground = theme.colors.foreground;
|
||||
let illustration = metrics.icon_size * 2.0;
|
||||
|
||||
v_flex()
|
||||
.w_full()
|
||||
@@ -97,22 +95,18 @@ impl RenderOnce for EmptyState {
|
||||
state.child(
|
||||
div()
|
||||
.mb_2()
|
||||
.child(icon.size(illustration).color(muted_foreground)),
|
||||
.child(icon.size(rems(2.0)).color(muted_foreground)),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Title3, cx)
|
||||
.text_base()
|
||||
.font_semibold()
|
||||
.text_color(foreground)
|
||||
.child(self.headline),
|
||||
)
|
||||
.when_some(self.hint, |state, hint| {
|
||||
state.child(
|
||||
div()
|
||||
.typeset(TextRole::Subheadline, cx)
|
||||
.text_color(muted_foreground)
|
||||
.child(hint),
|
||||
)
|
||||
state.child(div().text_sm().text_color(muted_foreground).child(hint))
|
||||
})
|
||||
.when_some(self.action, |state, action| {
|
||||
state.child(div().mt_3().child(action))
|
||||
|
||||
@@ -19,7 +19,7 @@ use gpui::{
|
||||
};
|
||||
|
||||
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.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
@@ -102,7 +102,6 @@ impl Styled for Field {
|
||||
impl RenderOnce for Field {
|
||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.medium;
|
||||
let error_color = theme.ramps.destructive.base;
|
||||
let id = self.id.clone();
|
||||
|
||||
@@ -112,11 +111,9 @@ impl RenderOnce for Field {
|
||||
move || format!("{id}-label")
|
||||
})
|
||||
.when(self.description.is_some(), |title| {
|
||||
title.typeset(TextRole::Headline, cx)
|
||||
})
|
||||
.when(self.description.is_none(), |title| {
|
||||
title.typeset(TextRole::Callout, cx)
|
||||
title.text_sm().font_semibold()
|
||||
})
|
||||
.when(self.description.is_none(), |title| title.text_sm())
|
||||
.child(self.label.clone());
|
||||
|
||||
let control = h_flex()
|
||||
@@ -134,14 +131,14 @@ impl RenderOnce for Field {
|
||||
let id = id.clone();
|
||||
move || format!("{id}-error")
|
||||
})
|
||||
.text_size(metrics.caption_size)
|
||||
.text_xs()
|
||||
.text_color(error_color)
|
||||
.child(error)
|
||||
});
|
||||
|
||||
let description_text = |cx: &App| {
|
||||
div()
|
||||
.text_size(metrics.caption_size)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ use gpui::{
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
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::theme::{
|
||||
ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH,
|
||||
@@ -2017,7 +2017,11 @@ impl RenderOnce for Input {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
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 focused = focus_handle.is_focused(window);
|
||||
|
||||
@@ -2027,17 +2031,17 @@ impl RenderOnce for Input {
|
||||
let multiline = self.state.read(cx).is_multiline();
|
||||
let recording = focused && !self.disabled && !self.state.read(cx).is_read_only();
|
||||
|
||||
let small = theme.sizes.resolve(Size::Small);
|
||||
let docked_height = small.control_height;
|
||||
let edge_inset = ((metrics.input_height - docked_height) / 2.0).max(Pixels::ZERO);
|
||||
let docked_height = Size::Small.control_height_rems().to_pixels(rem);
|
||||
let edge_inset = ((input_height - docked_height) / 2.0).max(Pixels::ZERO);
|
||||
|
||||
let vertical_inset = metrics.dense_padding_x * 0.5;
|
||||
let reveal_width = small.dense_padding_x * 2.0 + small.icon_size;
|
||||
let vertical_inset = dense_padding_x * 0.5;
|
||||
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 {
|
||||
left: Pixels::ZERO,
|
||||
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 {
|
||||
Pixels::ZERO
|
||||
},
|
||||
@@ -2045,11 +2049,11 @@ impl RenderOnce for Input {
|
||||
};
|
||||
|
||||
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()),
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
@@ -2176,14 +2180,14 @@ impl RenderOnce for Input {
|
||||
.w_full()
|
||||
.h(field_height)
|
||||
.pl(if self.prefix.is_some() {
|
||||
metrics.padding_x
|
||||
padding_x
|
||||
} else {
|
||||
metrics.dense_padding_x
|
||||
dense_padding_x
|
||||
})
|
||||
.pr(if self.suffix.is_some() {
|
||||
metrics.padding_x
|
||||
padding_x
|
||||
} else {
|
||||
metrics.dense_padding_x
|
||||
dense_padding_x
|
||||
})
|
||||
.gap_2()
|
||||
.rounded(if self.fully_rounded {
|
||||
@@ -2192,7 +2196,7 @@ impl RenderOnce for Input {
|
||||
radius.control
|
||||
})
|
||||
.bg(colors.input)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.text_color(colors.foreground)
|
||||
.border_1()
|
||||
.border_color(colors.border)
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
Action, AnyElement, App, FocusHandle, FontWeight, InteractiveElement as _, IntoElement,
|
||||
KeyBinding, KeyContext, Keystroke, OperatingSystem, ParentElement as _, RenderOnce,
|
||||
SharedString, StyleRefinement, Styled as _, Window, div, relative,
|
||||
Action, AnyElement, App, FocusHandle, InteractiveElement as _, IntoElement, KeyBinding,
|
||||
KeyContext, Keystroke, OperatingSystem, ParentElement as _, RenderOnce, SharedString,
|
||||
StyleRefinement, Styled as _, Window, div, relative,
|
||||
};
|
||||
|
||||
use crate::components::common::{StyledExt as _, h_flex};
|
||||
@@ -267,7 +267,7 @@ impl RenderOnce for Kbd {
|
||||
.rounded(theme.radius.sm)
|
||||
.text_center()
|
||||
.line_height(relative(1.))
|
||||
.text_size(theme.typography.caption.size)
|
||||
.text_xs()
|
||||
})
|
||||
.refine_style(&self.style)
|
||||
.child(label)
|
||||
|
||||
@@ -21,7 +21,7 @@ use gpui::{
|
||||
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};
|
||||
|
||||
/// 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 colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let size = self.size;
|
||||
|
||||
let on_click = self.on_click;
|
||||
let href = self.href;
|
||||
@@ -127,7 +127,7 @@ impl RenderOnce for Link {
|
||||
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(size)
|
||||
.text_color(ramps.primary.base)
|
||||
.underline()
|
||||
.refine_style(&self.style)
|
||||
|
||||
@@ -22,14 +22,14 @@ use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent,
|
||||
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
||||
StyleRefinement, Styled as _, Window, div,
|
||||
StyleRefinement, Styled as _, Window, div, rems,
|
||||
};
|
||||
|
||||
use crate::components::common::{
|
||||
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color,
|
||||
};
|
||||
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.
|
||||
type ChangeHandler = Rc<dyn Fn(Option<usize>, &mut Window, &mut App)>;
|
||||
@@ -173,7 +173,6 @@ impl RenderOnce for List {
|
||||
.collect();
|
||||
|
||||
let focus = crate::components::common::focus_handle(&self.id, window, cx);
|
||||
let theme = cx.theme();
|
||||
|
||||
let label = self
|
||||
.a11y_label
|
||||
@@ -200,7 +199,7 @@ impl RenderOnce for List {
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_0p5()
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_sm()
|
||||
.refine_style(&self.style)
|
||||
.track_focus(&focus)
|
||||
.focusable()
|
||||
@@ -246,7 +245,7 @@ impl ListItem {
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(theme.sizes.medium.control_height)
|
||||
.min_h_8()
|
||||
.rounded(theme.radius.sm)
|
||||
.role(Role::ListItem)
|
||||
.aria_selected(selected)
|
||||
@@ -266,7 +265,7 @@ impl ListItem {
|
||||
})
|
||||
})
|
||||
.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(
|
||||
div()
|
||||
@@ -278,7 +277,7 @@ impl ListItem {
|
||||
row.child(
|
||||
div()
|
||||
.flex_none()
|
||||
.typeset(TextRole::Subheadline, cx)
|
||||
.text_sm()
|
||||
.text_color(if selected {
|
||||
theme.colors.primary_foreground
|
||||
} else {
|
||||
|
||||
@@ -34,42 +34,25 @@ use std::sync::Arc;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle,
|
||||
GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _, InteractiveText,
|
||||
IntoElement, KeyBinding, KeyBindingContextPredicate, LayoutId, ListAlignment, ListOffset,
|
||||
ListState, MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels,
|
||||
Refineable as _, Render, SharedString, StatefulInteractiveElement as _, StrikethroughStyle,
|
||||
StyleRefinement, Styled, StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window,
|
||||
actions, div, img, list, px, relative,
|
||||
FontWeight, GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _,
|
||||
InteractiveText, IntoElement, KeyBinding, KeyBindingContextPredicate, LayoutId, ListAlignment,
|
||||
ListOffset, ListState, MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit,
|
||||
ParentElement as _, Pixels, Refineable as _, Rems, Render, SharedString,
|
||||
StatefulInteractiveElement as _, StrikethroughStyle, StyleRefinement, Styled, StyledImage as _,
|
||||
StyledText, TextLayout, UnderlineStyle, Window, actions, div, img, list, px, relative, rems,
|
||||
};
|
||||
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
|
||||
|
||||
use crate::components::button::{Button, ButtonVariant};
|
||||
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::scrollbar::{Scrollbar, ScrollbarVisibility};
|
||||
use crate::components::utils::code_line;
|
||||
use crate::theme::{
|
||||
ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size, TextRole,
|
||||
Typeset as _,
|
||||
};
|
||||
use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size};
|
||||
|
||||
/// 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.
|
||||
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.
|
||||
pub const TEXT_VIEW_CONTEXT: &str = "TextView";
|
||||
|
||||
@@ -1431,8 +1414,7 @@ fn render_block(
|
||||
ctx: &BlockContext,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let theme = cx.theme();
|
||||
let gap = theme.root_font_size * BLOCK_GAP;
|
||||
let gap = rems(0.75);
|
||||
|
||||
match block {
|
||||
MarkdownBlock::Heading {
|
||||
@@ -1445,7 +1427,11 @@ fn render_block(
|
||||
spans,
|
||||
*indent,
|
||||
*quote,
|
||||
if block_index == 0 { px(0.) } else { gap * 0.5 },
|
||||
if block_index == 0 {
|
||||
Rems::ZERO
|
||||
} else {
|
||||
rems(0.375)
|
||||
},
|
||||
ctx,
|
||||
cx,
|
||||
),
|
||||
@@ -1459,15 +1445,7 @@ fn render_block(
|
||||
items,
|
||||
indent,
|
||||
quote,
|
||||
} => text_row(
|
||||
items,
|
||||
*indent,
|
||||
*quote,
|
||||
theme.root_font_size * ITEM_GAP,
|
||||
Some(*marker),
|
||||
ctx,
|
||||
cx,
|
||||
),
|
||||
} => text_row(items, *indent, *quote, rems(0.2), Some(*marker), ctx, cx),
|
||||
MarkdownBlock::Image {
|
||||
source,
|
||||
alt,
|
||||
@@ -1490,7 +1468,7 @@ fn render_block(
|
||||
}
|
||||
|
||||
/// 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();
|
||||
div()
|
||||
.debug_selector({
|
||||
@@ -1501,25 +1479,25 @@ fn block_frame(quote: bool, top: Pixels, bottom: Pixels, id: &ElementId, cx: &Ap
|
||||
.flex()
|
||||
.flex_col()
|
||||
.font_family(".SystemUIFont")
|
||||
.text_size(theme.sizes.small.text_size)
|
||||
.text_xs()
|
||||
.line_height(relative(BODY_LINE_HEIGHT))
|
||||
.text_color(theme.colors.foreground)
|
||||
.pt(top)
|
||||
.pb(bottom)
|
||||
.when(quote, |frame| {
|
||||
frame
|
||||
.border_l(BORDER_WIDTH * 2.0)
|
||||
.border_l_2()
|
||||
.border_color(theme.colors.border)
|
||||
.pl(theme.root_font_size * QUOTE_INSET)
|
||||
.pl(rems(1.0))
|
||||
})
|
||||
}
|
||||
|
||||
/// Wraps the finished block in the list indent.
|
||||
fn indented_frame(indent: usize, frame: Div, cx: &App) -> Div {
|
||||
let indent_px = cx.theme().root_font_size * INDENT_STEP * indent as f32;
|
||||
fn indented_frame(indent: usize, frame: Div) -> Div {
|
||||
let indent = rems(1.5 * indent as f32);
|
||||
|
||||
if indent_px > px(0.) {
|
||||
div().w_full().pl(indent_px).child(frame)
|
||||
if indent.0 > 0.0 {
|
||||
div().w_full().pl(indent).child(frame)
|
||||
} else {
|
||||
frame
|
||||
}
|
||||
@@ -1531,30 +1509,23 @@ fn heading_row(
|
||||
spans: &[InlineSpan],
|
||||
indent: usize,
|
||||
quote: bool,
|
||||
top: Pixels,
|
||||
top: Rems,
|
||||
ctx: &BlockContext,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let theme = cx.theme();
|
||||
let role = match level {
|
||||
MarkdownHeading::H1 => TextRole::Title,
|
||||
MarkdownHeading::H2 => TextRole::Title2,
|
||||
MarkdownHeading::H3 => TextRole::Title3,
|
||||
MarkdownHeading::H4 | MarkdownHeading::H5 | MarkdownHeading::H6 => TextRole::Headline,
|
||||
let frame = block_frame(quote, top, rems(0.75), ctx.block_id, cx);
|
||||
let frame = match level {
|
||||
MarkdownHeading::H1 => frame.text_xl().font_semibold(),
|
||||
MarkdownHeading::H2 => frame.text_lg().font_semibold(),
|
||||
MarkdownHeading::H3 => frame.text_base().font_semibold(),
|
||||
MarkdownHeading::H4 | MarkdownHeading::H5 | MarkdownHeading::H6 => {
|
||||
frame.text_sm().font_semibold()
|
||||
}
|
||||
};
|
||||
|
||||
indented_frame(
|
||||
indent,
|
||||
block_frame(
|
||||
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,
|
||||
frame.child(text_child(spans, ctx.block_id, ctx.piece_context(0), cx)),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -1563,7 +1534,7 @@ fn text_row(
|
||||
items: &[InlineItem],
|
||||
indent: usize,
|
||||
quote: bool,
|
||||
bottom: Pixels,
|
||||
bottom: Rems,
|
||||
marker: Option<ListMarker>,
|
||||
ctx: &BlockContext,
|
||||
cx: &App,
|
||||
@@ -1572,12 +1543,12 @@ fn text_row(
|
||||
|
||||
indented_frame(
|
||||
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) => {
|
||||
let line_height = theme.sizes.small.text_size * BODY_LINE_HEIGHT;
|
||||
let line_height = rems(1.2);
|
||||
let marker_cell = div()
|
||||
.flex_none()
|
||||
.w(theme.root_font_size * MARKER_WIDTH)
|
||||
.w(rems(1.75))
|
||||
.h(line_height)
|
||||
.flex()
|
||||
.items_center()
|
||||
@@ -1608,7 +1579,6 @@ fn text_row(
|
||||
}
|
||||
None => frame.child(paragraph_child(items, ctx, cx)),
|
||||
}),
|
||||
cx,
|
||||
)
|
||||
.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);
|
||||
}
|
||||
|
||||
let theme = cx.theme();
|
||||
let side = theme.sizes.small.text_size * INLINE_IMAGE_SCALE;
|
||||
let side = rems(0.8625);
|
||||
let mut flow = div().flex().flex_wrap().items_center();
|
||||
let mut segment: Vec<&InlineSpan> = Vec::new();
|
||||
let mut segment_index = 0;
|
||||
@@ -1709,21 +1678,13 @@ fn image_row(
|
||||
let theme = cx.theme();
|
||||
indented_frame(
|
||||
indent,
|
||||
block_frame(
|
||||
quote,
|
||||
px(0.),
|
||||
theme.root_font_size * BLOCK_GAP,
|
||||
ctx.block_id,
|
||||
cx,
|
||||
)
|
||||
.child(
|
||||
block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(
|
||||
img(source.clone())
|
||||
.max_h(theme.root_font_size * IMAGE_MAX_HEIGHT)
|
||||
.max_h(rems(14.0))
|
||||
.max_w_full()
|
||||
.rounded(theme.radius.control)
|
||||
.overflow_hidden(),
|
||||
),
|
||||
cx,
|
||||
)
|
||||
.id((ctx.block_id.clone(), "image"))
|
||||
.when(!alt.is_empty(), |frame| frame.aria_label(alt.clone()))
|
||||
@@ -1744,7 +1705,7 @@ fn code_row(
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
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 plain = lines
|
||||
.lines
|
||||
@@ -1761,7 +1722,7 @@ fn code_row(
|
||||
.when_some(language.cloned(), |row, language| {
|
||||
row.child(
|
||||
div()
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.text_xs()
|
||||
.text_color(theme.colors.muted_foreground)
|
||||
.child(language),
|
||||
)
|
||||
@@ -1784,7 +1745,7 @@ fn code_row(
|
||||
.bg(theme.colors.muted)
|
||||
.p_2()
|
||||
.font_family(theme.mono_font)
|
||||
.text_size(text_size)
|
||||
.text_xs()
|
||||
.line_height(relative(CODE_LINE_HEIGHT))
|
||||
.overflow_hidden()
|
||||
.child(actions_row)
|
||||
@@ -1804,15 +1765,7 @@ fn code_row(
|
||||
|
||||
indented_frame(
|
||||
indent,
|
||||
block_frame(
|
||||
quote,
|
||||
px(0.),
|
||||
theme.root_font_size * BLOCK_GAP,
|
||||
ctx.block_id,
|
||||
cx,
|
||||
)
|
||||
.child(plate),
|
||||
cx,
|
||||
block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(plate),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -1821,15 +1774,8 @@ fn rule_row(indent: usize, quote: bool, ctx: &BlockContext, cx: &App) -> AnyElem
|
||||
let theme = cx.theme();
|
||||
indented_frame(
|
||||
indent,
|
||||
block_frame(
|
||||
quote,
|
||||
px(0.),
|
||||
theme.root_font_size * BLOCK_GAP,
|
||||
ctx.block_id,
|
||||
cx,
|
||||
)
|
||||
.child(div().h(BORDER_WIDTH).w_full().bg(theme.colors.border)),
|
||||
cx,
|
||||
block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx)
|
||||
.child(div().h_px().w_full().bg(theme.colors.border)),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -1884,9 +1830,7 @@ fn table_row(
|
||||
.min_w_0()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.when(row.header, |cell_element| {
|
||||
cell_element.font_weight(theme.typography.headline.weight)
|
||||
})
|
||||
.when(row.header, |cell_element| cell_element.font_semibold())
|
||||
.child(text_child(&cell.spans, &cell_id, piece, cx))
|
||||
})
|
||||
// Ragged tables pad missing cells so rows align.
|
||||
@@ -1899,15 +1843,7 @@ fn table_row(
|
||||
|
||||
indented_frame(
|
||||
indent,
|
||||
block_frame(
|
||||
quote,
|
||||
px(0.),
|
||||
theme.root_font_size * BLOCK_GAP,
|
||||
ctx.block_id,
|
||||
cx,
|
||||
)
|
||||
.child(grid),
|
||||
cx,
|
||||
block_frame(quote, Rems::ZERO, rems(0.75), ctx.block_id, cx).child(grid),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -2021,7 +1957,7 @@ where
|
||||
InlineStyle::Strong => highlights.push((
|
||||
range,
|
||||
HighlightStyle {
|
||||
font_weight: Some(theme.typography.headline.weight),
|
||||
font_weight: Some(FontWeight::SEMIBOLD),
|
||||
..Default::default()
|
||||
},
|
||||
)),
|
||||
@@ -2029,7 +1965,7 @@ where
|
||||
range,
|
||||
HighlightStyle {
|
||||
font_style: Some(FontStyle::Italic),
|
||||
font_weight: Some(theme.typography.headline.weight),
|
||||
font_weight: Some(FontWeight::SEMIBOLD),
|
||||
..Default::default()
|
||||
},
|
||||
)),
|
||||
|
||||
@@ -29,13 +29,13 @@ use gpui::{
|
||||
DispatchPhase, ElementId, Entity, FocusHandle, InteractiveElement as _, IntoElement,
|
||||
KeyDownEvent, MouseButton, MouseDownEvent, ParentElement as _, Pixels, Point, RenderOnce, Role,
|
||||
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::scroll_area::{ScrollArea, ScrollAxes};
|
||||
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.
|
||||
pub type ItemHandler = Rc<dyn Fn(&mut Window, &mut App)>;
|
||||
@@ -201,10 +201,6 @@ pub(crate) struct MenuChrome {
|
||||
destructive_foreground: gpui::Hsla,
|
||||
radius_overlay: Pixels,
|
||||
radius_sm: Pixels,
|
||||
icon_size: Pixels,
|
||||
dense_icon_size: Pixels,
|
||||
menu_item_height: Pixels,
|
||||
text_size: Pixels,
|
||||
shadow: Vec<BoxShadow>,
|
||||
}
|
||||
|
||||
@@ -242,10 +238,6 @@ impl MenuChrome {
|
||||
destructive_foreground: theme.colors.destructive_foreground,
|
||||
radius_overlay: theme.radius.overlay,
|
||||
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(),
|
||||
},
|
||||
theme.motion.overlay,
|
||||
@@ -813,7 +805,7 @@ fn render_item(
|
||||
) -> AnyElement {
|
||||
match &item.kind {
|
||||
MenuItemKind::Separator => div()
|
||||
.h(BORDER_WIDTH)
|
||||
.h_px()
|
||||
.debug_selector(move || format!("{}-separator-{index}", env.debug_prefix))
|
||||
.mx_2()
|
||||
.my_1()
|
||||
@@ -846,7 +838,7 @@ fn render_item(
|
||||
}
|
||||
})
|
||||
.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(
|
||||
div()
|
||||
@@ -868,7 +860,7 @@ fn render_item(
|
||||
.when(checked, |row| {
|
||||
row.child(
|
||||
icon_glyph(IconRole::Check)
|
||||
.size(env.chrome.dense_icon_size)
|
||||
.size(rems(0.75))
|
||||
.color(label_color),
|
||||
)
|
||||
})
|
||||
@@ -901,7 +893,7 @@ fn render_item(
|
||||
)
|
||||
.child(
|
||||
icon_glyph(IconRole::ChevronRight)
|
||||
.size(chrome.dense_icon_size)
|
||||
.size(rems(0.75))
|
||||
.color(label_color),
|
||||
)
|
||||
.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(
|
||||
cx: &App,
|
||||
item: &MenuItem,
|
||||
@@ -972,9 +964,9 @@ fn row_shell(
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.min_h(chrome.menu_item_height)
|
||||
.min_h_8()
|
||||
.px_4()
|
||||
.text_size(chrome.text_size)
|
||||
.text_sm()
|
||||
.line_height(relative(1.0))
|
||||
.rounded(chrome.radius_sm)
|
||||
.map(|row| {
|
||||
|
||||
@@ -81,11 +81,17 @@ impl RenderOnce for Progress {
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
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 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()
|
||||
.id(self.id)
|
||||
.w_full()
|
||||
@@ -100,34 +106,27 @@ impl RenderOnce for Progress {
|
||||
.aria_min_numeric_value(0.0)
|
||||
.aria_max_numeric_value(1.0)
|
||||
})
|
||||
.child(
|
||||
.child(track.child(if self.indeterminate {
|
||||
div()
|
||||
.w_full()
|
||||
.h(track_height)
|
||||
.h_full()
|
||||
.w(relative(0.3))
|
||||
.rounded(radius.full)
|
||||
.bg(colors.border)
|
||||
.child(if self.indeterminate {
|
||||
div()
|
||||
.h_full()
|
||||
.w(relative(0.3))
|
||||
.rounded(radius.full)
|
||||
.bg(ramps.primary.base)
|
||||
.with_animation(
|
||||
"indeterminate",
|
||||
Animation::new(PROGRESS_ANIMATION_PERIOD)
|
||||
.repeat()
|
||||
.with_max_fps(30.),
|
||||
|pill, delta| pill.ml(relative(delta * 0.7)),
|
||||
)
|
||||
.into_any_element()
|
||||
} else {
|
||||
div()
|
||||
.h_full()
|
||||
.w(relative(value))
|
||||
.rounded(radius.full)
|
||||
.bg(ramps.primary.base)
|
||||
.into_any_element()
|
||||
}),
|
||||
)
|
||||
.bg(ramps.primary.base)
|
||||
.with_animation(
|
||||
"indeterminate",
|
||||
Animation::new(PROGRESS_ANIMATION_PERIOD)
|
||||
.repeat()
|
||||
.with_max_fps(30.),
|
||||
|pill, delta| pill.ml(relative(delta * 0.7)),
|
||||
)
|
||||
.into_any_element()
|
||||
} else {
|
||||
div()
|
||||
.h_full()
|
||||
.w(relative(value))
|
||||
.rounded(radius.full)
|
||||
.bg(ramps.primary.base)
|
||||
.into_any_element()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ use gpui::{
|
||||
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};
|
||||
|
||||
/// The group's change reporter, fired with the clicked radio's value.
|
||||
@@ -178,7 +180,7 @@ where
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let radius = theme.radius;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let size = self.size;
|
||||
let selected = self.selected;
|
||||
let on_change = self.on_change;
|
||||
let group_label = self.a11y_label;
|
||||
@@ -186,7 +188,7 @@ where
|
||||
v_flex()
|
||||
.id(self.id)
|
||||
.gap_2()
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(size)
|
||||
.refine_style(&self.style)
|
||||
.role(Role::RadioGroup)
|
||||
.when_some(group_label.clone(), |group, label| group.aria_label(label))
|
||||
@@ -223,7 +225,7 @@ where
|
||||
h_flex()
|
||||
.justify_center()
|
||||
.flex_none()
|
||||
.size(metrics.indicator_size)
|
||||
.control_indicator(size)
|
||||
.rounded(radius.full)
|
||||
.border_1()
|
||||
.when(is_selected, |indicator| {
|
||||
@@ -235,12 +237,14 @@ where
|
||||
.bg(ramps.primary.hover)
|
||||
.border_color(ramps.primary.hover)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.size(metrics.indicator_size / 2.0)
|
||||
.rounded(radius.full)
|
||||
.bg(colors.primary_foreground),
|
||||
)
|
||||
.child({
|
||||
let dot = match size {
|
||||
Size::XSmall => div().size_1p5(),
|
||||
Size::Small | Size::Medium => div().size_2(),
|
||||
Size::Large => div().size_2p5(),
|
||||
};
|
||||
dot.rounded(radius.full).bg(colors.primary_foreground)
|
||||
})
|
||||
})
|
||||
.when(!is_selected, |indicator| {
|
||||
indicator
|
||||
|
||||
@@ -22,7 +22,9 @@ use gpui::{
|
||||
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::theme::{ActiveTheme as _, CONTROL_SPRING, Size};
|
||||
|
||||
@@ -168,7 +170,6 @@ where
|
||||
{
|
||||
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let muted = theme.colors.muted;
|
||||
let surface = theme.colors.surface;
|
||||
let foreground = theme.colors.foreground;
|
||||
@@ -177,12 +178,6 @@ where
|
||||
let radius = theme.radius.full;
|
||||
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
|
||||
.options
|
||||
.iter()
|
||||
@@ -238,9 +233,9 @@ where
|
||||
.justify_center()
|
||||
.cursor_pointer()
|
||||
.h_full()
|
||||
.px(horizontal_padding)
|
||||
.control_dense_padding_x(self.size)
|
||||
.rounded(radius)
|
||||
.text_size(text_size)
|
||||
.control_text(self.size)
|
||||
.text_color(content_color)
|
||||
.when(!is_selected, |segment| {
|
||||
segment.hover(|style| style.bg(surface))
|
||||
@@ -249,7 +244,7 @@ where
|
||||
.aria_label(segment.label.clone())
|
||||
.aria_toggled(Toggled::from(is_selected))
|
||||
.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(
|
||||
@@ -296,11 +291,11 @@ where
|
||||
.gap_1()
|
||||
.relative()
|
||||
.flex_none()
|
||||
.h(track_height)
|
||||
.p(track_inset)
|
||||
.control_height(self.size)
|
||||
.control_plate_inset(self.size)
|
||||
.rounded(radius)
|
||||
.bg(muted)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.child(
|
||||
canvas(
|
||||
{
|
||||
@@ -321,8 +316,8 @@ where
|
||||
.id("segmented-plate")
|
||||
.debug_selector(|| "segmented-plate".to_string())
|
||||
.absolute()
|
||||
.top(track_inset)
|
||||
.bottom(track_inset)
|
||||
.top(self.size.plate_inset_rems())
|
||||
.bottom(self.size.plate_inset_rems())
|
||||
.rounded(radius)
|
||||
.bg(surface)
|
||||
.shadow(plate_shadow.clone())
|
||||
|
||||
@@ -20,10 +20,10 @@ use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
App, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement 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::icons::{Icon, IconRole, icon};
|
||||
use crate::theme::{ActiveTheme as _, Size};
|
||||
@@ -188,7 +188,6 @@ where
|
||||
{
|
||||
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let border = theme.colors.border;
|
||||
let ring = theme.colors.ring;
|
||||
let input = theme.colors.input;
|
||||
@@ -196,7 +195,6 @@ where
|
||||
let foreground = theme.colors.foreground;
|
||||
let muted_foreground = theme.colors.muted_foreground;
|
||||
let radius = theme.radius.control;
|
||||
let icon_size = metrics.dense_icon_size;
|
||||
|
||||
let label = self
|
||||
.a11y_label
|
||||
@@ -271,14 +269,14 @@ where
|
||||
.justify_between()
|
||||
.gap_3()
|
||||
.w_full()
|
||||
.h(metrics.input_height)
|
||||
.pl(metrics.dense_padding_x)
|
||||
.pr(metrics.plate_inset * 2.0)
|
||||
.control_height(self.size)
|
||||
.control_dense_padding_x(self.size)
|
||||
.pr(rems(self.size.plate_inset_rems().0 * 2.0))
|
||||
.rounded(radius)
|
||||
.border_1()
|
||||
.border_color(rest_border)
|
||||
.bg(input)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.text_color(if trigger_has_value {
|
||||
foreground
|
||||
} else {
|
||||
@@ -288,7 +286,7 @@ where
|
||||
.child(trigger_text.clone())
|
||||
.child(
|
||||
icon(IconRole::ChevronDown)
|
||||
.size(icon_size)
|
||||
.size(self.size.dense_icon_rems())
|
||||
.color(muted_foreground),
|
||||
)
|
||||
.child(
|
||||
|
||||
@@ -30,7 +30,7 @@ use crate::components::common::{
|
||||
};
|
||||
use crate::components::grain::grain as grain_overlay;
|
||||
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.
|
||||
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}"))
|
||||
.h_full()
|
||||
.w(width)
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_sm()
|
||||
.when(border_right, |sidebar| {
|
||||
sidebar
|
||||
.border_r(BORDER_WIDTH)
|
||||
@@ -437,7 +437,8 @@ impl SidebarEntry {
|
||||
.px_2()
|
||||
.pt_2()
|
||||
.pb_1()
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.text_sm()
|
||||
.font_semibold()
|
||||
.text_color(theme.colors.muted_foreground)
|
||||
.role(Role::Heading)
|
||||
.when_some(prefix, |header, prefix| header.child(prefix))
|
||||
@@ -471,7 +472,7 @@ impl SidebarEntry {
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(theme.sizes.medium.control_height)
|
||||
.min_h_8()
|
||||
.rounded(theme.radius.sm)
|
||||
.text_color(label_color)
|
||||
.role(Role::ListItem)
|
||||
@@ -515,7 +516,7 @@ impl SidebarEntry {
|
||||
row.child(
|
||||
div()
|
||||
.flex_none()
|
||||
.typeset(TextRole::Subheadline, cx)
|
||||
.text_sm()
|
||||
.text_color(if selected {
|
||||
theme.colors.primary_foreground
|
||||
} else {
|
||||
|
||||
@@ -142,11 +142,11 @@ impl RenderOnce for Slider {
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let radius = theme.radius;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
let row_height = metrics.icon_size * 2.5;
|
||||
let track_height = metrics.icon_size / 4.0;
|
||||
let knob = metrics.indicator_size;
|
||||
let rem = window.rem_size();
|
||||
let row_height = self.size.slider_row_rems() * rem;
|
||||
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 fraction = if self.max > self.min {
|
||||
@@ -188,7 +188,12 @@ impl RenderOnce for Slider {
|
||||
.id(self.id)
|
||||
.relative()
|
||||
.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)
|
||||
.role(Role::Slider)
|
||||
.when_some(self.a11y_label.clone(), |slider, label| {
|
||||
@@ -284,7 +289,11 @@ impl RenderOnce for Slider {
|
||||
.absolute()
|
||||
.left_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()
|
||||
.rounded(radius.full)
|
||||
.bg(colors.border),
|
||||
@@ -294,7 +303,11 @@ impl RenderOnce for Slider {
|
||||
.absolute()
|
||||
.left_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))
|
||||
.rounded(radius.full)
|
||||
.bg(ramps.primary.base),
|
||||
@@ -310,7 +323,12 @@ impl RenderOnce for Slider {
|
||||
.items_center()
|
||||
.child(
|
||||
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()
|
||||
.rounded(radius.full)
|
||||
.bg(colors.primary_foreground)
|
||||
|
||||
@@ -32,10 +32,10 @@ use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Context, ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement,
|
||||
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::tooltip::Tooltip;
|
||||
use crate::icons::{IconRole, icon};
|
||||
@@ -745,7 +745,7 @@ impl RenderOnce for SpeechButton {
|
||||
|
||||
let theme = cx.theme();
|
||||
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 group = SharedString::from(format!(
|
||||
@@ -768,8 +768,8 @@ impl RenderOnce for SpeechButton {
|
||||
.group(group.clone())
|
||||
.role(Role::Button)
|
||||
.justify_center()
|
||||
.h(metrics.control_height)
|
||||
.px(metrics.dense_padding_x)
|
||||
.control_height(size)
|
||||
.control_dense_padding_x(size)
|
||||
.gap_0p5()
|
||||
.rounded(theme.radius.control)
|
||||
.text_color(foreground)
|
||||
@@ -794,13 +794,13 @@ impl RenderOnce for SpeechButton {
|
||||
};
|
||||
h_flex()
|
||||
.id(("speech-bars", self.speech.entity_id()))
|
||||
.h(metrics.icon_size)
|
||||
.h(size.icon_rems())
|
||||
.items_end()
|
||||
.gap_0p5()
|
||||
.children(bars.iter().map(|level| {
|
||||
div()
|
||||
.flex_none()
|
||||
.w(metrics.dense_icon_size / 4.)
|
||||
.w(rems(size.dense_icon_rems().0 / 4.0))
|
||||
.h(relative(bar_height(*level)))
|
||||
.rounded(theme.radius.full)
|
||||
.bg(theme.ramps.primary.base)
|
||||
@@ -809,7 +809,7 @@ impl RenderOnce for SpeechButton {
|
||||
.into_any_element()
|
||||
} else {
|
||||
icon(IconRole::Microphone)
|
||||
.size(metrics.icon_size)
|
||||
.size(size.icon_rems())
|
||||
.color(foreground)
|
||||
.into_any_element()
|
||||
})
|
||||
@@ -820,7 +820,7 @@ impl RenderOnce for SpeechButton {
|
||||
.group_hover(group, |style| style.visible())
|
||||
.child(
|
||||
icon(IconRole::Stop)
|
||||
.size(metrics.icon_size)
|
||||
.size(size.icon_rems())
|
||||
.color(foreground),
|
||||
),
|
||||
)
|
||||
@@ -887,7 +887,7 @@ impl RenderOnce for SpeechWaveform {
|
||||
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let size = self.size;
|
||||
let bar_height = |level: f32| {
|
||||
if reduce_motion {
|
||||
STILL_HEIGHT
|
||||
@@ -901,13 +901,13 @@ impl RenderOnce for SpeechWaveform {
|
||||
.items_end()
|
||||
.justify_end()
|
||||
.gap_0p5()
|
||||
.h(metrics.icon_size)
|
||||
.h(size.icon_rems())
|
||||
.w(SPEECH_WAVEFORM_WIDTH)
|
||||
.overflow_hidden()
|
||||
.children(levels.iter().map(|level| {
|
||||
div()
|
||||
.flex_none()
|
||||
.w(metrics.dense_icon_size / 4.)
|
||||
.w(rems(size.dense_icon_rems().0 / 4.0))
|
||||
.h(relative(bar_height(*level)))
|
||||
.rounded(theme.radius.full)
|
||||
.bg(if *level <= 0.0 {
|
||||
|
||||
@@ -113,9 +113,9 @@ impl Sizable 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 side = theme.sizes.resolve(self.size).icon_size;
|
||||
let side = self.size.icon_rems() * window.rem_size();
|
||||
let stroke = side * RING_STROKE;
|
||||
let track = theme.colors.border;
|
||||
let accent = self.color.unwrap_or(theme.ramps.primary.base);
|
||||
|
||||
@@ -104,20 +104,24 @@ impl Styled for StatusDot {
|
||||
impl RenderOnce for StatusDot {
|
||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let side = metrics.icon_size / 2.;
|
||||
let size = self.size;
|
||||
let color = self.variant.color(theme);
|
||||
|
||||
div()
|
||||
let dot = div()
|
||||
.id(self.id.clone())
|
||||
.debug_selector(move || self.id.to_string())
|
||||
.flex_none()
|
||||
.size(side)
|
||||
.rounded(theme.radius.full)
|
||||
.bg(color)
|
||||
.when_some(self.label, |dot, label| {
|
||||
dot.role(Role::Status).aria_label(label)
|
||||
})
|
||||
.refine_style(&self.style)
|
||||
.bg(color);
|
||||
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)
|
||||
})
|
||||
.refine_style(&self.style)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use gpui::{
|
||||
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};
|
||||
|
||||
/// 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 {
|
||||
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 colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
let track_height = metrics.switch_height;
|
||||
let track_width = metrics.switch_width;
|
||||
let rem = window.rem_size();
|
||||
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.
|
||||
let inset = (track_height - knob) / 2. - BORDER_WIDTH;
|
||||
let travel = track_width - BORDER_WIDTH * 2. - knob - inset * 2.;
|
||||
@@ -134,7 +134,7 @@ impl RenderOnce for Switch {
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.gap_2()
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(self.size)
|
||||
.refine_style(&self.style)
|
||||
.role(Role::Switch)
|
||||
.when_some(a11y_label, |switch, label| switch.aria_label(label))
|
||||
@@ -155,8 +155,8 @@ impl RenderOnce for Switch {
|
||||
.flex_none()
|
||||
.relative()
|
||||
.debug_selector(move || format!("{id}-track"))
|
||||
.w(track_width)
|
||||
.h(track_height)
|
||||
.switch_track_width(self.size)
|
||||
.switch_track_height(self.size)
|
||||
.rounded(theme.radius.full)
|
||||
.border_1()
|
||||
.when(self.checked, |track| {
|
||||
@@ -177,7 +177,7 @@ impl RenderOnce for Switch {
|
||||
.absolute()
|
||||
.top(inset)
|
||||
.left(inset)
|
||||
.size(knob)
|
||||
.switch_knob(self.size)
|
||||
.rounded(theme.radius.full)
|
||||
.bg(colors.primary_foreground)
|
||||
.with_spring("switch-thumb", anim, move |thumb, offset| {
|
||||
|
||||
@@ -25,7 +25,7 @@ use gpui::{
|
||||
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels,
|
||||
Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _,
|
||||
StyleRefinement, Styled as _, TextOverflow, Window, canvas, div, linear_color_stop,
|
||||
linear_gradient, px,
|
||||
linear_gradient, px, rems,
|
||||
};
|
||||
|
||||
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::tooltip::Tooltip;
|
||||
use crate::icons::IconRole;
|
||||
use crate::theme::{
|
||||
ActiveTheme as _, ControlMetrics, POPUP_MAX_HEIGHT, Size, TAB_INDICATOR_WIDTH, TAB_MAX_WIDTH,
|
||||
TAB_MIN_WIDTH,
|
||||
};
|
||||
use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, TAB_MAX_WIDTH, TAB_MIN_WIDTH};
|
||||
|
||||
/// Reports the next selected tab by pointer and keys.
|
||||
type ChangeHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
|
||||
@@ -215,7 +212,7 @@ impl Render for TabDragPreview {
|
||||
.border_1()
|
||||
.border_color(theme.colors.border)
|
||||
.bg(theme.colors.background)
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_sm()
|
||||
.text_color(theme.colors.foreground)
|
||||
.shadow(theme.elevations.control.shadows())
|
||||
.child(self.label.clone())
|
||||
@@ -620,8 +617,6 @@ impl Tabs {
|
||||
.clone();
|
||||
|
||||
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 label_color = match ctx.variant {
|
||||
@@ -671,13 +666,13 @@ impl Tabs {
|
||||
.py_1()
|
||||
.rounded_tl(theme.radius.sm)
|
||||
.rounded_tr(theme.radius.sm)
|
||||
.border_b(TAB_INDICATOR_WIDTH)
|
||||
.border_b_2()
|
||||
.border_color(gpui::transparent_black())
|
||||
.when(active, |chip| chip.border_color(theme.ramps.primary.base)),
|
||||
TabsVariant::Pill | TabsVariant::Titlebar => chip
|
||||
.h(small.control_height + metrics.plate_inset * 2.0)
|
||||
.px(metrics.dense_padding_x)
|
||||
.pr(metrics.plate_inset)
|
||||
.h_8()
|
||||
.px_2()
|
||||
.pr_0p5()
|
||||
.rounded(match ctx.variant {
|
||||
TabsVariant::Titlebar => theme.radius.full,
|
||||
_ => theme.radius.control,
|
||||
@@ -692,7 +687,7 @@ impl Tabs {
|
||||
})
|
||||
.child(SharedString::from(format!("{kind} ({count})")))
|
||||
.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| {
|
||||
let key = measure.key.clone();
|
||||
@@ -799,17 +794,13 @@ impl RenderOnce for Tabs {
|
||||
|
||||
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.
|
||||
let (medium_text_size, border_color, shadow_bleed) = {
|
||||
let (border_color, shadow_bleed) = {
|
||||
let theme = cx.theme();
|
||||
let shadow_bleed = match self.variant {
|
||||
TabsVariant::Pill | TabsVariant::Titlebar => theme.elevations.control.bleed(),
|
||||
TabsVariant::Underline => Pixels::ZERO,
|
||||
};
|
||||
(
|
||||
theme.sizes.medium.text_size,
|
||||
theme.colors.border,
|
||||
shadow_bleed,
|
||||
)
|
||||
(theme.colors.border, shadow_bleed)
|
||||
};
|
||||
|
||||
let label = self
|
||||
@@ -880,7 +871,7 @@ impl RenderOnce for Tabs {
|
||||
div()
|
||||
.id(self.id.clone())
|
||||
.flex()
|
||||
.text_size(medium_text_size)
|
||||
.text_sm()
|
||||
.refine_style(&self.style)
|
||||
.track_focus(&focus)
|
||||
.focusable()
|
||||
@@ -1038,8 +1029,6 @@ impl Tab {
|
||||
let active = selected || self.pinned;
|
||||
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(Size::default());
|
||||
let small = theme.sizes.small;
|
||||
|
||||
let label_color = match ctx.variant {
|
||||
TabsVariant::Underline => {
|
||||
@@ -1069,14 +1058,8 @@ impl Tab {
|
||||
|
||||
let titlebar = ctx.variant == TabsVariant::Titlebar;
|
||||
let group = SharedString::from(format!("{}-tab-{}", ctx.id, self.key));
|
||||
let close = (self.closeable && ctx.on_close.is_some() && !self.disabled).then(|| {
|
||||
let close_metrics = ControlMetrics {
|
||||
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 close = (self.closeable && ctx.on_close.is_some() && !self.disabled)
|
||||
.then(|| self.render_tab_close(&ctx.id, index, &ctx.on_close));
|
||||
|
||||
let label = div()
|
||||
.flex_grow(1.0)
|
||||
@@ -1093,8 +1076,8 @@ impl Tab {
|
||||
theme.colors.muted_hover
|
||||
};
|
||||
|
||||
let fade_width = metrics.padding_x;
|
||||
let hover_fade_width = metrics.padding_x * 2.0;
|
||||
let fade_width = rems(0.75);
|
||||
let hover_fade_width = rems(1.5);
|
||||
|
||||
label
|
||||
.min_w_0()
|
||||
@@ -1166,15 +1149,15 @@ impl Tab {
|
||||
.py_1()
|
||||
.rounded_tl(theme.radius.sm)
|
||||
.rounded_tr(theme.radius.sm)
|
||||
.border_b(TAB_INDICATOR_WIDTH)
|
||||
.border_b_2()
|
||||
.border_color(gpui::transparent_black())
|
||||
.when(active, |strip_tab| {
|
||||
strip_tab.border_color(theme.ramps.primary.base)
|
||||
}),
|
||||
TabsVariant::Pill | TabsVariant::Titlebar => strip_tab
|
||||
.h(small.control_height + metrics.plate_inset * 2.0)
|
||||
.px(metrics.dense_padding_x)
|
||||
.pr(metrics.plate_inset)
|
||||
.h_8()
|
||||
.px_2()
|
||||
.pr_0p5()
|
||||
.rounded(match ctx.variant {
|
||||
TabsVariant::Titlebar => theme.radius.full,
|
||||
_ => theme.radius.control,
|
||||
@@ -1194,7 +1177,7 @@ impl Tab {
|
||||
.when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead))
|
||||
.child(label)
|
||||
.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| {
|
||||
strip_tab.child(
|
||||
@@ -1226,9 +1209,9 @@ impl Tab {
|
||||
div()
|
||||
.absolute()
|
||||
.left_0()
|
||||
.top(TAB_INDICATOR_WIDTH)
|
||||
.bottom(TAB_INDICATOR_WIDTH)
|
||||
.w(TAB_INDICATOR_WIDTH)
|
||||
.top_0p5()
|
||||
.bottom_0p5()
|
||||
.w_0p5()
|
||||
.rounded(theme.radius.sm)
|
||||
.bg(theme.ramps.primary.base),
|
||||
)
|
||||
@@ -1351,12 +1334,11 @@ impl Tab {
|
||||
tabs_id: &ElementId,
|
||||
index: usize,
|
||||
on_close: &Option<CloseHandler>,
|
||||
metrics: ControlMetrics,
|
||||
) -> AnyElement {
|
||||
Button::new((self.key.clone(), "tab-close"))
|
||||
.icon(IconRole::Close)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.custom_size(metrics)
|
||||
.xsmall()
|
||||
.fully_rounded(true)
|
||||
.tab_stop(false)
|
||||
.debug_selector({
|
||||
|
||||
@@ -20,7 +20,7 @@ use gpui::{
|
||||
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
|
||||
IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
|
||||
StatefulInteractiveElement as _, StyleRefinement, Styled as _, Task, Window, deferred, div,
|
||||
ease_out_quint, px,
|
||||
ease_out_quint, px, rems,
|
||||
};
|
||||
|
||||
use crate::components::button::{Button, ButtonVariant};
|
||||
@@ -291,8 +291,6 @@ impl ToastEntry {
|
||||
let foreground = theme.colors.foreground;
|
||||
let radius = theme.radius.full;
|
||||
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 toasts = toasts.clone();
|
||||
let id = self.id;
|
||||
@@ -320,7 +318,7 @@ impl ToastEntry {
|
||||
.flex_none()
|
||||
.flex()
|
||||
.items_center()
|
||||
.child(icon.size(icon_size).color(foreground)),
|
||||
.child(icon.size(rems(1.0)).color(foreground)),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
@@ -328,7 +326,7 @@ impl ToastEntry {
|
||||
.flex_1()
|
||||
.min_w(px(0.))
|
||||
.truncate()
|
||||
.text_size(text_size)
|
||||
.text_sm()
|
||||
.text_color(foreground)
|
||||
.child(toast.message.clone()),
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ use gpui::{
|
||||
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::theme::{ActiveTheme as _, DISABLED_OPACITY, Size};
|
||||
|
||||
@@ -124,7 +124,7 @@ impl RenderOnce for Toggle {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
let size = self.size;
|
||||
let on_change = self.on_change;
|
||||
let next = !self.pressed;
|
||||
let a11y_label = self.a11y_label.or_else(|| self.label.clone());
|
||||
@@ -133,13 +133,11 @@ impl RenderOnce for Toggle {
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.justify_center()
|
||||
.h(metrics.control_height)
|
||||
.when(icon_only, |toggle| {
|
||||
toggle.w(metrics.control_height).px(gpui::Pixels::ZERO)
|
||||
})
|
||||
.when(!icon_only, |toggle| toggle.px(metrics.dense_padding_x))
|
||||
.control_height(size)
|
||||
.when(icon_only, |toggle| toggle.control_width(size).px_0())
|
||||
.when(!icon_only, |toggle| toggle.control_dense_padding_x(size))
|
||||
.rounded(theme.radius.control)
|
||||
.text_size(metrics.text_size)
|
||||
.control_text(size)
|
||||
.text_color(colors.foreground)
|
||||
.role(Role::Button)
|
||||
.when_some(a11y_label, |toggle, label| toggle.aria_label(label))
|
||||
@@ -170,7 +168,7 @@ impl RenderOnce for Toggle {
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.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)),
|
||||
)
|
||||
|
||||
@@ -80,8 +80,6 @@ impl Render for Tooltip {
|
||||
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.
|
||||
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_foreground = theme.colors.surface_foreground;
|
||||
let radius_sm = theme.radius.sm;
|
||||
@@ -102,8 +100,7 @@ impl Render for Tooltip {
|
||||
.border_color(border)
|
||||
.rounded(radius_sm)
|
||||
.shadow(shadows.clone())
|
||||
.text_size(text_size)
|
||||
.line_height(line_height)
|
||||
.text_sm()
|
||||
.text_color(surface_foreground)
|
||||
.child(self.text.clone())
|
||||
};
|
||||
@@ -119,7 +116,7 @@ impl Render for Tooltip {
|
||||
cx,
|
||||
)
|
||||
.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 above = parent.top() - px(4.);
|
||||
|
||||
@@ -21,7 +21,7 @@ use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent,
|
||||
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
||||
StyleRefinement, Styled as _, Window, div,
|
||||
StyleRefinement, Styled as _, Window, div, rems,
|
||||
};
|
||||
|
||||
use crate::components::common::{
|
||||
@@ -254,7 +254,6 @@ impl RenderOnce for Tree {
|
||||
.collect();
|
||||
|
||||
let focus = crate::components::common::focus_handle(&self.id, window, cx);
|
||||
let theme = cx.theme();
|
||||
|
||||
let label = self
|
||||
.a11y_label
|
||||
@@ -286,7 +285,7 @@ impl RenderOnce for Tree {
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_0p5()
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_sm()
|
||||
.refine_style(&self.style)
|
||||
.track_focus(&focus)
|
||||
.focusable()
|
||||
@@ -364,7 +363,7 @@ impl TreeItem {
|
||||
let disabled = self.disabled;
|
||||
|
||||
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()
|
||||
.id((self.key.clone(), "tree-item"))
|
||||
@@ -375,7 +374,7 @@ impl TreeItem {
|
||||
.pl(indent)
|
||||
.pr_2()
|
||||
.py_1()
|
||||
.min_h(theme.sizes.medium.control_height)
|
||||
.min_h_8()
|
||||
.rounded(theme.radius.sm)
|
||||
.role(Role::TreeItem)
|
||||
.aria_selected(selected)
|
||||
@@ -407,7 +406,7 @@ impl TreeItem {
|
||||
let step = u32::try_from(level).unwrap_or(u32::MAX) as f32;
|
||||
div()
|
||||
.absolute()
|
||||
.left(theme.sizes.medium.padding_x * (step + 0.5))
|
||||
.left(rems(0.75 * (step + 0.5)))
|
||||
.top_0()
|
||||
.bottom_0()
|
||||
.border_l_1()
|
||||
@@ -418,7 +417,7 @@ impl TreeItem {
|
||||
self.icon
|
||||
.clone()
|
||||
.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(
|
||||
div()
|
||||
@@ -440,7 +439,7 @@ impl TreeItem {
|
||||
// Only expandable rows draw a chevron; the empty cell keeps labels aligned with folders.
|
||||
div()
|
||||
.flex_none()
|
||||
.size(theme.sizes.medium.icon_size)
|
||||
.size_4()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
@@ -451,7 +450,7 @@ impl TreeItem {
|
||||
} else {
|
||||
IconRole::ChevronRight
|
||||
})
|
||||
.size(theme.sizes.medium.dense_icon_size)
|
||||
.size(rems(0.75))
|
||||
.color(glyph_color),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -72,7 +72,7 @@ where
|
||||
.justify_center()
|
||||
.flex_none()
|
||||
.font_family(theme.mono_font)
|
||||
.text_size(theme.sizes.small.text_size)
|
||||
.text_xs()
|
||||
.line_height(gpui::relative(1.0))
|
||||
.text_color(color)
|
||||
.child(content)
|
||||
|
||||
+15
-13
@@ -4,13 +4,14 @@ use std::time::Duration;
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, RenderOnce,
|
||||
SharedString, Styled as _, TimedTransformation, Transformation, Window, div, px, svg,
|
||||
AbsoluteLength, AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, Rems,
|
||||
RenderOnce, SharedString, Styled as _, TimedTransformation, Transformation, Window, div, rems,
|
||||
svg,
|
||||
};
|
||||
|
||||
const SMALL_ICON_SIZE: Pixels = px(14.0);
|
||||
const DEFAULT_ICON_SIZE: Pixels = px(16.0);
|
||||
const LARGE_ICON_SIZE: Pixels = px(20.0);
|
||||
const SMALL_ICON_SIZE: Rems = rems(0.875);
|
||||
const DEFAULT_ICON_SIZE: Rems = rems(1.0);
|
||||
const LARGE_ICON_SIZE: Rems = rems(1.25);
|
||||
/// The spin presents at most this rate, rotating a sprite needs no more frames.
|
||||
const SPIN_MAX_FPS: f32 = 60.0;
|
||||
|
||||
@@ -137,7 +138,7 @@ enum Glyph {
|
||||
#[derive(Clone, IntoElement)]
|
||||
pub struct Icon {
|
||||
glyph: Glyph,
|
||||
size: Pixels,
|
||||
size: AbsoluteLength,
|
||||
color: Option<Hsla>,
|
||||
transformation: Option<Transformation>,
|
||||
rotation_period: Option<Duration>,
|
||||
@@ -147,7 +148,7 @@ pub struct Icon {
|
||||
pub fn icon(role: IconRole) -> Icon {
|
||||
Icon {
|
||||
glyph: Glyph::Role(role),
|
||||
size: DEFAULT_ICON_SIZE,
|
||||
size: AbsoluteLength::Rems(DEFAULT_ICON_SIZE),
|
||||
color: None,
|
||||
transformation: None,
|
||||
rotation_period: None,
|
||||
@@ -162,33 +163,33 @@ impl Icon {
|
||||
{
|
||||
Self {
|
||||
glyph: Glyph::Named(named.path()),
|
||||
size: DEFAULT_ICON_SIZE,
|
||||
size: AbsoluteLength::Rems(DEFAULT_ICON_SIZE),
|
||||
color: None,
|
||||
transformation: None,
|
||||
rotation_period: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn size(mut self, size: Pixels) -> Self {
|
||||
self.size = size;
|
||||
pub fn size(mut self, size: impl Into<AbsoluteLength>) -> Self {
|
||||
self.size = size.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// The small size.
|
||||
pub fn small(mut self) -> Self {
|
||||
self.size = SMALL_ICON_SIZE;
|
||||
self.size = AbsoluteLength::Rems(SMALL_ICON_SIZE);
|
||||
self
|
||||
}
|
||||
|
||||
/// The default medium size.
|
||||
pub fn medium(mut self) -> Self {
|
||||
self.size = DEFAULT_ICON_SIZE;
|
||||
self.size = AbsoluteLength::Rems(DEFAULT_ICON_SIZE);
|
||||
self
|
||||
}
|
||||
|
||||
/// The large size.
|
||||
pub fn large(mut self) -> Self {
|
||||
self.size = LARGE_ICON_SIZE;
|
||||
self.size = AbsoluteLength::Rems(LARGE_ICON_SIZE);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -260,6 +261,7 @@ impl RenderOnce for Icon {
|
||||
rotation_period,
|
||||
} = self;
|
||||
|
||||
let size = size.to_pixels(window.rem_size());
|
||||
let color = color.unwrap_or_else(|| window.text_style().color);
|
||||
|
||||
match glyph {
|
||||
|
||||
@@ -12,7 +12,7 @@ use gpui::{
|
||||
|
||||
use crate::layout::window_controls::{WindowControls, titlebar_strip};
|
||||
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.
|
||||
#[derive(IntoElement)]
|
||||
@@ -86,7 +86,6 @@ impl RenderOnce for Titlebar {
|
||||
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let height = theme.titlebar_height;
|
||||
let padding_x = theme.sizes.resolve(Size::default()).padding_x;
|
||||
let shadow_bleed = theme.elevations.control.bleed();
|
||||
|
||||
let id = self.id;
|
||||
@@ -101,7 +100,7 @@ impl RenderOnce for Titlebar {
|
||||
.h(height)
|
||||
.gap_2()
|
||||
.when(!self.transparent, |bar| bar.bg(theme.colors.muted))
|
||||
.px(padding_x)
|
||||
.px_3()
|
||||
.refine_style(&self.style)
|
||||
.when(cfg!(target_os = "macos"), |bar| bar.pl(TRAFFIC_LIGHT_PAD))
|
||||
.when(!self.prefix.is_empty(), |bar| {
|
||||
|
||||
@@ -13,7 +13,7 @@ use gpui::Styled as _;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
use gpui::{AnyElement, ParentElement as _};
|
||||
use gpui::{AnyElement, ParentElement as _, rems};
|
||||
use gpui::{
|
||||
App, ClickEvent, Div, ElementId, InteractiveElement as _, IntoElement, MouseButton, RenderOnce,
|
||||
Stateful, StatefulInteractiveElement as _, Window, WindowControlArea, div,
|
||||
@@ -229,7 +229,6 @@ fn caption_button(
|
||||
close: bool,
|
||||
) -> AnyElement {
|
||||
let theme = cx.theme();
|
||||
let glyph_size = theme.sizes.small.dense_icon_size;
|
||||
|
||||
let hover = if close {
|
||||
WINDOWS_CLOSE_HOVER
|
||||
@@ -275,7 +274,7 @@ fn caption_button(
|
||||
.text_color(theme.colors.foreground)
|
||||
})
|
||||
})
|
||||
.child(icon(role).size(glyph_size))
|
||||
.child(icon(role).size(rems(0.75)))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -287,7 +286,6 @@ where
|
||||
F: Fn(&mut Window, &mut App) + 'static,
|
||||
{
|
||||
let theme = cx.theme();
|
||||
let small = theme.sizes.small;
|
||||
|
||||
div()
|
||||
.id(id)
|
||||
@@ -295,7 +293,7 @@ where
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.size(small.control_height)
|
||||
.size_7()
|
||||
.rounded(theme.radius.full)
|
||||
.text_color(if enabled {
|
||||
theme.colors.foreground
|
||||
@@ -311,6 +309,6 @@ where
|
||||
action(window, cx);
|
||||
})
|
||||
})
|
||||
.child(icon(role).size(small.dense_icon_size))
|
||||
.child(icon(role).size(rems(0.75)))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ mod ramps;
|
||||
mod resolve;
|
||||
mod source;
|
||||
mod system;
|
||||
mod typography;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -25,12 +24,9 @@ use gpui::{
|
||||
pub use ramps::{AccentShades, Oklch};
|
||||
pub use resolve::{Ramps, ResolvedTheme};
|
||||
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.
|
||||
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.
|
||||
pub const TAB_MAX_WIDTH: Pixels = px(240.0);
|
||||
/// 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,
|
||||
/// The monospace family, for code surfaces.
|
||||
pub mono_font: &'static str,
|
||||
/// The type ladder, resolved at the root font size.
|
||||
pub typography: Typography,
|
||||
pub sizes: SizeTable,
|
||||
pub accessibility: AccessibilityPreferences,
|
||||
/// The material a window should open with, after accessibility.
|
||||
pub window_background: WindowBackgroundAppearance,
|
||||
@@ -230,8 +223,6 @@ impl Theme {
|
||||
titlebar_height: resolved.titlebar_height,
|
||||
root_font_size: resolved.root_font_size,
|
||||
mono_font: resolved.mono_font,
|
||||
typography: resolved.typography,
|
||||
sizes: resolved.sizes,
|
||||
accessibility: resolved.accessibility,
|
||||
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.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct CustomTheme {
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::theme::definition::ThemeDefinition;
|
||||
use crate::theme::ramps::{AccentShades, Oklch, contrast_foreground, derive_shades, mix};
|
||||
use crate::theme::system::{SourceKind, SystemTheme};
|
||||
use crate::theme::{
|
||||
ColorTokens, CustomTheme, Elevations, MaterialTokens, Motion, Radius, Scrollbar, SizeTable,
|
||||
ThemeVariant, Typography,
|
||||
AccessibilityPreferences, ColorTokens, CustomTheme, Elevations, MaterialTokens, Motion, Radius,
|
||||
Scrollbar, ThemeVariant,
|
||||
};
|
||||
|
||||
/// Derived state shades for the colors that get pressed and hovered.
|
||||
@@ -37,10 +37,7 @@ pub struct ResolvedTheme {
|
||||
pub root_font_size: gpui::Pixels,
|
||||
/// The monospace family, for code surfaces.
|
||||
pub mono_font: &'static str,
|
||||
/// The type ladder, resolved at the root font size.
|
||||
pub typography: Typography,
|
||||
pub sizes: SizeTable,
|
||||
pub accessibility: crate::theme::system::AccessibilityPreferences,
|
||||
pub accessibility: AccessibilityPreferences,
|
||||
/// The material a window should open with, after accessibility.
|
||||
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.
|
||||
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 mut radius = Radius::default();
|
||||
@@ -221,8 +217,6 @@ pub(crate) fn resolve(
|
||||
titlebar_height,
|
||||
root_font_size,
|
||||
mono_font: mono_font(),
|
||||
typography: Typography::resolve(root_font_size),
|
||||
sizes,
|
||||
accessibility,
|
||||
window_background,
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
@@ -29,6 +29,25 @@ impl Render for Harness {
|
||||
.xsmall()
|
||||
.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(
|
||||
DropdownMenu::new("icon-only-dropdown")
|
||||
.icon(IconRole::More)
|
||||
@@ -49,11 +68,23 @@ fn buttons_render_at_their_token_heights(cx: &mut TestAppContext) {
|
||||
let xsmall = cx
|
||||
.debug_bounds("xsmall-height-probe")
|
||||
.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
|
||||
.debug_bounds("icon-only-dropdown-trigger")
|
||||
.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!(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!(child_only.size, size(px(32.0), px(32.0)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user