Skip to content

Commit

Permalink
Merge pull request #123 from averissimo/122-fix_class
Browse files Browse the repository at this point in the history
Appends class when fully qualified name is used
  • Loading branch information
rich-iannone authored Aug 7, 2024
2 parents 32617f7 + 51a0211 commit e0a38c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit e0a38c2

Please sign in to comment.