Use focus borders for inputs and selects
- Replace the input focus shadow with an accent border. - Apply the same focus border to select triggers.
This commit is contained in:
@@ -19,7 +19,6 @@ use gpui_native_theme::{
|
|||||||
ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH,
|
ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH,
|
||||||
WHEEL_LINE_HEIGHT,
|
WHEEL_LINE_HEIGHT,
|
||||||
};
|
};
|
||||||
use gpui_native_utils::focus_ring;
|
|
||||||
|
|
||||||
use crate::button::{Button, ButtonVariant};
|
use crate::button::{Button, ButtonVariant};
|
||||||
use crate::common::{Sizable, StyledExt as _, h_flex};
|
use crate::common::{Sizable, StyledExt as _, h_flex};
|
||||||
@@ -2160,7 +2159,7 @@ impl RenderOnce for Input {
|
|||||||
.when(!self.disabled, |input| {
|
.when(!self.disabled, |input| {
|
||||||
input.track_focus(&focus_handle).tab_stop(true)
|
input.track_focus(&focus_handle).tab_stop(true)
|
||||||
})
|
})
|
||||||
.when(focused, |input| input.shadow(focus_ring(colors.ring)))
|
.when(focused, |input| input.border_color(colors.ring))
|
||||||
.when_some(self.prefix, |input, prefix| {
|
.when_some(self.prefix, |input, prefix| {
|
||||||
input.child(edge_zone("input-prefix", prefix))
|
input.child(edge_zone("input-prefix", prefix))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use gpui_native_icons::{Icon, IconRole, icon};
|
use gpui_native_icons::{Icon, IconRole, icon};
|
||||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||||
use gpui_native_utils::{focus_handle, focus_ring};
|
use gpui_native_utils::focus_handle;
|
||||||
|
|
||||||
use crate::common::{Sizable, StyledExt, h_flex};
|
use crate::common::{Sizable, StyledExt, h_flex};
|
||||||
use crate::menu::{Menu, MenuItem};
|
use crate::menu::{Menu, MenuItem};
|
||||||
@@ -207,8 +207,8 @@ where
|
|||||||
let is_open = *open.read(cx);
|
let is_open = *open.read(cx);
|
||||||
let open_for_items = open.clone();
|
let open_for_items = open.clone();
|
||||||
|
|
||||||
let rest_border = border;
|
let rest_border = if is_open { ring } else { border };
|
||||||
let hover_border = border;
|
let hover_border = rest_border;
|
||||||
|
|
||||||
let selected_index = self.selected.as_ref().and_then(|value| {
|
let selected_index = self.selected.as_ref().and_then(|value| {
|
||||||
self.options
|
self.options
|
||||||
@@ -240,7 +240,7 @@ where
|
|||||||
.aria_expanded(is_open)
|
.aria_expanded(is_open)
|
||||||
.track_focus(&focus)
|
.track_focus(&focus)
|
||||||
.tab_stop(true)
|
.tab_stop(true)
|
||||||
.focus_visible(move |style| style.shadow(focus_ring(ring)))
|
.focus_visible(move |style| style.border_color(ring))
|
||||||
.on_key_down({
|
.on_key_down({
|
||||||
let open = open.clone();
|
let open = open.clone();
|
||||||
move |event: &KeyDownEvent, _window, cx| {
|
move |event: &KeyDownEvent, _window, cx| {
|
||||||
@@ -269,7 +269,6 @@ where
|
|||||||
} else {
|
} else {
|
||||||
muted_foreground
|
muted_foreground
|
||||||
})
|
})
|
||||||
.when(is_open, |trigger| trigger.shadow(focus_ring(ring)))
|
|
||||||
.hover(|style| style.bg(muted).border_color(hover_border))
|
.hover(|style| style.bg(muted).border_color(hover_border))
|
||||||
.child(trigger_text.clone())
|
.child(trigger_text.clone())
|
||||||
.child(
|
.child(
|
||||||
|
|||||||
Reference in New Issue
Block a user