Theme tokens in light and dark with high contrast, a palette cross-fade, motion curves and a damped spring, embedded Lucide icons with Inter and JetBrains Mono, Icon, Button, IconButton, and a gallery that captures its own window. Reviewed by codex gpt-6-astra (max): PASS in round 3.
54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
use ely_gpui_component::theme::{ActiveTheme, TextSize};
|
|
use gpui::{App, Div, FontWeight, IntoElement, ParentElement, SharedString, Styled, div};
|
|
|
|
/// Titled block of demos.
|
|
pub fn section(title: impl Into<SharedString>, note: impl Into<SharedString>, cx: &App) -> Div {
|
|
let theme = cx.theme();
|
|
div().flex().flex_col().gap_4().pt_10().child(
|
|
div()
|
|
.flex()
|
|
.flex_col()
|
|
.gap_1()
|
|
.child(
|
|
div()
|
|
.text_size(theme.text_size(TextSize::Md))
|
|
.font_weight(FontWeight::SEMIBOLD)
|
|
.text_color(theme.colors.fg)
|
|
.child(title.into()),
|
|
)
|
|
.child(
|
|
div()
|
|
.text_size(theme.text_size(TextSize::Sm))
|
|
.text_color(theme.colors.fg_muted)
|
|
.child(note.into()),
|
|
),
|
|
)
|
|
}
|
|
|
|
pub fn row() -> Div {
|
|
div().flex().flex_wrap().items_center().gap_3()
|
|
}
|
|
|
|
/// Row whose captions share one line.
|
|
pub fn specimens() -> Div {
|
|
div().flex().flex_wrap().items_end().gap_6()
|
|
}
|
|
|
|
pub fn label(text: impl Into<SharedString>, cx: &App) -> impl IntoElement {
|
|
let theme = cx.theme();
|
|
div()
|
|
.text_size(theme.text_size(TextSize::Xs))
|
|
.text_color(theme.colors.fg_subtle)
|
|
.child(text.into())
|
|
}
|
|
|
|
/// Demo with a caption beneath.
|
|
pub fn specimen(caption: impl Into<SharedString>, body: impl IntoElement, cx: &App) -> Div {
|
|
div()
|
|
.flex()
|
|
.flex_col()
|
|
.gap_2()
|
|
.child(body)
|
|
.child(label(caption, cx))
|
|
}
|