lumen-dioxus 6.0.0

Lumen UI components for Dioxus: web, desktop, mobile, and Dioxus Native (Blitz).
Documentation
//! Gallery section: motion, brand, and decoration: `Particles`, `RevealGroup`, `ScrollReveal`,
//! `VisualEffect`, `Marquee`, `Parallax`, `ViewProgress`, `MotionGroup`, `TextRoll`, `SplitText`,
//! `AnimatedNumber`, `Backdrop`, `Graphic`, `AnimatedLogo`, `AnimatedPortrait`, and `Illustration`.

use dioxus::prelude::*;
use lumen_dioxus::prelude::*;

const EFFECTS: [(VisualEffectVariant, &str); 4] = [
    (VisualEffectVariant::Mesh, "Mesh"),
    (VisualEffectVariant::Aurora, "Aurora"),
    (VisualEffectVariant::Spotlight, "Spotlight"),
    (VisualEffectVariant::Grain, "Grain"),
];

const ILLUSTRATIONS: [(IllustrationVariant, &str); 4] = [
    (IllustrationVariant::Empty, "No projects yet"),
    (IllustrationVariant::Success, "Published"),
    (IllustrationVariant::Error, "Build failed"),
    (IllustrationVariant::Offline, "You are offline"),
];

const ROW: &str = "display: flex; flex-wrap: wrap; gap: 12px; align-items: center;";

/// Every motion component in its common states.
#[component]
pub fn MotionSection() -> Element {
    let mut revenue = use_signal(|| 12_480.0);
    let mut effect = use_signal(|| 0usize);
    let mut illustration = use_signal(|| 0usize);
    let mut releases = use_signal(|| vec!["v6.0", "v5.4", "v5.3"]);
    let (effect_variant, effect_name) = EFFECTS[effect() % EFFECTS.len()];
    let (artwork, artwork_label) = ILLUSTRATIONS[illustration() % ILLUSTRATIONS.len()];

    rsx! {
        section { style: "display: flex; flex-direction: column; gap: 20px;",
            h2 { class: "ui-label", "Motion" }

            ScrollReveal { animation: RevealAnimation::SlideUp,
                Card {
                    CardHeader {
                        CardTitle { "Scroll reveal" }
                        CardDescription { "Slides in once it enters the viewport on the web and desktop." }
                    }
                }
            }

            RevealGroup {
                stagger: 120,
                style: "display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;",
                Card { CardContent { "Design tokens" } }
                Card { CardContent { "Components" } }
                Card { CardContent { "Native adapters" } }
            }

            SplitText {
                element: SplitTextElement::H3,
                by: SplitTextBy::Char,
                trigger: SplitTextTrigger::Load,
                text: "Ship interfaces that feel alive",
            }

            div { style: ROW,
                a { class: "ui-button ui-button--secondary", href: "#motion",
                    TextRoll { mode: TextRollMode::Chars, text: "Read the motion guide" }
                }
                a { href: "#motion", TextRoll { text: "Line roll" } }
            }

            div { style: ROW,
                strong {
                    AnimatedNumber { value: revenue(), prefix: "$", duration: MotionDuration::Entrance }
                }
                Button {
                    variant: ButtonVariant::Secondary,
                    onclick: move |_| revenue += 1_250.0,
                    "Record a sale"
                }
            }

            Marquee {
                decorative: false,
                fade: true,
                items: vec![
                    "Astro".to_string(),
                    "React".to_string(),
                    "Web Components".to_string(),
                    "SwiftUI".to_string(),
                    "Compose".to_string(),
                    "Dioxus".to_string(),
                ],
                label: "Supported frameworks",
                outline: MarqueeOutline::Alternate,
            }
            Marquee { label: "Partners", direction: MarqueeDirection::End, speed: MarqueeSpeed::Slow,
                li { "Acme" }
                li { "Harbor" }
                li { "Summit" }
                li { "Umbrella" }
            }

            VisualEffect {
                variant: effect_variant,
                animated: true,
                intensity: 0.7,
                style: "min-height: 140px; border-radius: 16px; padding: 20px;",
                div { style: "display: flex; flex-direction: column; gap: 12px; position: relative;",
                    strong { "{effect_name} effect" }
                    div {
                        Button { onclick: move |_| effect += 1, "Next effect" }
                    }
                }
            }

            Particles { density: ParticlesDensity::Low,
                div { style: "padding: 24px;", "Particles drift behind this content." }
            }

            div { style: "display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;",
                Parallax { clip: true, zoom: 1.2, style: "height: 140px; border-radius: 12px;",
                    div { class: "ui-card", style: "height: 100%; display: grid; place-items: center;", "Parallax layer" }
                }
                ViewProgress { range: ViewProgressRange::Entry,
                    div { class: "ui-card", style: "height: 140px; display: grid; place-items: center;",
                        "Scrubs --ui-view-progress"
                    }
                }
            }

            div { style: "display: flex; flex-direction: column; gap: 8px;",
                MotionGroup { style: "display: flex; gap: 8px;",
                    for release in releases() {
                        Badge { key: "{release}", "data-ui-motion-key": release, "{release}" }
                    }
                }
                div {
                    Button {
                        variant: ButtonVariant::Outline,
                        onclick: move |_| releases.write().rotate_left(1),
                        "Rotate releases"
                    }
                }
            }

            Backdrop { variant: BackdropVariant::Grid, tone: BackdropTone::Accent,
                div { style: "padding: 24px; display: flex; align-items: center; gap: 16px;",
                    Graphic { label: "Lumen", variant: GraphicVariant::Orbit,
                        Icon { name: "sparkles" }
                    }
                    Graphic { size: GraphicSize::Sm, tone: GraphicTone::Neutral, variant: GraphicVariant::Grid,
                        Icon { name: "layers" }
                    }
                    AnimatedLogo { animation: AnimatedLogoAnimation::Sequence, aria_label: "Lumen UI", role: "img",
                        svg { "aria-hidden": "true", view_box: "0 0 64 64", width: "32", height: "32",
                            rect { "data-ui-logo-pop": "", width: "64", height: "64", rx: "14", fill: "#0f172a" }
                            path {
                                "data-ui-logo-draw": "",
                                "pathLength": "100",
                                style: "--ui-logo-delay: 300ms;",
                                d: "M15 16V47H24 M33 28V40C33 46 36.5 49 42 49S51 46 51 40V28",
                                fill: "none",
                                stroke: "#f8fafc",
                                stroke_width: "6.5",
                                stroke_linecap: "round",
                                stroke_linejoin: "round",
                            }
                            circle { "data-ui-logo-pop": "", style: "--ui-logo-delay: 700ms;", cx: "51", cy: "16", r: "4", fill: "#f59e0b" }
                        }
                    }
                }
            }

            AnimatedPortrait { style: "max-width: 220px;",
                div { class: "ui-animated-portrait__card",
                    Avatar { fallback: "SL", alt: "Santiago" }
                }
            }

            div { style: ROW,
                Illustration { variant: artwork, label: artwork_label, size: IllustrationSize::Lg }
                Button {
                    variant: ButtonVariant::Ghost,
                    onclick: move |_| illustration += 1,
                    "{artwork_label}: next state"
                }
            }
        }
    }
}