feat: add user-configurable theme settings
This commit is contained in:
+36
-2
@@ -1,4 +1,5 @@
|
||||
use gpui::{App, Div, IntoElement, ParentElement, SharedString, Styled, div};
|
||||
use gpui_kit::base::StyledExt as _;
|
||||
use gpui_kit::component::{ActiveTheme, h_flex, v_flex};
|
||||
|
||||
/// A settings row: the label and description on the left, the control on the right.
|
||||
@@ -9,14 +10,15 @@ pub fn settings_row(
|
||||
cx: &App,
|
||||
) -> Div {
|
||||
h_flex()
|
||||
.gap_3()
|
||||
.w_full()
|
||||
.gap_4()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.child(div().text_sm().child(label.into()))
|
||||
.child(div().text_sm().font_semibold().child(label.into()))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
@@ -24,5 +26,37 @@ pub fn settings_row(
|
||||
.child(description.into()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.w_40()
|
||||
.flex_shrink_0()
|
||||
.justify_end()
|
||||
.items_center()
|
||||
.child(control),
|
||||
)
|
||||
}
|
||||
|
||||
/// A full-width settings block with the label and description in one header.
|
||||
pub fn settings_block(
|
||||
label: impl Into<SharedString>,
|
||||
description: impl Into<SharedString>,
|
||||
control: impl IntoElement,
|
||||
cx: &App,
|
||||
) -> impl IntoElement {
|
||||
v_flex()
|
||||
.w_full()
|
||||
.gap_3()
|
||||
.child(
|
||||
v_flex()
|
||||
.w_full()
|
||||
.child(div().text_sm().font_semibold().child(label.into()))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.truncate()
|
||||
.child(description.into()),
|
||||
),
|
||||
)
|
||||
.child(control)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user