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