Compare commits

..

2 Commits

Author SHA1 Message Date
itzelot01 d43f6ab02b YEW descentralized app with js callback 2024-01-22 21:48:10 +00:00
itzelot01 35bc3d5ed4 YEW Template 2024-01-18 22:43:48 +00:00
6 changed files with 98 additions and 0 deletions

18
Cargo.toml Normal file
View File

@ -0,0 +1,18 @@
[package]
name = "trunk-template"
version = "0.1.0"
edition = "2021"
description = "Template for starting a Yew project using Trunk"
readme = "README.md"
repository = "https://github.com/yewstack/yew-trunk-minimal-template"
license = "MIT OR Apache-2.0"
keywords = ["yew", "trunk"]
categories = ["gui", "wasm", "web-programming"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
js-sys = "0.3.66"
once_cell = "1.18.0"
wasm-bindgen = "0.2.90"
wasm-bindgen-futures = "0.4.39"
yew = { version="0.20", features=["csr"] }

9
index.html Normal file
View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>DECA NFTs</title>
<script scr = "/js/script.js"></script>
<link data-trunk rel="sass" href="index.scss">
</head>
</html>

25
index.scss Normal file
View File

@ -0,0 +1,25 @@
html,
body {
height: 100%;
margin: 0;
}
body {
align-items: left;
display: flex;
justify-content: center;
background: linear-gradient(#cfb0da 42.44%, #a530e4);
font-size: 1.5rem;
}
main {
color: #340034;
font-family: TimesNewRoman;
text-align: center;
}
h1 + .subtitle {
display: block;
margin-top: -1em;
}

5
js/script.js Normal file
View File

@ -0,0 +1,5 @@
export function get_now_date() {
console.log("get_now_date called!");
var curr_date = new Date();
return curr_date.toDateString();
}

7
src/bindings.rs Normal file
View File

@ -0,0 +1,7 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen(module = "/js/script.js")]
extern "C" {
#[wasm_bindgen]
pub fn get_now_date() -> String;
}

34
src/main.rs Normal file
View File

@ -0,0 +1,34 @@
use yew::prelude::*;
mod bindings;
struct App;
impl Component for App {
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
Self
}
fn view(&self, _ctx: &Context<Self>) -> Html {
//let get_obj = bindings::getObj();
//let obj = use_memo((), get_obj);
html! {
<div class="section">
<div class="container">
<main>
<h1 class="title">{"DECA NFTs"}</h1>
<h4>{"These are the DECA NFTs available for giveaway"}</h4>
<h2 class="subtitle">{bindings::get_now_date()}</h2>
</main>
</div>
</div>
}
}
}
fn main() {
yew::Renderer::<App>::new().render();
}