From 1049c9ea10f14d98df1b42945a306502ab1f3df5 Mon Sep 17 00:00:00 2001 From: tiye Date: Thu, 22 Dec 2022 22:41:53 +0800 Subject: [PATCH] add ui_button_primary ui_button_danger; tag 0.0.16 --- Cargo.lock | 2 +- demo_respo/src/plugins.rs | 5 ++-- respo/Cargo.toml | 2 +- respo/src/ui.rs | 56 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 088865c..23fb2ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "respo" -version = "0.0.15" +version = "0.0.16" dependencies = [ "cirru_parser", "js-sys", diff --git a/demo_respo/src/plugins.rs b/demo_respo/src/plugins.rs index a6ecd7c..11b936d 100644 --- a/demo_respo/src/plugins.rs +++ b/demo_respo/src/plugins.rs @@ -1,5 +1,6 @@ use std::fmt::Debug; +use respo::ui::{ui_button_danger, ui_button_primary}; use respo::RespoEvent; use respo::{space, ui::ui_row_parted, RespoStyle}; use serde::{Deserialize, Serialize}; @@ -208,13 +209,13 @@ pub fn comp_plugins_demo(states: &StatesTree) -> Result, Str button().class(ui_button()).inner_text("Try Prompt").on_click(on_prompt).to_owned(), space(Some(8), None), button() - .class(ui_button()) + .class(ui_button_primary()) .inner_text("Try Custom Modal") .on_click(on_modal) .to_owned(), space(Some(8), None), button() - .class(ui_button()) + .class(ui_button_danger()) .inner_text("Try Custom Drawer") .on_click(on_drawer) .to_owned(), diff --git a/respo/Cargo.toml b/respo/Cargo.toml index 7fc3c72..30d1352 100644 --- a/respo/Cargo.toml +++ b/respo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "respo" -version = "0.0.15" +version = "0.0.16" edition = "2021" description = "a tiny virtual DOM library migrated from ClojureScript" license = "Apache-2.0" diff --git a/respo/src/ui.rs b/respo/src/ui.rs index 4bc1f94..d355e1d 100644 --- a/respo/src/ui.rs +++ b/respo/src/ui.rs @@ -72,7 +72,61 @@ static_styles!( ( "$0:active", RespoStyle::default() - .transform(CssTransform::Scale(1.04, 1.04)) + .transform(CssTransform::Scale(1.02, 1.02)) + .transition_duration(0.0), + ), +); + +static_styles!( + ui_button_primary, + ( + "$0", + RespoStyle::default() + .outline(None) + .color(CssColor::White) + .background_color(CssColor::Hsl(220, 80, 60)) + .border(Some((0., CssBorderStyle::Solid, CssColor::Hsl(220, 80, 60)))) + .min_width(CssSize::Px(80.)) + .line_height(CssLineHeight::Px(24.)) + .border_radius(4.) + .font_size(14.) + .cursor("pointer".to_owned()) + .transition_duration(200.) + .text_align(CssTextAlign::Center), + ), + ("$0:hover", RespoStyle::default().background_color(CssColor::Hsl(220, 80, 64))), + ( + "$0:active", + RespoStyle::default() + .transform(CssTransform::Scale(1.02, 1.02)) + .background_color(CssColor::Hsl(220, 80, 68)) + .transition_duration(0.0), + ), +); + +static_styles!( + ui_button_danger, + ( + "$0", + RespoStyle::default() + .outline(None) + .color(CssColor::White) + .background_color(CssColor::Hsl(6, 100, 60)) + .border(Some((0., CssBorderStyle::Solid, CssColor::Hsl(6, 100, 60)))) + .min_width(CssSize::Px(80.)) + .line_height(CssLineHeight::Px(24.)) + .border_radius(4.) + .font_size(14.) + .cursor("pointer".to_owned()) + .transition_duration(200.) + .text_align(CssTextAlign::Center), + ), + ("$0:hover", RespoStyle::default().background_color(CssColor::Hsl(6, 100, 64))), + ( + "$0:active", + RespoStyle::default() + .transform(CssTransform::Scale(1.02, 1.02)) + .background_color(CssColor::Hsl(6, 100, 68)) .transition_duration(0.0), ), );