-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export function tma_ready() { | ||
console.log(Telegram.WebApp.version); | ||
return Telegram.WebApp.ready(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::telegram::get_item; | ||
use yew::prelude::*; | ||
|
||
#[function_component(PointsComp)] | ||
pub fn points() -> Html { | ||
let points = use_state(|| 0); | ||
{ | ||
let points = points.clone(); | ||
use_effect(move || { | ||
let points = points.clone(); | ||
wasm_bindgen_futures::spawn_local(async move { | ||
match get_item("points").await { | ||
Ok(result) => { | ||
let points_value = result.as_f64().unwrap_or(0.0) as i32; | ||
points.set(points_value); | ||
} | ||
Err(error) => { | ||
log::error!("Error getting points: {:?}", error); | ||
} | ||
} | ||
}); | ||
|| () | ||
}); | ||
} | ||
|
||
html! { | ||
<div class="points"> | ||
<span class="symbol">{"★"}</span> | ||
<span class="value">{*points}</span> | ||
</div> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.points { | ||
position: fixed; | ||
top: 10px; | ||
right: 10px; | ||
background-color: rgba(240, 240, 240, 0.8); | ||
padding: 10px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
display: vertical; | ||
|
||
.value { | ||
font-size: 1.5em; | ||
font-weight: bold; | ||
color: #333; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.symbol { | ||
margin-right: 5px; | ||
color: gold; | ||
font-size: 0.8em; | ||
} | ||
} |