-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use embedded SVG instead of fonts for icons
The [downsides of icon fonts] are well-documented, and also, why ship all of the icons when it only uses 14? [downsides of icon fonts]: https://speakerdeck.com/ninjanails/death-to-icon-fonts
- Loading branch information
Showing
17 changed files
with
105 additions
and
2,753 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use font_awesome_as_a_crate as fa; | ||
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; | ||
|
||
pub fn fa_helper( | ||
h: &Helper<'_, '_>, | ||
_r: &Handlebars<'_>, | ||
_ctx: &Context, | ||
_rc: &mut RenderContext<'_, '_>, | ||
out: &mut dyn Output, | ||
) -> Result<(), RenderError> { | ||
trace!("fa_helper (handlebars helper)"); | ||
|
||
let type_ = h | ||
.param(0) | ||
.and_then(|v| v.value().as_str()) | ||
.and_then(|v| fa::Type::from_str(v).ok()) | ||
.ok_or_else(|| { | ||
RenderError::new("Param 0 with String type is required for fontawesome helper.") | ||
})?; | ||
|
||
let name = h.param(1).and_then(|v| v.value().as_str()).ok_or_else(|| { | ||
RenderError::new("Param 1 with String type is required for fontawesome helper.") | ||
})?; | ||
|
||
trace!("fa_helper: {} {}", type_, name); | ||
|
||
let name = if name.starts_with("fa-") { | ||
&name[3..] | ||
} else { | ||
&name[..] | ||
}; | ||
|
||
if let Some(id) = h.param(2).and_then(|v| v.value().as_str()) { | ||
out.write(&format!("<span class=fa-svg id=\"{}\">", id))?; | ||
} else { | ||
out.write("<span class=fa-svg>")?; | ||
} | ||
out.write( | ||
fa::svg(type_, name).map_err(|_| RenderError::new(format!("Missing font {}", name)))?, | ||
)?; | ||
out.write("</span>")?; | ||
|
||
Ok(()) | ||
} |
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,3 +1,4 @@ | ||
pub mod fontawesome; | ||
pub mod navigation; | ||
pub mod theme; | ||
pub mod toc; |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
2,671 changes: 0 additions & 2,671 deletions
2,671
src/theme/FontAwesome/fonts/fontawesome-webfont.svg
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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.