Skip to content

Commit

Permalink
Merge pull request #113 from rstudio/article-available-icons
Browse files Browse the repository at this point in the history
Add a pkgdown article showing the available icons
  • Loading branch information
rich-iannone authored Aug 23, 2023
2 parents 7d4bd14 + f3aba56 commit 06799b6
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
^_pkgdown\.yml$
^LICENSE\.md$
^/tools$
^docs$
^codecov\.yml$
^data-raw$
^tests/manual_tests$
index.md
vignettes
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# Session Data files
.RData

# Docs folder from `pkgdown::build_site()`
docs/
inst/doc

# Example code in package build process
*-Ex.R

Expand Down
12 changes: 10 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ destination: docs
home:
strip_header: true

template:
bootstrap: 5

reference:
- title: Font Awesome Icon Insertion
desc: >
Expand All @@ -19,5 +22,10 @@ reference:
- fa_html_dependency
- fa_metadata

development:
version_tooltip: "Development version"
navbar:
structure:
left: [icons, reference, news]
components:
icons:
text: Icons
href: articles/icon-reference.html
Binary file added pkgdown/favicon/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.html
*.R
*.css
80 changes: 80 additions & 0 deletions vignettes/icon-reference.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: "Icon Reference"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Icon Reference}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r options, message=FALSE, warning=FALSE, include=FALSE}
library(tidyverse)
library(fontawesome)
library(gt)
```

The `fontawesome` package has `r vec_fmt_integer(length(fontawesome::fa_metadata()[["icon_names_full"]]))` icons. *That's a lot of icons!* This reference table lists them all in alphabetical order by the icon name. With a function like `fa()`, you can use **Icon Name**, and not the **Full Name**, for sake of simplicity. Not too many icons have variants (those that do have both the *Solid* and *Regular* forms) but if you prefer a specific form the **Full Name** can be used within `fa()`.

<hr />

```{r echo=FALSE}
fa_icons_vec <- c()
for (i in seq_len(nrow(fontawesome:::fa_tbl))) {
icon_svg_i <- as.character(fontawesome::fa(fontawesome:::fa_tbl[i, ][["full_name"]]))
fa_icons_vec <- c(fa_icons_vec, icon_svg_i)
}
fontawesome_table <-
fontawesome:::fa_tbl |>
dplyr::select(icon = name, label, icon_name = name, full_name) |>
dplyr::mutate(icon = fa_icons_vec) |>
gt() |>
fmt_markdown(columns = icon) |>
cols_label(
icon = ""
) |>
cols_label_with(fn = function(x) gsub("_", " ", x)) |>
tab_style(
style = list(
cell_text(
font = system_fonts(name = "monospace-code"),
size = px(12)
),
cell_borders(
sides = c("l", "r"),
color = "lightblue",
weight = px(1.5))
),
locations = cells_body(columns = -icon)
) |>
tab_style(
style = css(position = "sticky", top = "-1em", `z-index` = 10),
locations = cells_column_labels()
) |>
tab_style(
style = cell_fill(color = "lightblue"),
locations = cells_body(columns = icon)
) |>
cols_align(align = "center", columns = icon) |>
cols_width(
icon ~ px(50),
label ~ px(200),
icon_name ~ px(200),
full_name ~ px(230)
) |>
opt_all_caps() |>
opt_stylize(style = 6) |>
tab_options(
table.border.top.style = "hidden",
column_labels.border.bottom.style = "hidden",
container.height = px(490)
)
fontawesome_table
```

<hr />

Data table published on `r gt::vec_fmt_datetime(Sys.time(), format = "EEEE, MMMM d, y 'at' h:mm a ('UTC')")`.

0 comments on commit 06799b6

Please sign in to comment.