Add method for switching views

This commit is contained in:
Yash Karandikar 2021-10-23 18:49:12 -05:00
parent 1ceca74824
commit ea1c1b9408
Signed by: karx
GPG key ID: A794DA2529474BA5
4 changed files with 31 additions and 1 deletions

View file

@ -3,7 +3,8 @@
<head>
<meta charset="utf-8" />
<title>NoteRS</title>
<link rel="inline" data-trunk type="js" href="utils.js" />
<link rel="inline" data-trunk type="js" href="utils.js">
<link rel="css" data-trunk href="style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css">

9
noters/src/components.rs Normal file
View file

@ -0,0 +1,9 @@
use sycamore::prelude::*;
#[component(DefaultView<G>)]
pub fn default_view() -> Template<G> {
template! {
p { "Hello, world!" }
}
}

View file

@ -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()
}
})
}
});
}

5
noters/style.css Normal file
View file

@ -0,0 +1,5 @@
.wrapper {
margin: auto;
width: 60%;
padding: 10px;
}