refactor(ui): use v_flex/h_flex helpers in components
This commit is contained in:
@@ -377,14 +377,12 @@ impl RenderOnce for AlertsView {
|
||||
let entries = self.alerts.read(cx).entries();
|
||||
|
||||
deferred(
|
||||
div()
|
||||
v_flex()
|
||||
.id(self.id)
|
||||
.absolute()
|
||||
.top_4()
|
||||
.right_4()
|
||||
.w(ALERT_STACK_WIDTH)
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_end()
|
||||
.gap_2()
|
||||
.children(entries.iter().rev().map(|entry| {
|
||||
|
||||
@@ -143,9 +143,7 @@ impl RenderOnce for Field {
|
||||
};
|
||||
|
||||
let content = if self.variant == FieldVariant::Row {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -160,9 +158,7 @@ impl RenderOnce for Field {
|
||||
})
|
||||
.when_some(error, |field, error| field.child(error))
|
||||
} else {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
v_flex()
|
||||
|
||||
@@ -2247,15 +2247,12 @@ impl RenderOnce for Input {
|
||||
input.child(edge_zone("input-prefix", prefix))
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
h_flex()
|
||||
.relative()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.h_full()
|
||||
.overflow_hidden()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.when_some(line_height, |region, line_height| {
|
||||
region.items_start().line_height(line_height)
|
||||
})
|
||||
|
||||
@@ -25,8 +25,9 @@ use gpui::{
|
||||
StyleRefinement, Styled as _, Window, div, rems,
|
||||
};
|
||||
|
||||
use crate::common::focus_handle;
|
||||
use crate::components::common::{
|
||||
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color,
|
||||
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color, v_flex,
|
||||
};
|
||||
use crate::icons::Icon;
|
||||
use crate::theme::ActiveTheme as _;
|
||||
@@ -172,7 +173,7 @@ impl RenderOnce for List {
|
||||
.map(|(index, _)| index)
|
||||
.collect();
|
||||
|
||||
let focus = crate::components::common::focus_handle(&self.id, window, cx);
|
||||
let focus = focus_handle(&self.id, window, cx);
|
||||
|
||||
let label = self
|
||||
.a11y_label
|
||||
@@ -194,10 +195,8 @@ impl RenderOnce for List {
|
||||
})
|
||||
.collect();
|
||||
|
||||
div()
|
||||
v_flex()
|
||||
.id(self.id)
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_0p5()
|
||||
.text_sm()
|
||||
.refine_style(&self.style)
|
||||
|
||||
@@ -45,7 +45,7 @@ use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, T
|
||||
|
||||
use crate::components::button::{Button, ButtonVariant};
|
||||
use crate::components::checkbox::Checkbox;
|
||||
use crate::components::common::{Sizable as _, StyledExt as _};
|
||||
use crate::components::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
|
||||
use crate::components::highlight::{HighlightedCode, Language, highlight, plain};
|
||||
use crate::components::scrollbar::{Scrollbar, ScrollbarVisibility};
|
||||
use crate::components::utils::code_line;
|
||||
@@ -853,10 +853,8 @@ pub fn bind_text_view_keys(cx: &mut App) {
|
||||
fn view_container(frame: &ViewFrame) -> Div {
|
||||
let clear_flag = frame.pressed_on_piece.clone();
|
||||
|
||||
div()
|
||||
v_flex()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.key_context(TEXT_VIEW_CONTEXT)
|
||||
.track_focus(&frame.focus_handle)
|
||||
.on_action({
|
||||
@@ -1470,14 +1468,12 @@ fn render_block(
|
||||
/// The shared block frame: ambient text style, spacing, quote bar.
|
||||
fn block_frame(quote: bool, top: Rems, bottom: Rems, id: &ElementId, cx: &App) -> Div {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
v_flex()
|
||||
.debug_selector({
|
||||
let id = id.clone();
|
||||
move || id.to_string()
|
||||
})
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.font_family(theme.ui_font())
|
||||
.text_xs()
|
||||
.line_height(relative(BODY_LINE_HEIGHT))
|
||||
@@ -1714,9 +1710,7 @@ fn code_row(
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
let actions_row = div()
|
||||
.flex()
|
||||
.items_center()
|
||||
let actions_row = h_flex()
|
||||
.justify_between()
|
||||
.pb_1()
|
||||
.when_some(language.cloned(), |row, language| {
|
||||
@@ -1737,10 +1731,8 @@ fn code_row(
|
||||
}),
|
||||
);
|
||||
|
||||
let plate = div()
|
||||
let plate = v_flex()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.rounded(theme.radius.control)
|
||||
.bg(theme.colors.muted)
|
||||
.p_2()
|
||||
@@ -1798,10 +1790,8 @@ fn table_row(
|
||||
let row_count = table.rows.len();
|
||||
let mut cell_ix = 0usize;
|
||||
|
||||
let grid = div()
|
||||
let grid = v_flex()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.border_1()
|
||||
.border_color(colors.border)
|
||||
.rounded(theme.radius.control)
|
||||
|
||||
@@ -378,9 +378,7 @@ impl RenderOnce for Sidebar {
|
||||
.handle(scroll.read(cx).clone())
|
||||
.h_full()
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
v_flex()
|
||||
.gap_0p5()
|
||||
.when(padded, |content| content.p_2())
|
||||
.children(children),
|
||||
|
||||
@@ -987,6 +987,7 @@ impl RenderOnce for Tabs {
|
||||
let Some(root_bounds) = measure_frame.map(|frame| frame.root_bounds) else {
|
||||
return root.children(strip);
|
||||
};
|
||||
|
||||
let container_canvas = canvas(
|
||||
{
|
||||
let key = measure_key.clone();
|
||||
@@ -1000,6 +1001,7 @@ impl RenderOnce for Tabs {
|
||||
)
|
||||
.absolute()
|
||||
.inset(shadow_bleed);
|
||||
|
||||
let trigger_canvas = canvas(
|
||||
{
|
||||
let key = measure_key;
|
||||
@@ -1065,7 +1067,6 @@ impl Tab {
|
||||
let active = selected || self.pinned;
|
||||
|
||||
let theme = cx.theme();
|
||||
|
||||
let label_color = tab_label_color(ctx.variant, active, self.disabled, cx);
|
||||
|
||||
let titlebar = ctx.variant == TabsVariant::Titlebar;
|
||||
|
||||
@@ -26,6 +26,7 @@ use gpui::{
|
||||
use crate::components::button::{Button, ButtonVariant};
|
||||
use crate::components::common::{
|
||||
DismissHandler, ResultLogErr as _, Sizable as _, StyledExt as _, TOAST_LAYER, floating_panel,
|
||||
v_flex,
|
||||
};
|
||||
use crate::icons::{Icon, IconRole};
|
||||
use crate::theme::{ActiveTheme as _, TOAST_MAX_WIDTH};
|
||||
@@ -254,14 +255,12 @@ impl RenderOnce for ToastsView {
|
||||
let current = self.toasts.read(cx).current.clone();
|
||||
|
||||
deferred(
|
||||
div()
|
||||
v_flex()
|
||||
.id(self.id)
|
||||
.absolute()
|
||||
.left_0()
|
||||
.bottom_4()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.when_some(exiting, |column, entry| {
|
||||
let id = entry.id;
|
||||
|
||||
@@ -25,7 +25,7 @@ use gpui::{
|
||||
};
|
||||
|
||||
use crate::components::common::{
|
||||
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color,
|
||||
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color, v_flex,
|
||||
};
|
||||
use crate::icons::{Icon, IconRole, icon};
|
||||
use crate::theme::ActiveTheme as _;
|
||||
@@ -283,10 +283,8 @@ impl RenderOnce for Tree {
|
||||
})
|
||||
.collect();
|
||||
|
||||
div()
|
||||
v_flex()
|
||||
.id(self.id)
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_0p5()
|
||||
.text_sm()
|
||||
.refine_style(&self.style)
|
||||
|
||||
@@ -19,6 +19,8 @@ use gpui::{
|
||||
Stateful, StatefulInteractiveElement as _, Window, WindowControlArea, div,
|
||||
};
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
use crate::components::common::h_flex;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
use crate::icons::{IconRole, icon};
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
@@ -106,11 +108,9 @@ impl RenderOnce for WindowControls {
|
||||
let client_decorated =
|
||||
matches!(window.window_decorations(), Decorations::Client { .. });
|
||||
|
||||
div()
|
||||
h_flex()
|
||||
.flex_none()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.h_full()
|
||||
.gap_1()
|
||||
.when(client_decorated && controls.minimize, |row| {
|
||||
row.child(circle_button(
|
||||
|
||||
Reference in New Issue
Block a user