number_input: Fix button margin. (#634)
This commit is contained in:
parent
231772ee4e
commit
d96b4b44d2
1 changed files with 7 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, prelude::FluentBuilder as _, px, App, AppContext as _, Context, Entity, EventEmitter,
|
actions, prelude::FluentBuilder as _, px, App, AppContext as _, Context, Entity, EventEmitter,
|
||||||
FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding, ParentElement, Pixels,
|
FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding, ParentElement, Render,
|
||||||
Render, SharedString, Styled, Subscription, Window,
|
SharedString, Styled, Subscription, Window,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
|
@ -162,7 +162,6 @@ impl Render for NumberInput {
|
||||||
|
|
||||||
// Sync size to input at first.
|
// Sync size to input at first.
|
||||||
self.sync_size_to_input_if_needed(window, cx);
|
self.sync_size_to_input_if_needed(window, cx);
|
||||||
const BUTTON_OFFSET: Pixels = px(-3.);
|
|
||||||
let btn_size = match self.size {
|
let btn_size = match self.size {
|
||||||
Size::XSmall | Size::Small => Size::XSmall,
|
Size::XSmall | Size::Small => Size::XSmall,
|
||||||
_ => Size::Small,
|
_ => Size::Small,
|
||||||
|
|
@ -174,6 +173,11 @@ impl Render for NumberInput {
|
||||||
.on_action(cx.listener(Self::on_action_decrement))
|
.on_action(cx.listener(Self::on_action_decrement))
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.input_size(self.size)
|
.input_size(self.size)
|
||||||
|
.px(match self.size {
|
||||||
|
Size::XSmall => px(1.),
|
||||||
|
Size::Small => px(2.),
|
||||||
|
_ => px(3.),
|
||||||
|
})
|
||||||
.bg(cx.theme().background)
|
.bg(cx.theme().background)
|
||||||
.border_color(cx.theme().input)
|
.border_color(cx.theme().input)
|
||||||
.border_1()
|
.border_1()
|
||||||
|
|
@ -183,7 +187,6 @@ impl Render for NumberInput {
|
||||||
Button::new("minus")
|
Button::new("minus")
|
||||||
.ghost()
|
.ghost()
|
||||||
.with_size(btn_size)
|
.with_size(btn_size)
|
||||||
.ml(BUTTON_OFFSET)
|
|
||||||
.icon(IconName::Minus)
|
.icon(IconName::Minus)
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
this.on_step(StepAction::Decrement, window, cx)
|
this.on_step(StepAction::Decrement, window, cx)
|
||||||
|
|
@ -194,7 +197,6 @@ impl Render for NumberInput {
|
||||||
Button::new("plus")
|
Button::new("plus")
|
||||||
.ghost()
|
.ghost()
|
||||||
.with_size(btn_size)
|
.with_size(btn_size)
|
||||||
.mr(BUTTON_OFFSET)
|
|
||||||
.icon(IconName::Plus)
|
.icon(IconName::Plus)
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
this.on_step(StepAction::Increment, window, cx)
|
this.on_step(StepAction::Increment, window, cx)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue