-
Notifications
You must be signed in to change notification settings - Fork 19
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
21 changed files
with
2,508 additions
and
21 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.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "icons" | ||
version = "0.1.0" | ||
authors = ["ALeX Kazik <alex@kazik.de>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
yew = { version = "0.21", features = ["csr"] } | ||
yew-bootstrap = { path = "../../packages/yew-bootstrap" } | ||
|
||
[[bin]] | ||
name = "copy-bootstrap-icons" |
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,61 @@ | ||
# Example of automatically copying the bootstrap-icons files | ||
|
||
This is copies the required files to the `dist` directory, which is recommended. | ||
|
||
Please see [the documentation](https://docs.rs/yew-bootstrap/latest/yew_bootstrap/icons/index.html) for more information. | ||
|
||
A copy of `bootstrap-icons` is included and should change only rarely. `trunk` does not add a hash to generated files, and thus a change in those files won't be detected by `trunk`. | ||
|
||
## Instructions | ||
|
||
1. `Cargo.toml` | ||
|
||
Add the build-executed binary. | ||
|
||
```toml | ||
[[bin]] | ||
name = "copy-bootstrap-icons" | ||
``` | ||
|
||
2. `src/bin/copy-bootstrap-icons.rs` | ||
|
||
Create the program to copy the files. | ||
|
||
```rust | ||
use std::path::PathBuf; | ||
use yew_bootstrap::icons::BIFiles; | ||
|
||
fn main() -> Result<(), std::io::Error> { | ||
let path = PathBuf::from( | ||
std::env::var("TRUNK_STAGING_DIR").expect("Environment variable TRUNK_STAGING_DIR"), | ||
) | ||
.join(BIFiles::NAME); | ||
if !path.is_dir() { | ||
std::fs::create_dir(&path)?; | ||
} | ||
BIFiles::copy(&path) | ||
} | ||
``` | ||
|
||
3. `index.html` | ||
|
||
Set base reference, link the required CSS and specify your WASM program[^1]. | ||
|
||
[^1]: Since we'll be writing a build-executed program, there are now two binaries and trunk needs to know which is your WASM binary. | ||
|
||
```html | ||
<base data-trunk-public-url /> | ||
<link rel="stylesheet" href="bootstrap-icons-v1.10.5/bootstrap-icons.css" /> | ||
<link data-trunk rel="rust" data-bin="name-of-app" /> | ||
``` | ||
|
||
4. `Trunk.toml` | ||
|
||
Add a hook to run the build-executed program. | ||
|
||
```toml | ||
[[hooks]] | ||
stage = "build" | ||
command = "cargo" | ||
command_arguments = ["run", "--bin", "copy-bootstrap-icons"] | ||
``` |
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,4 @@ | ||
[[hooks]] | ||
stage = "build" | ||
command = "cargo" | ||
command_arguments = ["run", "--bin", "copy-bootstrap-icons"] |
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,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<base data-trunk-public-url/> | ||
<meta charset="utf-8"/> | ||
<title>Yew App</title> | ||
<link rel="stylesheet" href="bootstrap-icons-v1.10.5/bootstrap-icons.css"/> | ||
<link data-trunk rel="rust" data-bin="icons"/> | ||
</head> | ||
</html> |
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,13 @@ | ||
use std::path::PathBuf; | ||
use yew_bootstrap::icons::BIFiles; | ||
|
||
fn main() -> Result<(), std::io::Error> { | ||
let path = PathBuf::from( | ||
std::env::var("TRUNK_STAGING_DIR").expect("Environment variable TRUNK_STAGING_DIR"), | ||
) | ||
.join(BIFiles::NAME); | ||
if !path.is_dir() { | ||
std::fs::create_dir(&path)?; | ||
} | ||
BIFiles::copy(&path) | ||
} |
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,13 @@ | ||
use yew::prelude::*; | ||
use yew_bootstrap::icons::*; | ||
|
||
#[function_component(App)] | ||
fn app() -> Html { | ||
html! { | ||
<h1>{"I"}<span style="color: red">{BI::HEART_FILL}</span>{BI::GEAR_FILL}</h1> | ||
} | ||
} | ||
|
||
fn main() { | ||
yew::Renderer::<App>::new().render(); | ||
} |
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
Oops, something went wrong.