Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerNet committed Aug 24, 2024
1 parent 4119022 commit fa9aeef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
12 changes: 6 additions & 6 deletions web/src/app/minesweeper/players.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ where
<table class="border border-solid border-slate-400 border-collapse table-auto w-full max-w-xs text-sm text-center">
<thead>
<tr>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Player
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Username
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Score
</th>
</tr>
Expand Down Expand Up @@ -170,8 +170,8 @@ fn PlayerRow(player_num: usize, player: Option<ClientPlayer>) -> impl IntoView {

view! {
<tr class=player_class>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{player_num}</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">
<td class="border border-slate-100 dark:border-slate-700 p-1">{player_num}</td>
<td class="border border-slate-100 dark:border-slate-700 p-1">
{username}
{if is_dead {
view! {
Expand Down Expand Up @@ -208,7 +208,7 @@ fn PlayerRow(player_num: usize, player: Option<ClientPlayer>) -> impl IntoView {
}}

</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{score}</td>
<td class="border border-slate-100 dark:border-slate-700 p-1">{score}</td>
</tr>
}
}
Expand Down
40 changes: 27 additions & 13 deletions web/src/app/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,37 @@ async fn get_player_games() -> Result<Vec<PlayerGame>, ServerFnError> {
#[component]
fn GameHistory() -> impl IntoView {
let player_games = create_resource(|| (), move |_| async { get_player_games().await });
let td_class = "border border-slate-100 dark:border-slate-700 p-1";

let loading_row = move |num: usize| {
let player_class = player_class(0) + " text-black";
view! {
<tr class=player_class>
<td class=td_class>Game {num}</td>
<td class=td_class></td>
<td class=td_class></td>
<td class=td_class>Loading...</td>
<td class=td_class></td>
<td class=td_class></td>
</tr>
}
};
let game_view = move |game: PlayerGame| {
let player_class = player_class(game.player as usize) + " text-black";
view! {
<tr class=player_class>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">
<td class=td_class>
<A
class="text-sky-800 hover:text-sky-500 font-medium"
href=format!("/game/{}", game.game_id)
>
{game.game_id}
</A>
</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{game.start_time}</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{game.game_mode.long_name()}</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{game.game_time}</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">
<td class=td_class>{game.start_time}</td>
<td class=td_class>{game.game_mode.long_name()}</td>
<td class=td_class>{game.game_time}</td>
<td class=td_class>
{if game.dead {
view! {
<span class=player_icon_holder("bg-red-600", true)>
Expand Down Expand Up @@ -274,7 +288,7 @@ fn GameHistory() -> impl IntoView {
}}

</td>
<td class="border-b border-slate-100 dark:border-slate-700 p-1">{game.score}</td>
<td class=td_class>{game.score}</td>
</tr>
}
};
Expand All @@ -283,28 +297,28 @@ fn GameHistory() -> impl IntoView {
<table class="border border-solid border-slate-400 border-collapse table-auto text-sm text-center">
<thead>
<tr>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Game
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Date
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Game Mode
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Duration
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Status
</th>
<th class="border-b dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
<th class="border dark:border-slate-600 font-medium p-4 text-slate-400 dark:text-slate-200 ">
Score
</th>
</tr>
</thead>
<tbody>
<Suspense fallback=move || ()>
<Suspense fallback=move || (0..5).map(loading_row).collect_view()>

{move || {
player_games
Expand Down

0 comments on commit fa9aeef

Please sign in to comment.