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(
|
||||
div()
|
||||
.font_family(cx.theme().mono_font)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(commit.id.clone()),
|
||||
)
|
||||
@@ -386,7 +386,7 @@ pub(crate) fn commit_row(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_ellipsis()
|
||||
.whitespace_nowrap()
|
||||
.child(commit.summary.clone()),
|
||||
|
||||
@@ -155,6 +155,7 @@ impl Render for RepoHistoryView {
|
||||
let commit = commits[ix].clone();
|
||||
let id = commit.id.clone();
|
||||
let view = view.clone();
|
||||
|
||||
commit_row(
|
||||
ix,
|
||||
&commit,
|
||||
|
||||
@@ -17,6 +17,7 @@ use signed_state::{
|
||||
};
|
||||
use ui::alert::{Alert, AlertSeverity};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::badge::Badge;
|
||||
use ui::common::{Sizable as _, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::layout::panel::Panel;
|
||||
@@ -886,19 +887,25 @@ impl RepoDetailView {
|
||||
let mut entries = vec![
|
||||
SidebarEntry::row("repo-nav-commits", "Commits")
|
||||
.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 {
|
||||
entries.push(
|
||||
SidebarEntry::row("repo-nav-issues", "Issues")
|
||||
.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(
|
||||
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
||||
.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)
|
||||
.title("Repository error")
|
||||
.message(error)
|
||||
.style(ui::alert::AlertStyle::Inline)
|
||||
.on_dismiss(move |cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.error = None;
|
||||
|
||||
@@ -17,7 +17,7 @@ use gpui::{
|
||||
Window, transparent_black,
|
||||
};
|
||||
|
||||
use crate::components::common::{StyledExt, h_flex};
|
||||
use crate::components::common::{Sizable, StyledExt, h_flex};
|
||||
use crate::icons::Icon;
|
||||
use crate::theme::{ActiveTheme as _, Size, Theme};
|
||||
|
||||
@@ -87,6 +87,7 @@ pub struct Badge {
|
||||
label: SharedString,
|
||||
icon: Option<Icon>,
|
||||
variant: BadgeVariant,
|
||||
size: Size,
|
||||
tooltip: Option<TooltipBuilder>,
|
||||
style: StyleRefinement,
|
||||
}
|
||||
@@ -103,6 +104,7 @@ impl Badge {
|
||||
label: label.into(),
|
||||
icon: None,
|
||||
variant: BadgeVariant::default(),
|
||||
size: Size::default(),
|
||||
tooltip: None,
|
||||
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 {
|
||||
fn style(&mut self) -> &mut gpui::StyleRefinement {
|
||||
&mut self.style
|
||||
@@ -142,8 +150,12 @@ 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(Size::Small);
|
||||
let label_size = metrics.caption_size;
|
||||
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 (background, foreground, border) = self.variant.tokens(theme);
|
||||
|
||||
h_flex()
|
||||
@@ -157,8 +169,9 @@ impl RenderOnce for Badge {
|
||||
.bg(background)
|
||||
.text_color(foreground)
|
||||
.text_size(label_size)
|
||||
.px(metrics.dense_padding_x)
|
||||
.py_0p5()
|
||||
.px(label_size * 0.5)
|
||||
.min_w(square)
|
||||
.min_h(square)
|
||||
.when_some(self.icon, |badge, icon| {
|
||||
badge.child(icon.size(metrics.dense_icon_size).color(foreground))
|
||||
})
|
||||
|
||||
@@ -473,6 +473,7 @@ impl SidebarEntry {
|
||||
.py_1()
|
||||
.min_h(theme.sizes.medium.control_height)
|
||||
.rounded(theme.radius.sm)
|
||||
.text_color(label_color)
|
||||
.role(Role::ListItem)
|
||||
.aria_selected(selected)
|
||||
.aria_position_in_set(position_in_set)
|
||||
@@ -508,7 +509,6 @@ impl SidebarEntry {
|
||||
.overflow_hidden()
|
||||
.whitespace_nowrap()
|
||||
.text_ellipsis()
|
||||
.text_color(label_color)
|
||||
.child(label),
|
||||
)
|
||||
.when_some(detail, |row, detail| {
|
||||
|
||||
Reference in New Issue
Block a user