add StyledExt::refine_style to utils

This commit is contained in:
2026-11-01 10:33:51 +07:00
parent 78d7e857f1
commit ac4a0f2add
6 changed files with 36 additions and 31 deletions
+12 -2
View File
@@ -1,7 +1,7 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
App, BoxShadow, Div, ElementId, FocusHandle, Hsla, IntoElement, StatefulInteractiveElement,
Styled, Window, div, px,
App, BoxShadow, Div, ElementId, FocusHandle, Hsla, IntoElement, Refineable as _,
StatefulInteractiveElement, StyleRefinement, Styled, Window, div, px,
};
use gpui_native_theme::ActiveTheme as _;
@@ -15,6 +15,16 @@ pub fn v_flex() -> Div {
div().flex().flex_col()
}
/// Extensions over [`Styled`], shared by the components.
pub trait StyledExt: Styled + Sized {
fn refine_style(mut self, style: &StyleRefinement) -> Self {
self.style().refine(style);
self
}
}
impl<E: Styled> StyledExt for E {}
/// Returns a focus handle for the given element ID.
pub fn focus_handle(id: &ElementId, window: &mut Window, cx: &mut App) -> FocusHandle {
window