number_input: Fix button margin. (#634)

This commit is contained in:
Jason Lee 2025-02-17 14:29:33 +08:00 committed by GitHub
parent 231772ee4e
commit d96b4b44d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
use gpui::{
actions, prelude::FluentBuilder as _, px, App, AppContext as _, Context, Entity, EventEmitter,
FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding, ParentElement, Pixels,
Render, SharedString, Styled, Subscription, Window,
FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding, ParentElement, Render,
SharedString, Styled, Subscription, Window,
};
use regex::Regex;
@ -162,7 +162,6 @@ impl Render for NumberInput {
// Sync size to input at first.
self.sync_size_to_input_if_needed(window, cx);
const BUTTON_OFFSET: Pixels = px(-3.);
let btn_size = match self.size {
Size::XSmall | Size::Small => Size::XSmall,
_ => Size::Small,
@ -174,6 +173,11 @@ impl Render for NumberInput {
.on_action(cx.listener(Self::on_action_decrement))
.flex_1()
.input_size(self.size)
.px(match self.size {
Size::XSmall => px(1.),
Size::Small => px(2.),
_ => px(3.),
})
.bg(cx.theme().background)
.border_color(cx.theme().input)
.border_1()
@ -183,7 +187,6 @@ impl Render for NumberInput {
Button::new("minus")
.ghost()
.with_size(btn_size)
.ml(BUTTON_OFFSET)
.icon(IconName::Minus)
.on_click(cx.listener(|this, _, window, cx| {
this.on_step(StepAction::Decrement, window, cx)
@ -194,7 +197,6 @@ impl Render for NumberInput {
Button::new("plus")
.ghost()
.with_size(btn_size)
.mr(BUTTON_OFFSET)
.icon(IconName::Plus)
.on_click(cx.listener(|this, _, window, cx| {
this.on_step(StepAction::Increment, window, cx)