From 9d824b267632ee392d971946abd69087637ac667 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Thu, 5 Oct 2023 11:06:43 +0800 Subject: [PATCH] feat: add button component loading prop --- Cargo.toml | 3 ++- gh-pages/src/pages/button/mod.rs | 30 ++++++++++++++++++++++++++++++ src/button/button.css | 6 ++++++ src/button/mod.rs | 21 +++++++++++++++++---- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8b27b9f..d7ea510 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -leptos = { version = "0.5.0", features = ["csr"] } +leptos = { version = "0.5.0", features = ["csr"] } stylers = "0.3.2" web-sys = { version = "0.3.62", features = ["DomRect"] } leptos_dom = { version = "0.5.0" } @@ -22,6 +22,7 @@ icondata = { version = "0.0.7", features = [ "AiCloseOutlined", "AiCheckOutlined", "AiLeftOutlined", + "AiLoadingOutlined", ] } [workspace] diff --git a/gh-pages/src/pages/button/mod.rs b/gh-pages/src/pages/button/mod.rs index aed47be..1a6bdac 100644 --- a/gh-pages/src/pages/button/mod.rs +++ b/gh-pages/src/pages/button/mod.rs @@ -92,6 +92,7 @@ pub fn ButtonPage() -> impl IntoView { "" +

"style"

@@ -108,3 +109,32 @@ pub fn ButtonPage() -> impl IntoView { } } + +#[component] +pub fn LoadingButton() -> impl IntoView { + let loading = create_rw_signal(false); + view! { +

"loading"

+ + + + + + + "ERROR Color Icon" + + + } + "#, "rust")> + "" + + + } +} diff --git a/src/button/button.css b/src/button/button.css index eeec107..f0691b3 100644 --- a/src/button/button.css +++ b/src/button/button.css @@ -43,3 +43,9 @@ padding: 0 10px; border-radius: 50%; } + +@keyframes meltLoadingCircle { + 100% { + transform: rotate(360deg); + } +} diff --git a/src/button/mod.rs b/src/button/mod.rs index 52acc24..c6f976e 100644 --- a/src/button/mod.rs +++ b/src/button/mod.rs @@ -57,6 +57,7 @@ pub fn Button( #[prop(optional, into)] color: MaybeSignal, #[prop(optional, into)] round: MaybeSignal, #[prop(optional, into)] icon: Option, + #[prop(optional, into)] loading: MaybeSignal, #[prop(optional)] children: Option, ) -> impl IntoView { let theme = use_theme(Theme::light); @@ -89,7 +90,7 @@ pub fn Button( "" }; - view! { class=class_name, + view! {class=class_name,