Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions app/src/ai/blocklist/block/numbered_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use warpui::{AppContext, Element, SingletonEntity, ViewHandle};

use super::compact_agent_input::CompactAgentInput;
use crate::context_chips::spacing;
const NUMBER_BADGE_BORDER_WIDTH: f32 = 1.;
const NUMBER_BADGE_VERTICAL_PADDING: f32 = 1.;

fn render_number_badge(
number: usize,
Expand All @@ -34,8 +36,8 @@ fn render_number_badge(
.finish(),
)
.with_horizontal_padding(5.)
.with_vertical_padding(1.)
.with_border(Border::all(1.).with_border_color(badge_border_color))
.with_vertical_padding(NUMBER_BADGE_VERTICAL_PADDING)
.with_border(Border::all(NUMBER_BADGE_BORDER_WIDTH).with_border_color(badge_border_color))
.with_corner_radius(CornerRadius::with_all(Radius::Pixels(3.)))
.with_background(badge_background)
.finish()
Expand Down Expand Up @@ -85,6 +87,7 @@ pub(super) fn build_numbered_button(
) -> Button {
let appearance = Appearance::as_ref(app);
let theme = appearance.theme();
let font_size = appearance.monospace_font_size();

let mut button = base_numbered_button(mouse_state, app);

Expand All @@ -105,12 +108,25 @@ pub(super) fn build_numbered_button(
}

let badge = render_number_badge(number, is_checked, appearance);
let badge_font_size = font_size.max(4.) - 1.;
let content_top_margin = ((badge_font_size * DEFAULT_UI_LINE_HEIGHT_RATIO)
+ (NUMBER_BADGE_VERTICAL_PADDING + NUMBER_BADGE_BORDER_WIDTH) * 2.
- (font_size * DEFAULT_UI_LINE_HEIGHT_RATIO))
.max(0.)
/ 2.;

let row = Flex::row()
.with_cross_axis_alignment(CrossAxisAlignment::Start)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this diff - shouldn't this be changed?

.with_child(badge)
.with_child(
Shrinkable::new(1., Container::new(content).with_margin_left(8.).finish()).finish(),
Shrinkable::new(
1.,
Container::new(content)
.with_margin_left(8.)
.with_margin_top(content_top_margin)
.finish(),
)
.finish(),
)
.finish();

Expand Down