diff --git a/Cargo.lock b/Cargo.lock index d2407cc..954e044 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -748,15 +748,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "id_tree" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcd9db8dd5be8bde5a2624ed4b2dfb74368fe7999eb9c4940fd3ca344b61071a" -dependencies = [ - "snowflake", -] - [[package]] name = "idna" version = "0.3.0" @@ -1460,12 +1451,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "snowflake" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27207bb65232eda1f588cf46db2fee75c0808d557f6b3cf19a75f5d6d7c94df1" - [[package]] name = "spin" version = "0.5.2" @@ -2306,20 +2291,6 @@ dependencies = [ "syn", ] -[[package]] -name = "yewprint" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29de9263e650aab7a0ccf49c53ae6b122082b1451762ca2d0e64367e6c8448b2" -dependencies = [ - "gloo", - "id_tree", - "implicit-clone", - "wasm-bindgen", - "web-sys", - "yew", -] - [[package]] name = "yewprint-app" version = "0.1.0" @@ -2338,7 +2309,6 @@ dependencies = [ "wee_alloc", "yew", "yew-router", - "yewprint", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0fe2016..3e4712f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib"] console_error_panic_hook = { version = "0.1.6", optional = true } wasm-bindgen = "0.2" -web-sys = { version = "0.3", features = ["Window", "MediaQueryList"] } +web-sys = { version = "0.3", features = ["Window", "MediaQueryList", "DomTokenList"] } js-sys = "0.3" # `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size @@ -29,7 +29,7 @@ wee_alloc = { version = "0.4.5", optional = false } yew = { version = "0.20.0", features = ["csr"] } yew-router = { version = "0.17.0" } -yewprint = "0.4.0" +#yewprint = "0.4.0" gloo = "0.8.0" gloo-events = "0.1" futures = "0.3.25" diff --git a/src/app.rs b/src/app.rs index 0076f02..d506520 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3,7 +3,7 @@ use yew::prelude::*; use yew_router::Routable; use yew_router::prelude::Navigator; use yew_router::prelude::use_navigator; -use yewprint::Icon; +use crate::component::fa_icon::FontawesomeIcon; use crate::page::Page; use crate::page::PageRouter; use crate::page::Pages; @@ -11,6 +11,7 @@ use crate::theme::ThemeContext; use crate::theme::ThemeMsg; use crate::theme::ThemeProvider; use crate::component::actionbar::{Actionbar, ActionbarOption}; +use crate::theme::ThemeState; #[function_component] @@ -29,16 +30,16 @@ fn ThemedApp() -> Html { let navigator = use_navigator().unwrap(); // Helper function for generating tabs - fn page_option(current: &Page, page: Page, navigator: Navigator, state: UseStateHandle) -> ActionbarOption { + fn page_option(current: &Page, page: Page, navigator: Navigator, state: UseStateSetter) -> ActionbarOption { let is_current = *current == page; ActionbarOption::new( page.name(), match page { - Page::Home => Icon::Home, - Page::Projects => Icon::Code, - Page::Socials => Icon::SocialMedia, - Page::Gallery => Icon::Camera, - Page::Contact => Icon::Envelope, + Page::Home => FontawesomeIcon::House, + Page::Projects => FontawesomeIcon::Code, + Page::Socials => FontawesomeIcon::ShareNodes, + Page::Gallery => FontawesomeIcon::Camera, + Page::Contact => FontawesomeIcon::Envelope, }, Callback::from(move |_| { navigator.push(&page); @@ -49,6 +50,7 @@ fn ThemedApp() -> Html { } let ctx = use_context::().expect("No theme context supplied"); + let theme_icon = if ctx.theme == ThemeState::Dark { FontawesomeIcon::Sun } else { FontawesomeIcon::Moon }; let page_state = use_state_eq(|| window() .location() @@ -65,23 +67,21 @@ fn ThemedApp() -> Html {
- - {vec![ - page_option(¤t_page, Page::Home, navigator.clone(), page_state.clone()), - page_option(¤t_page, Page::Projects, navigator.clone(), page_state.clone()), - page_option(¤t_page, Page::Socials, navigator.clone(), page_state.clone()), - page_option(¤t_page, Page::Gallery, navigator.clone(), page_state.clone()), - page_option(¤t_page, Page::Contact, navigator, page_state), - ActionbarOption::new_opt( - None, - Some(Icon::Flash), - Some(Callback::from(move |_| ctx.dispatch(ThemeMsg::Toggle))), - true, - false, - false - ) - ]} - + } } \ No newline at end of file diff --git a/src/component/actionbar.rs b/src/component/actionbar.rs index 1dce646..ddc291a 100644 --- a/src/component/actionbar.rs +++ b/src/component/actionbar.rs @@ -1,14 +1,12 @@ -use yew::html::ChildrenRenderer; use yew::prelude::*; use yew::virtual_dom::VNode; -use yewprint::{Collapse, Icon, ButtonGroup}; -use yewprint::Button; -use yewprint::Icon::{MenuClosed, MenuOpen}; + +use super::fa_icon::{FAIcon, FontawesomeIcon}; #[derive(PartialEq, Clone)] pub struct ActionbarOption { name: Option, - icon: Option, + icon: Option, onclick: Option>, center_content: bool, selected: bool, @@ -18,7 +16,7 @@ pub struct ActionbarOption { #[derive(PartialEq, Clone)] struct ActionbarOptionState { inner: ActionbarOption, - callback: UseStateHandle + callback: UseStateSetter } impl Into for ActionbarOption { @@ -34,57 +32,69 @@ impl Into for ActionbarOption { } impl ActionbarOption { - pub fn new_opt(name: Option, icon: Option, onclick: Option>, center_content: bool, selected: bool, fill: bool) -> ActionbarOption { + pub fn new_opt(name: Option, icon: Option, onclick: Option>, center_content: bool, selected: bool, fill: bool) -> ActionbarOption { ActionbarOption { name, icon, onclick, center_content, selected, fill } } - pub fn new(name: &str, icon: Icon, onclick: Callback, selected: bool) -> ActionbarOption { + pub fn new(name: &str, icon: FontawesomeIcon, onclick: Callback, selected: bool) -> ActionbarOption { ActionbarOption::new_opt(Some(name.to_owned()), Some(icon), Some(onclick), false, selected, true) } } impl Into for ActionbarOptionState { fn into(self) -> VNode { - let classes = if self.inner.center_content { classes!() } else { classes!("ab-navbutton") }; let onclick = self.inner.onclick.unwrap_or_default(); html! { - +
+
+ {if let Some(icon) = self.inner.icon { html!{ } } else { html!{} }} + {self.inner.name} +
+
} } } #[derive(Properties, PartialEq)] pub struct ActionbarProps { - pub children: ChildrenRenderer + #[prop_or_default] + pub mobile_title: Option, + pub items: Vec } #[function_component] pub fn Actionbar(props: &ActionbarProps) -> Html { let expanded = use_state_eq(|| false); + let expanded_setter = expanded.setter(); let is_expanded = *expanded; - let children = props.children.iter().map(|opt| ActionbarOptionState { inner: opt, callback: expanded.clone() }).collect::>(); html! { -
-
-