From b24115ce2031d07fa92863c8c09d982cb3e44d76 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 28 Sep 2023 15:43:44 +0200 Subject: [PATCH] feat: implemented signin/signup button toggling --- src/main.rs | 2 +- src/topbar.rs | 101 +++++++++++++++++++++++++++++++++-------------- style/home.css | 2 +- style/topbar.css | 9 ++++- 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/src/main.rs b/src/main.rs index c5d7795..9b6665d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ mod topbar; +use topbar::TopBar; use yew::prelude::*; use yew_router::prelude::*; -use topbar::TopBar; #[derive(Clone, Routable, PartialEq)] enum Route { diff --git a/src/topbar.rs b/src/topbar.rs index 7ee875d..e701129 100644 --- a/src/topbar.rs +++ b/src/topbar.rs @@ -1,43 +1,84 @@ use yew::prelude::*; +pub enum Msg { + ToggleSignIn, + ToggleSignUp, +} + #[derive(Properties, PartialEq)] pub struct TabProps { pub text: AttrValue, - pub link: AttrValue, } #[function_component] -pub fn Tab(props: &TabProps) -> Html { - html!{ -
  • - - - - - {props.text.clone()} - - - -
  • +fn Tab(props: &TabProps) -> Html { + html! { + + + + + {props.text.clone()} + + + } } -#[function_component] -pub fn TopBar() -> Html { - html!{ - +impl Component for TopBar { + type Message = Msg; + type Properties = (); + + fn create(_ctx: &Context) -> Self { + Self { + sign_in: false, + sign_up: false, + } } -} \ No newline at end of file + + fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { + match msg { + Msg::ToggleSignIn => { + self.sign_up = false; + self.sign_in = !self.sign_in; + true + } + Msg::ToggleSignUp => { + self.sign_in = false; + self.sign_up = !self.sign_up; + true + } + } + } + + fn view(&self, ctx: &Context) -> Html { + html! { + + } + } +} diff --git a/style/home.css b/style/home.css index 06b98aa..6068c18 100644 --- a/style/home.css +++ b/style/home.css @@ -15,7 +15,7 @@ main { } .content { - margin: 12px; + padding: 12px; height: calc(100% - 48px); width: calc(100% - 24px); } diff --git a/style/topbar.css b/style/topbar.css index f48301b..551fa19 100644 --- a/style/topbar.css +++ b/style/topbar.css @@ -1,10 +1,17 @@ .tabs li { display: inline-block; - padding-left: 8px; + padding-right: 8px; } .tabs li a { position: relative; + cursor: default; +} + +.tabs li button { + position: relative; + border: none; + background: none; } .tab-svg-path {