diff --git a/Cargo.lock b/Cargo.lock index 7a909d9..0476de1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1923,9 +1923,9 @@ dependencies = [ [[package]] name = "xtask-wasm" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a078921c435f7181ac151ebd655c5c6ec4456f37b16aa52a3ad242ccee8016c" +checksum = "72b8fc162610b6505cf16d401b6cd58659a22767dc6ed0e9dd9cc9e59614f178" dependencies = [ "fs_extra", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 4290812..f19b615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ id_tree = { version = "1.7", optional = true } wasm-bindgen = "0.2" gloo = "0.6" - [build-dependencies] regex = { version = "1", default-features = false, features = ["std", "unicode-perl"] } heck = "0.3" diff --git a/netlify.toml b/netlify.toml index 3d60501..99ae440 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,8 @@ [build] publish = "target/release/dist" command = "cargo xtask dist --release" + +[[redirects]] +from = "/*" +to = "/index.html" +status = 200 diff --git a/src/button_group.rs b/src/button_group.rs index ff559b1..e17143b 100644 --- a/src/button_group.rs +++ b/src/button_group.rs @@ -1,4 +1,5 @@ use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct ButtonGroupProps { @@ -11,7 +12,7 @@ pub struct ButtonGroupProps { #[prop_or_default] pub large: bool, #[prop_or_default] - pub style: Option, + pub style: Option, #[prop_or_default] pub children: html::Children, #[prop_or_default] diff --git a/src/buttons.rs b/src/buttons.rs index a31364a..5e17737 100644 --- a/src/buttons.rs +++ b/src/buttons.rs @@ -1,5 +1,6 @@ use crate::{Icon, IconName, Intent, Spinner, ICON_SIZE_LARGE}; use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct ButtonProps { @@ -24,13 +25,13 @@ pub struct ButtonProps { #[prop_or_default] pub intent: Option, #[prop_or_default] - pub title: String, + pub title: Option, #[prop_or_default] pub onclick: Callback, #[prop_or_default] pub class: Classes, #[prop_or_default] - pub style: Option, + pub style: Option, #[prop_or_default] pub children: html::Children, } diff --git a/src/callout.rs b/src/callout.rs index 59e00a0..1052d28 100644 --- a/src/callout.rs +++ b/src/callout.rs @@ -1,6 +1,7 @@ use crate::icon::ICON_SIZE_LARGE; use crate::{Icon, IconName, Intent}; use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct CalloutProps { @@ -13,7 +14,7 @@ pub struct CalloutProps { #[prop_or_default] pub intent: Option, #[prop_or_default] - pub title: Option, + pub title: Option, pub children: html::Children, } diff --git a/src/collapse.rs b/src/collapse.rs index 202d00b..940f9bb 100644 --- a/src/collapse.rs +++ b/src/collapse.rs @@ -176,7 +176,8 @@ impl Component for Collapse { if !self.translated { content_style.push_str("transform: translateY(0px); "); } else if let Some(ref height_when_open) = self.height_when_open { - content_style.push_str(&format!("transform: translateY(-{}); ", height_when_open)); + content_style + .push_str(format!("transform: translateY(-{})", height_when_open).as_str()); } else { unreachable!("height_when_open was undefined while translated is set"); } diff --git a/src/menu.rs b/src/menu.rs index c142a1e..ac420b4 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1,5 +1,6 @@ use crate::{Icon, IconName, Intent, H6}; use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct MenuProps { @@ -41,7 +42,7 @@ pub struct MenuItemProps { #[prop_or_default] pub disabled: bool, #[prop_or_default] - pub href: Option, + pub href: Option, #[prop_or_default] pub label: Option, #[prop_or_default] diff --git a/src/tag.rs b/src/tag.rs index bc3afec..479986d 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -1,5 +1,6 @@ use crate::{if_html, Icon, IconName, Intent, Text}; use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct TagProps { @@ -31,11 +32,11 @@ pub struct TagProps { #[prop_or_default] pub round: bool, #[prop_or_default] - pub title: Option, + pub title: Option, #[prop_or_default] pub class: Classes, #[prop_or_default] - pub style: Option, + pub style: Option, } #[function_component(Tag)] diff --git a/src/text.rs b/src/text.rs index 77f0985..c0c760b 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1,4 +1,5 @@ use yew::prelude::*; +use yew::virtual_dom::AttrValue; #[derive(Clone, PartialEq, Properties)] pub struct TextProps { @@ -12,9 +13,9 @@ pub struct TextProps { #[prop_or_default] pub inline: bool, #[prop_or_default] - pub title: Option, + pub title: Option, #[prop_or_default] - pub style: Option, + pub style: Option, } #[function_component(Text)] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 739f4d8..b56474f 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -5,7 +5,7 @@ use std::{ }; use xtask_wasm::{ anyhow::{Context, Result}, - clap, + clap, DistResult, }; #[derive(clap::Parser)] @@ -26,28 +26,28 @@ fn main() -> Result<()> { let cli: Cli = clap::Parser::parse(); match cli { - Cli::Dist(arg) => { + Cli::Dist(dist) => { log::info!("Generating package..."); download_css(false)?; - let result = arg + let DistResult { dist_dir, .. } = dist .static_dir_path("yewprint-doc/static") .run("yewprint-doc")?; - fs::copy( - "yewprint-doc/src/logo.svg", - result.dist_dir.join("favicon.svg"), - )?; + fs::copy("yewprint-doc/src/logo.svg", dist_dir.join("favicon.svg"))?; } - Cli::Watch(arg) => { + Cli::Watch(watch) => { let mut command = process::Command::new("cargo"); command.args(["xtask", "dist"]); - arg.run(command)?; + watch.run(command)?; } - Cli::Start(arg) => { - arg.arg("dist").start(xtask_wasm::default_dist_dir(false))?; + Cli::Start(dev_server) => { + dev_server + .arg("dist") + .not_found("index.html") + .start(xtask_wasm::default_dist_dir(false))?; } Cli::UpdateCSS => download_css(true)?, } diff --git a/yewprint-doc/src/app.rs b/yewprint-doc/src/app.rs index 1de415c..636afec 100644 --- a/yewprint-doc/src/app.rs +++ b/yewprint-doc/src/app.rs @@ -41,7 +41,7 @@ pub struct App { pub enum Msg { ToggleLight, - GoToMenu(DocMenu), + GoToMenu(MouseEvent, DocMenu), } impl Component for App { @@ -60,7 +60,8 @@ impl Component for App { fn update(&mut self, ctx: &Context, msg: Self::Message) -> bool { match msg { Msg::ToggleLight => self.dark_theme ^= true, - Msg::GoToMenu(doc_menu) => { + Msg::GoToMenu(event, doc_menu) => { + event.prevent_default(); if let Some(history) = ctx.link().history() { history.push(doc_menu); } else { @@ -98,122 +99,146 @@ impl Component for App { /> // NOTE: thanks to keep this list of sorted // alphabetically (except for the light switch) @@ -341,12 +366,13 @@ pub enum DocMenu { Tabs, #[at("/tag")] Tag, - #[at("/textarea")] + #[at("/text-area")] TextArea, #[at("/text")] Text, #[at("/tree")] Tree, + #[not_found] #[at("/")] Home, }