use std::time::Duration;
use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
const ROW: &str = "display: flex; flex-wrap: wrap; gap: 12px; align-items: center;";
const COLUMN: &str = "display: flex; flex-direction: column; gap: 16px;";
const PLAIN_BUTTON: &str = "all: unset; cursor: pointer; border-radius: 999px;";
fn placeholder(color: &str, label: &str) -> String {
let svg = format!(
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 180'><rect width='320' height='180' fill='{color}'/><text x='160' y='98' font-family='sans-serif' font-size='28' fill='white' text-anchor='middle'>{label}</text></svg>"
);
format!(
"data:image/svg+xml;utf8,{}",
svg.replace('%', "%25")
.replace('#', "%23")
.replace('<', "%3C")
.replace('>', "%3E")
.replace(' ', "%20")
)
}
#[component]
pub fn ContentSection() -> Element {
rsx! {
section { style: COLUMN,
h2 { class: "ui-label", "Content" }
TextParts {}
Conversation {}
CodeSamples {}
Formatting {}
MediaParts {}
Planning {}
Social {}
Secrets {}
}
}
}
#[component]
fn TextParts() -> Element {
let mut filter = use_signal(|| "all");
rsx! {
div { style: COLUMN,
Typography {
Eyebrow { "Release notes" }
h3 { "Lumen for Dioxus" }
p {
"Press "
Kbd { "Ctrl" }
" + "
Kbd { "K" }
" to open the command palette."
}
}
div { style: ROW,
Marker { "1" }
Marker { variant: MarkerVariant::Success, "Done" }
Marker { variant: MarkerVariant::Warning, "Review" }
Marker { variant: MarkerVariant::Danger, "Blocked" }
}
div { style: ROW,
for (value , label , count) in [("all", "All", "24"), ("open", "Open", "7"), ("closed", "Closed", "17")] {
button {
key: "{value}",
aria_pressed: if filter() == value { "true" } else { "false" },
r#type: "button",
style: PLAIN_BUTTON,
onclick: move |_| filter.set(value),
Pill {
count,
variant: if filter() == value { PillVariant::Brand } else { PillVariant::Outline },
"{label}"
}
}
}
Pill { href: "#tags", "Linked tag" }
span { style: "position: relative; display: inline-flex;",
Avatar { fallback: "SM" }
FloatingBadge { "3" }
}
}
ul { style: "list-style: none; padding: 0; margin: 0; display: grid; gap: 8px;",
Item { r#as: ItemElement::Li, "Design tokens" }
Item { r#as: ItemElement::Li, glass: true, "Glass item" }
}
Note { label: "Note", "Dioxus Native draws these components without a webview." }
Note { border_position: NoteBorderPosition::Right, "A note with the border on the right." }
}
}
}
#[component]
fn Conversation() -> Element {
let mut preview_state = use_signal(|| None::<AttachmentPreviewState>);
let mut retry = use_signal(|| 0_u32);
let mut last_state = use_signal(|| "ready".to_string());
rsx! {
div { style: COLUMN,
Message {
Bubble { "How do I install Lumen for Dioxus?" }
}
Message { from: MessageFrom::User,
Bubble { from: MessageFrom::User, "Add lumen-dioxus to Cargo.toml." }
}
AttachmentList { aria_label: "Files",
li { Attachment { "design-review.pdf" } }
li { Attachment { href: "#download", glass: true, "tokens.json" } }
li {
AttachmentPreview {
alt: "Gradient preview",
src: placeholder("#6d28d9", "Preview"),
state: preview_state(),
retry_key: retry().to_string(),
caption: rsx! { "preview.svg ({last_state})" },
on_state_change: move |state: AttachmentPreviewState| last_state.set(state.as_str().to_string()),
actions: rsx! {
Button {
size: ButtonSize::Sm,
variant: ButtonVariant::Outline,
onclick: move |_| preview_state.set(Some(AttachmentPreviewState::Loading)),
"Show loading"
}
Button {
size: ButtonSize::Sm,
variant: ButtonVariant::Ghost,
onclick: move |_| {
preview_state.set(None);
retry += 1;
},
"Reset"
}
},
}
}
li {
AttachmentPreview { alt: "Contract", src: "#contract.pdf", content_type: "application/pdf" }
}
}
}
}
}
#[component]
fn CodeSamples() -> Element {
let mut manager = use_signal(|| "cargo".to_string());
let items = vec![
CodeTabsItem::new("cargo", "cargo add lumen-dioxus").language("bash"),
CodeTabsItem::new("toml", "lumen-dioxus = \"6.0\"").language("toml"),
];
rsx! {
div { style: COLUMN,
p {
"Render "
lumen_dioxus::Code { "LumenStyles" }
" once near the root of the app."
}
lumen_dioxus::Code {
variant: CodeVariant::Block,
language: "ts",
label: "theme.ts",
copy: true,
recovery_label: "Copy it manually",
code: "const theme = 'paper' // the default reading theme\nexport default theme",
}
CodeTabs {
items: items.clone(),
storage_key: "gallery-install",
on_value_change: move |value| manager.set(value),
}
p { "Selected: {manager}. The tabs below follow it through the shared storage key." }
CodeTabs { items, storage_key: "gallery-install", copy: false }
Terminal {
title: "Install",
copy: true,
lines: vec![
TerminalLine::command("cargo add lumen-dioxus"),
TerminalLine::output("Adding lumen-dioxus v0.1.0").tone(TerminalLineTone::Success),
TerminalLine::comment("# then run the gallery"),
TerminalLine::command("cargo run --example gallery --features native-example"),
],
}
InstallCommand { command: "cargo add lumen-dioxus", label: "cargo command" }
}
}
}
#[component]
fn Formatting() -> Element {
let mut revenue = use_signal(|| 1234.5_f64);
rsx! {
div { style: ROW,
FormattedNumber { value: revenue() }
FormattedNumber {
value: revenue(),
format: FormattedNumberFormat::Currency,
currency: "USD",
notation: FormattedNumberNotation::Compact,
}
FormattedNumber { value: 0.256, format: FormattedNumberFormat::Percent, maximum_fraction_digits: 1.0 }
FormattedNumber { value: 12, format: FormattedNumberFormat::Unit, unit: "kilobyte" }
span {
"Colombia (COP): "
FormattedNumber {
value: revenue(),
locale: "es-CO",
lang: "es-CO",
format: FormattedNumberFormat::Currency,
currency: "COP",
}
}
span {
"Arabic digits: "
FormattedNumber {
value: revenue(),
locale: "ar-EG-u-nu-arab",
lang: "ar-EG",
dir: "rtl",
}
}
span {
"French distance: "
FormattedNumber {
value: 2,
locale: "fr-FR",
lang: "fr-FR",
format: FormattedNumberFormat::Unit,
unit: "meter",
unit_display: FormattedNumberUnitDisplay::Long,
}
}
FormattedNumber { value: "not a number" }
FormattedDate { date_time: "2026-12-01", date_style: FormattedDateStyle::Long }
FormattedDate {
date_time: "2026-12-01T15:04:00Z",
date_style: FormattedDateStyle::Medium,
time_style: FormattedDateTimeStyle::Short,
}
Button {
size: ButtonSize::Sm,
variant: ButtonVariant::Outline,
onclick: move |_| revenue *= 10.0,
"Multiply by 10"
}
}
}
}
#[component]
fn MediaParts() -> Element {
let mut reveal = use_signal(|| 50.0);
let mut mode = use_signal(ImageComparisonMode::default);
let mut viewport = use_signal(MediaViewportValue::default);
let mut selected = use_signal(|| vec![true, false, false]);
let count = selected.read().iter().filter(|value| **value).count();
rsx! {
div { style: COLUMN,
div { style: ROW,
Image { alt: "Indigo placeholder", src: placeholder("#4338ca", "Image"), width: "160" }
CoverImage { hover: true, show_bottom_gradient: true, style: "width: 220px; height: 124px;",
Image { alt: "Cover placeholder", src: placeholder("#0f766e", "Cover"), radius: ImageRadius::None }
}
}
DeviceFrame { device: DeviceFrameDevice::Iphone, style: "max-width: 220px;",
Image { alt: "Phone screen", src: placeholder("#be185d", "App"), radius: ImageRadius::None }
}
ImageComparison {
label: "Reveal the edited photo",
value: reveal(),
on_value_change: move |value| reveal.set(value),
mode: mode(),
before: rsx! {
Image { alt: "Original", src: placeholder("#475569", "Before"), radius: ImageRadius::None }
},
after: rsx! {
Image { alt: "Edited", src: placeholder("#16a34a", "After"), radius: ImageRadius::None }
},
div { style: ROW,
for (value , label) in [
(ImageComparisonMode::Reveal, "Reveal"),
(ImageComparisonMode::SideBySide, "Side by side"),
(ImageComparisonMode::Before, "Before"),
(ImageComparisonMode::After, "After"),
]
{
Button {
key: "{label}",
size: ButtonSize::Sm,
variant: if mode() == value { ButtonVariant::Secondary } else { ButtonVariant::Ghost },
onclick: move |_| mode.set(value),
"{label}"
}
}
}
}
MediaViewport {
label: "Product photo",
value: viewport(),
on_value_change: move |value| viewport.set(value),
Image { alt: "Product", src: placeholder("#c2410c", "Zoom me"), radius: ImageRadius::None }
}
MediaFilmstrip { label: "Photos", selection_label: format!("{count} selected"),
for index in 0..3_usize {
li { key: "{index}",
MediaThumbnail {
label: format!("Photo {}", index + 1),
order: u32::try_from(index + 1).unwrap_or(0),
selected: selected.read()[index],
state: if index == 2 { MediaThumbnailState::Loading } else { MediaThumbnailState::Ready },
onclick: move |_| {
let mut list = selected.write();
list[index] = !list[index];
},
Image {
alt: "",
src: placeholder(["#1d4ed8", "#9333ea", "#0891b2"][index], "Photo"),
radius: ImageRadius::None,
}
}
}
}
}
}
}
}
#[component]
fn Planning() -> Element {
let mut events = use_signal(|| {
vec![
ScheduleEvent {
id: "standup".into(),
title: "Standup".into(),
start: "2026-12-01T09:00:00Z".into(),
end: "2026-12-01T09:15:00Z".into(),
resource_id: Some("room-a".into()),
},
ScheduleEvent {
id: "review".into(),
title: "Design review".into(),
start: "2026-12-02T14:00:00Z".into(),
end: "2026-12-02T15:00:00Z".into(),
resource_id: Some("room-a".into()),
},
]
});
let dates = vec!["2026-12-01".to_string(), "2026-12-02".to_string()];
let slots = create_schedule_slots(&dates, &events.read(), &[]);
let conflicts = schedule_conflicts(&events.read()).len();
rsx! {
div { style: COLUMN,
Agenda { aria_label: "Today",
header { "Tuesday" }
ol {
li { "09:00 Standup" }
li { "14:00 Design review" }
}
}
Schedule { aria_label: "This week",
div { "data-ui-schedule-grid": "", style: "--ui-schedule-columns: 2;",
for slot in slots {
div { key: "{slot.date}", "data-ui-schedule-slot": "",
strong { "{slot.date}" }
for event in slot.events {
div { key: "{event.id}", "data-ui-schedule-event": "", "{event.title}" }
}
}
}
}
}
div { style: ROW,
Button {
size: ButtonSize::Sm,
variant: ButtonVariant::Outline,
onclick: move |_| {
let moved = move_schedule_event(
&events.read(),
"review",
"2026-12-01T09:00:00Z",
"2026-12-01T10:00:00Z",
None,
);
events.set(moved);
},
"Move the review to Tuesday 09:00"
}
span { "Conflicts: {conflicts}" }
}
}
}
}
#[component]
fn Social() -> Element {
rsx! {
div { style: COLUMN,
Testimonial {
author: "Ada Lovelace",
author_role: "Analyst",
initials: "AL",
context: "Engine notes",
cite: "https://lumen.santi020k.com",
p { "The components render the same markup on every renderer." }
}
TestimonialGroup {
label: "What people say",
items: vec![
TestimonialGroupItem::new("Grace Hopper", "Ship it."),
TestimonialGroupItem::new("Alan Turing", "Clear and consistent."),
TestimonialGroupItem::new("Katherine Johnson", "Numbers line up."),
],
}
QRCode { value: "https://lumen.santi020k.com", size: 140 }
}
}
}
#[component]
fn Secrets() -> Element {
let mut state = use_signal(|| "hidden".to_string());
rsx! {
div { style: COLUMN,
SecretValue {
label: "API key",
value: "sk_test_example_key_1234",
auto_hide_after: 10_000.0,
on_state_change: move |next: SecretValueState| state.set(next.as_str().to_string()),
}
SecretValue {
label: "Webhook secret",
cache_on_hide: true,
load_value: move |()| -> SecretValueFuture {
Box::pin(async {
lumen_dioxus::time::sleep(Duration::from_millis(600)).await;
Ok("webhook_secret_5f0c1d".to_string())
})
},
}
p { "API key state: {state}" }
}
}
}