make badge sizable and use badges for sidebar counts
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
This commit is contained in:
@@ -378,7 +378,7 @@ pub(crate) fn commit_row(
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.font_family(cx.theme().mono_font)
|
.font_family(cx.theme().mono_font)
|
||||||
.typeset(TextRole::Caption, cx)
|
.typeset(TextRole::Callout, cx)
|
||||||
.text_color(cx.theme().colors.muted_foreground)
|
.text_color(cx.theme().colors.muted_foreground)
|
||||||
.child(commit.id.clone()),
|
.child(commit.id.clone()),
|
||||||
)
|
)
|
||||||
@@ -386,7 +386,7 @@ pub(crate) fn commit_row(
|
|||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.min_w_0()
|
.min_w_0()
|
||||||
.typeset(TextRole::Body, cx)
|
.typeset(TextRole::Callout, cx)
|
||||||
.text_ellipsis()
|
.text_ellipsis()
|
||||||
.whitespace_nowrap()
|
.whitespace_nowrap()
|
||||||
.child(commit.summary.clone()),
|
.child(commit.summary.clone()),
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ impl Render for RepoHistoryView {
|
|||||||
let commit = commits[ix].clone();
|
let commit = commits[ix].clone();
|
||||||
let id = commit.id.clone();
|
let id = commit.id.clone();
|
||||||
let view = view.clone();
|
let view = view.clone();
|
||||||
|
|
||||||
commit_row(
|
commit_row(
|
||||||
ix,
|
ix,
|
||||||
&commit,
|
&commit,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use signed_state::{
|
|||||||
};
|
};
|
||||||
use ui::alert::{Alert, AlertSeverity};
|
use ui::alert::{Alert, AlertSeverity};
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
|
use ui::badge::Badge;
|
||||||
use ui::common::{Sizable as _, h_flex, v_flex};
|
use ui::common::{Sizable as _, h_flex, v_flex};
|
||||||
use ui::icons::{Icon, IconRole};
|
use ui::icons::{Icon, IconRole};
|
||||||
use ui::layout::panel::Panel;
|
use ui::layout::panel::Panel;
|
||||||
@@ -886,19 +887,25 @@ impl RepoDetailView {
|
|||||||
let mut entries = vec![
|
let mut entries = vec![
|
||||||
SidebarEntry::row("repo-nav-commits", "Commits")
|
SidebarEntry::row("repo-nav-commits", "Commits")
|
||||||
.prefix(Icon::named(IconRole::GitCommit))
|
.prefix(Icon::named(IconRole::GitCommit))
|
||||||
.when_some(commit_count, |entry, count| entry.suffix(count.to_string())),
|
.when_some(commit_count, |entry, count| {
|
||||||
|
entry.suffix(Badge::new(count, count.to_string()).xsmall())
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
if include_issues {
|
if include_issues {
|
||||||
entries.push(
|
entries.push(
|
||||||
SidebarEntry::row("repo-nav-issues", "Issues")
|
SidebarEntry::row("repo-nav-issues", "Issues")
|
||||||
.prefix(Icon::named(IconRole::GitIssueDone))
|
.prefix(Icon::named(IconRole::GitIssueDone))
|
||||||
.when_some(issue_count, |entry, count| entry.suffix(count.to_string())),
|
.when_some(issue_count, |entry, count| {
|
||||||
|
entry.suffix(Badge::new(count, count.to_string()).xsmall())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
entries.push(
|
entries.push(
|
||||||
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
||||||
.prefix(Icon::named(IconRole::GitPullRequest))
|
.prefix(Icon::named(IconRole::GitPullRequest))
|
||||||
.when_some(pull_count, |entry, count| entry.suffix(count.to_string())),
|
.when_some(pull_count, |entry, count| {
|
||||||
|
entry.suffix(Badge::new(count, count.to_string()).xsmall())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,6 +998,7 @@ impl Render for RepoDetailView {
|
|||||||
.severity(AlertSeverity::Danger)
|
.severity(AlertSeverity::Danger)
|
||||||
.title("Repository error")
|
.title("Repository error")
|
||||||
.message(error)
|
.message(error)
|
||||||
|
.style(ui::alert::AlertStyle::Inline)
|
||||||
.on_dismiss(move |cx| {
|
.on_dismiss(move |cx| {
|
||||||
if let Err(error) = weak.update(cx, |this, cx| {
|
if let Err(error) = weak.update(cx, |this, cx| {
|
||||||
this.error = None;
|
this.error = None;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use gpui::{
|
|||||||
Window, transparent_black,
|
Window, transparent_black,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::components::common::{StyledExt, h_flex};
|
use crate::components::common::{Sizable, StyledExt, h_flex};
|
||||||
use crate::icons::Icon;
|
use crate::icons::Icon;
|
||||||
use crate::theme::{ActiveTheme as _, Size, Theme};
|
use crate::theme::{ActiveTheme as _, Size, Theme};
|
||||||
|
|
||||||
@@ -87,6 +87,7 @@ pub struct Badge {
|
|||||||
label: SharedString,
|
label: SharedString,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
variant: BadgeVariant,
|
variant: BadgeVariant,
|
||||||
|
size: Size,
|
||||||
tooltip: Option<TooltipBuilder>,
|
tooltip: Option<TooltipBuilder>,
|
||||||
style: StyleRefinement,
|
style: StyleRefinement,
|
||||||
}
|
}
|
||||||
@@ -103,6 +104,7 @@ impl Badge {
|
|||||||
label: label.into(),
|
label: label.into(),
|
||||||
icon: None,
|
icon: None,
|
||||||
variant: BadgeVariant::default(),
|
variant: BadgeVariant::default(),
|
||||||
|
size: Size::default(),
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
style: StyleRefinement::default(),
|
style: StyleRefinement::default(),
|
||||||
}
|
}
|
||||||
@@ -133,6 +135,12 @@ impl Badge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sizable for Badge {
|
||||||
|
fn apply_size(&mut self, size: Size) {
|
||||||
|
self.size = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl gpui::Styled for Badge {
|
impl gpui::Styled for Badge {
|
||||||
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
||||||
&mut self.style
|
&mut self.style
|
||||||
@@ -142,8 +150,12 @@ impl gpui::Styled for Badge {
|
|||||||
impl RenderOnce for Badge {
|
impl RenderOnce for Badge {
|
||||||
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let metrics = theme.sizes.resolve(Size::Small);
|
let metrics = theme.sizes.resolve(self.size);
|
||||||
let label_size = metrics.caption_size;
|
let label_size = match self.size {
|
||||||
|
Size::XSmall | Size::Small => metrics.caption_size * 0.9,
|
||||||
|
Size::Medium | Size::Large => metrics.caption_size,
|
||||||
|
};
|
||||||
|
let square = label_size * 2.;
|
||||||
let (background, foreground, border) = self.variant.tokens(theme);
|
let (background, foreground, border) = self.variant.tokens(theme);
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
@@ -157,8 +169,9 @@ impl RenderOnce for Badge {
|
|||||||
.bg(background)
|
.bg(background)
|
||||||
.text_color(foreground)
|
.text_color(foreground)
|
||||||
.text_size(label_size)
|
.text_size(label_size)
|
||||||
.px(metrics.dense_padding_x)
|
.px(label_size * 0.5)
|
||||||
.py_0p5()
|
.min_w(square)
|
||||||
|
.min_h(square)
|
||||||
.when_some(self.icon, |badge, icon| {
|
.when_some(self.icon, |badge, icon| {
|
||||||
badge.child(icon.size(metrics.dense_icon_size).color(foreground))
|
badge.child(icon.size(metrics.dense_icon_size).color(foreground))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ impl SidebarEntry {
|
|||||||
.py_1()
|
.py_1()
|
||||||
.min_h(theme.sizes.medium.control_height)
|
.min_h(theme.sizes.medium.control_height)
|
||||||
.rounded(theme.radius.sm)
|
.rounded(theme.radius.sm)
|
||||||
|
.text_color(label_color)
|
||||||
.role(Role::ListItem)
|
.role(Role::ListItem)
|
||||||
.aria_selected(selected)
|
.aria_selected(selected)
|
||||||
.aria_position_in_set(position_in_set)
|
.aria_position_in_set(position_in_set)
|
||||||
@@ -508,7 +509,6 @@ impl SidebarEntry {
|
|||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.whitespace_nowrap()
|
.whitespace_nowrap()
|
||||||
.text_ellipsis()
|
.text_ellipsis()
|
||||||
.text_color(label_color)
|
|
||||||
.child(label),
|
.child(label),
|
||||||
)
|
)
|
||||||
.when_some(detail, |row, detail| {
|
.when_some(detail, |row, detail| {
|
||||||
|
|||||||
Reference in New Issue
Block a user