generated from just-the-docs/just-the-docs-template
-
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
1 parent
ea119b1
commit e79e518
Showing
6 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 +1,3 @@ | ||
pub mod board; | ||
pub mod board; | ||
pub mod saved_boards; | ||
pub mod utils; |
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,11 @@ | ||
use leptos::*; | ||
use leptos::prelude::*; | ||
|
||
#[component] | ||
pub fn SavedBoards() -> impl IntoView { | ||
view! { | ||
<div class="grid grid-cols-4 gap-4 mt-4"> | ||
// Thumbnails will go here | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use super::board::{Board, CellContent}; | ||
|
||
pub fn generate_thumbnail(board: &Board) -> String { | ||
let svg = format!( | ||
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> | ||
<rect width="100" height="100" fill="rgb(30, 41, 59)"/> | ||
<g transform="translate(5,5)">{}</g> | ||
</svg>"#, | ||
board.grid.iter().enumerate().map(|(i, row)| { | ||
row.iter().enumerate().map(|(j, cell)| { | ||
let x = j as f32 * 45.0; | ||
let y = i as f32 * 45.0; | ||
match cell { | ||
CellContent::Empty => format!( | ||
r#"<rect x="{}" y="{}" width="40" height="40" fill="rgb(51, 65, 85)"/>"#, | ||
x, y | ||
), | ||
CellContent::Player => format!( | ||
r#"<rect x="{}" y="{}" width="40" height="40" fill="rgb(51, 65, 85)"/> | ||
<circle cx="{:.0}" cy="{:.0}" r="15" fill="rgb(37, 99, 235)"/>"#, | ||
x, y, x + 20.0, y + 20.0 | ||
), | ||
CellContent::Trap => format!( | ||
r#"<rect x="{}" y="{}" width="40" height="40" fill="rgb(51, 65, 85)"/> | ||
<path d="M{} {} l30 30 m0 -30 l-30 30" stroke="rgb(220, 38, 38)" stroke-width="4"/>"#, | ||
x, y, x + 5.0, y + 5.0 | ||
), | ||
} | ||
}).collect::<String>() | ||
}).collect::<String>() | ||
); | ||
|
||
format!( | ||
r#"data:image/svg+xml,{}"#, | ||
urlencoding::encode(&svg) | ||
) | ||
} |