Skip to content

Commit

Permalink
randomly refined and bump version of yew to 0.21
Browse files Browse the repository at this point in the history
ignore Cargo.lock and target more generally
  • Loading branch information
mhfan committed Apr 19, 2024
1 parent 3c324e2 commit b64759a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/target
/Cargo.lock

Cargo.lock
target

/dist
/node_modules
/package-lock.json
/assets/css/tailwind.css

14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description = "WebUI/inyew for 24-Game/Puzzle/Challenge"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
yew = { version = "0.20", features = ["csr"] }
yew-router = "0.17" #git = "https://github.com/yewstack/yew"
yew = { version = "0.21", features = [ "csr" ] } # client-side rendering
yew-router = "0.18" #git = "https://github.com/yewstack/yew"
#reqwasm = "0.5"
#serde = "1.0"
#gloo = "0.8"
Expand All @@ -27,23 +27,21 @@ log = "0.4"
rand = "0.8" # path = "..",
inrust = { git = "https://github.com/mhfan/inrust", default-features = false, features = [ "ahash" ] } # "cc", "serde"
instant = { version = "0.1", features = [ "wasm-bindgen" ] }

[dependencies.getrandom]
features = [ "js" ]
version = "0.2"
getrandom = { version = "0.2", features = [ "js" ]}

[dependencies.web-sys]
features = [ "HtmlInputElement", "HtmlFieldSetElement", "HtmlSelectElement",
"HtmlCollection", "DomTokenList", ]
version = "0.3"

[profile.dev]
incremental = true
opt-level = 1

[profile.release]
codegen-units = 1
strip = 'debuginfo'
opt-level = "s"
#strip = true # XXX: why not working for wasm?
panic = 'abort'
lto = true

[workspace]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

![gh-pages-publish](https://github.com/mhfan/inyew/actions/workflows/publish_gh_pages.yml/badge.svg)
[![dependency status](https://deps.rs/repo/github/mhfan/inyew/status.svg)](https://deps.rs/repo/github/mhfan/inyew)

# Study Yew/Rust for Frontend GUI

Expand Down
20 changes: 10 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Game24State {

fn form_expr(&mut self) {
let opd = &self.opd_elq;
let opr = self.opr_elm.as_ref().unwrap();
let opr = self.opr_elm.as_ref().unwrap();

let str = format!("({} {} {})", opd[0].value(), opr.value(), opd[1].value());
opd[0].set_size(str.len() as u32); opd[0].set_value(&str);
Expand All @@ -69,15 +69,15 @@ impl Game24State {

self.opd_elq.clear(); self.opr_elm = None;
self.ncnt += 1; if self.ncnt == self.nums.len() as u8 {
let str = str.chars().map(|ch|
match ch { '×' => '*', '÷' => '/', _ => ch }).collect::<String>();
//let str = str.chars().map(|ch|
// match ch { '×' => '*', '÷' => '/', _ => ch }).collect::<String>();

//opr.parent_element().unwrap().parent_element().unwrap()
// .dyn_into::<HtmlFieldSetElement>().unwrap().set_disabled(true);
self.grp_opr.cast::<HtmlFieldSetElement>().unwrap().set_disabled(true);
let eqm_elm = &self.eqm_elm.cast::<HtmlElement>().unwrap();

if str.parse::<Expr>().unwrap().value() == &self.goal {
if str.parse::<Expr>().is_ok_and(|e| e.value() == &self.goal) {
let tmr_elm = &self.tmr_elm.cast::<HtmlElement>().unwrap();
tmr_elm.set_inner_text(&format!("{:.1}s", self.tnow.elapsed().as_secs_f32()));
tmr_elm.set_hidden(false);
Expand Down Expand Up @@ -251,6 +251,11 @@ impl Component for Game24State {
} else { if inp.focus().is_ok() { inp.select() } None }
});

let ctrl_class = "px-4 py-2 m-4 text-gray-900 font-bold bg-gradient-to-r \
from-stone-200 via-stone-400 to-stone-500 rounded-lg hover:bg-gradient-to-br \
focus:ring-4 focus:outline-none focus:ring-stone-300 shadow-lg shadow-stone-500/50 \
dark:focus:ring-stone-800 dark:shadow-lg dark:shadow-stone-800/80";

let num_class = "px-4 py-2 my-4 w-fit appearance-none select-text \
read-only:bg-transparent bg-stone-200 border border-purple-200 \
text-center text-2xl text-purple-600 font-semibold \
Expand All @@ -273,14 +278,9 @@ impl Component for Game24State {
placeholder="?" inputmode="numeric" pattern=r"-?\d+(\/\d+)?"
class={ classes!(num_class, "aria-checked:ring-purple-600",
"aria-checked:ring", "rounded-full", "mx-2") }/>
} // https://regexr.com, https://regex101.com
} // https://regexr.com, https://regex101.com, https://rustexp.lpil.uk
}).collect::<Html>();

let ctrl_class = "px-4 py-2 m-4 text-gray-900 font-bold bg-gradient-to-r \
from-stone-200 via-stone-400 to-stone-500 rounded-lg hover:bg-gradient-to-br \
focus:ring-4 focus:outline-none focus:ring-stone-300 shadow-lg shadow-stone-500/50 \
dark:focus:ring-stone-800 dark:shadow-lg dark:shadow-stone-800/80";

//let resolving = use_state_eq(|| false); // XXX: reactive
html! { <main class="mt-auto mb-auto">
<div id="play-cards"/> // TODO:
Expand Down

0 comments on commit b64759a

Please sign in to comment.