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
+9 -13
View File
@@ -2,13 +2,12 @@ use std::fmt::Display;
use gpui::prelude::FluentBuilder as _;
use gpui::{
App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, Refineable as _,
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _,
Window, div,
App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role,
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, div,
};
use gpui_native_theme::{ActiveTheme as _, Oklch, Size, ThemeVariant};
use crate::common::{Sizable, h_flex};
use crate::common::{Sizable, StyledExt, h_flex};
/// Number of rows and columns in the pixel grid.
const GRID_SIZE: usize = 8;
@@ -85,7 +84,7 @@ impl RenderOnce for Avatar {
let radius = theme.radius.control;
let side = theme.sizes.resolve(self.size).avatar_size;
let mut base = h_flex()
let base = h_flex()
.id(ElementId::from(self.id.clone()))
.flex_none()
.justify_center()
@@ -97,10 +96,8 @@ impl RenderOnce for Avatar {
.when_some(
self.name.clone().or(Some(self.id.clone())),
|avatar, label| avatar.role(Role::Image).aria_label(label),
);
// Apply custom styles
base.style().refine(&self.style);
)
.refine_style(&self.style);
match self.picture {
Some(url) => base.child(
@@ -174,7 +171,7 @@ impl RenderOnce for PixelAvatar {
}
}
let mut grid = div()
div()
.grid()
.grid_cols(GRID_SIZE as u16)
.grid_rows(GRID_SIZE as u16)
@@ -183,9 +180,8 @@ impl RenderOnce for PixelAvatar {
.rounded(radius)
.overflow_hidden()
.bg(gpui::Hsla { a: 0.16, ..main })
.children(cells);
grid.style().refine(&self.style);
grid
.children(cells)
.refine_style(&self.style)
}
}