Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appends class when fully qualified name is used #123

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/fa_i.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fa_i <- function(
if (grepl("^fa[a-z] fa-[a-z-]+$", name)) {
# Case where fully-qualified icon name is provided

iconClass <- name
iconClass <- paste(c(name, class), collapse = " ")

} else {
# Case where short icon name is provided
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-fa_icon.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ test_that("the `fa_i()` function returns an icon object", {
expect_message(regexp = NA, fa_i("euroz", html_dependency = fake_dep))
})

test_that("the `fa_i()` function combines fully qualified name and class", {
icon_no_class <- fa_i("fas fa-arrows-rotate", class = NULL)
expect_equal(icon_no_class$attribs$class, "fas fa-arrows-rotate")

icon <- fa_i("arrows-rotate", class = "fa-spin", prefer_type = "solid")
expect_equal(icon$attribs$class, "fas fa-arrows-rotate fa-spin")

icon_qualified <- fa_i("fas fa-arrows-rotate", class = "fa-spin")
expect_equal(icon_qualified$attribs$class, "fas fa-arrows-rotate fa-spin")
})

test_that("Known alias names (for short name) result in retrival of icons", {

# Get the complete set of known alias names for the included icons
Expand Down
Loading