From ea1c1b9408cd0282c5f78f42a54291eaaf46cb46 Mon Sep 17 00:00:00 2001 From: Yash Karandikar Date: Sat, 23 Oct 2021 18:49:12 -0500 Subject: [PATCH] Add method for switching views --- noters/index.html | 3 ++- noters/src/components.rs | 9 +++++++++ noters/src/main.rs | 15 +++++++++++++++ noters/style.css | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 noters/src/components.rs create mode 100644 noters/style.css diff --git a/noters/index.html b/noters/index.html index 3e90691..6351721 100644 --- a/noters/index.html +++ b/noters/index.html @@ -3,7 +3,8 @@ NoteRS - + + diff --git a/noters/src/components.rs b/noters/src/components.rs new file mode 100644 index 0000000..f9feaaa --- /dev/null +++ b/noters/src/components.rs @@ -0,0 +1,9 @@ +use sycamore::prelude::*; + +#[component(DefaultView)] +pub fn default_view() -> Template { + template! { + p { "Hello, world!" } + } +} + diff --git a/noters/src/main.rs b/noters/src/main.rs index e7715f8..d522bb3 100644 --- a/noters/src/main.rs +++ b/noters/src/main.rs @@ -1,3 +1,4 @@ +mod components; mod console; mod local_storage; @@ -8,6 +9,11 @@ macro_rules! log { ($($t:tt)*) => (console::log_raw(&format_args!($($t)*).to_string())) } +#[allow(unused)] // temp +pub enum AppMode { + Default // note list view +} + fn main() { #[allow(unused_variables)] // Allow because localStorage might be empty let keys = { @@ -27,7 +33,16 @@ fn main() { new_vec }; + let mode = Signal::new(AppMode::Default); + sycamore::render(|| template! { h1(style="text-align: center") { "NoteRS" } + div(class="wrapper") { + (match *mode.get() { + AppMode::Default => template! { + crate::components::DefaultView() + } + }) + } }); } diff --git a/noters/style.css b/noters/style.css new file mode 100644 index 0000000..bc171c5 --- /dev/null +++ b/noters/style.css @@ -0,0 +1,5 @@ +.wrapper { + margin: auto; + width: 60%; + padding: 10px; +} \ No newline at end of file