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

Feature Request: Update font-awesome version #1966

Closed
JesseVent opened this issue Mar 3, 2018 · 5 comments
Closed

Feature Request: Update font-awesome version #1966

JesseVent opened this issue Mar 3, 2018 · 5 comments
Assignees
Milestone

Comments

@JesseVent
Copy link

stylesheet = "css/font-awesome.min.css"

I've noticed theres been huge changes the font-awesome icons in the last few versions they have released, the documentation for icons() is now is incorrect as most of the icons listed through their explorer will fail to load when using in shiny app.

Please update the font-awesome font files or the new svg implementation

@nteetor
Copy link

nteetor commented Mar 6, 2018

Which link are you following to the list of Font Awesome icons? If one heads over to the Font Awesome 4.7 website, see https://fontawesome.com/v4.7.0/, the icons listed ought to all work with icon(). The updates in Font Awesome 5 are not trivial. For now the best solution may be to make sure Shiny's documentation points to the Font Awesome 4.7 website.

@jcheng5
Copy link
Member

jcheng5 commented Apr 16, 2018

Some notes regarding FA 4 vs 5: https://www.drupal.org/project/fontawesome/issues/2930071

@nzcoops
Copy link

nzcoops commented Aug 1, 2018

Just adding a +1 for this request.
It gets confusing with the shiny help pages pointing to a page of icons where 90% of them are unusable with no clear indication (to new users) as to why some wouldn't/wouldn't work.

@JesseVent
Copy link
Author

I just committed some changes into a fork at JesseVent@9ce6f87 which appear to work, build passes all tests and CRAN checks. So could be something to look into - Unfortunately I couldn't think of a way to provide fallback support for 4.7.0 other than using a mapping document in a csv file.

Seems to work pretty well in the scenarios I tested, definitely renders in-app. Hope it helps.

icon <- function(name, class = NULL, lib = "font-awesome", style="fas") {
  prefixes <- list(
    "font-awesome" = "fa",
    "glyphicon" = "glyphicon"
  )
  prefix <- prefixes[[lib]]

  # determine stylesheet
  if (is.null(prefix)) {
    stop("Unknown font library '", lib, "' specified. Must be one of ",
         paste0('"', names(prefixes), '"', collapse = ", "))
  }

  # Add fallback support for 4.7.0 by checking for legacy icons names and replacing with 5.2.0 names
  if ( prefix == "fa" && !is.null(name)) {
    mapfile <- system.file("www","shared","font-awesome", "fa-mapping.csv", package = "shiny")
    fa_lookup  <- read.csv(mapfile, stringsAsFactors = FALSE)
    match      <- match(name, fa_lookup$v4_name)
    prefix_tag <- NA
    if (!is.na(match)) {
      match      <- as.numeric(match)
      name       <- fa_lookup$v5_name[match]
      prefix_tag <- fa_lookup$prefix[match]
    }
    if (is.na(prefix_tag)) prefix_tag <- style
  }

  # build the icon class (allow name to be null so that other functions
  # e.g. buildTabset can pass an explicit class value)
  iconClass <- ""
  if (!is.null(name)) {
    # support for glyphicon
    if(prefix != "fa") iconClass <- paste0(prefix, " ", prefix, "-", name)
    # new font-awesome format
    if(prefix == "fa") iconClass <- paste0(prefix_tag, " ", prefix, "-", name)
  }
  if (!is.null(class)) iconClass <- paste(iconClass, class)

  iconTag <- tags$i(class = iconClass)

  # font-awesome needs an additional dependency (glyphicon is in bootstrap)
  if (lib == "font-awesome") {
    htmltools::htmlDependency("font-awesome", "5.2.0", c(href="shared/font-awesome"), script = "js/all.js")
  }
  iconTag
}
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking examples ... OK
* checking for unstated dependencies intests... OK
* checking tests ...
* Runningtest-all.ROK
* DONE
Status: 1 NOTE
checking installed package size ... NOTE

R CMD check results
0 errors | 0 warnings | 1 note 

R CMD check succeeded

alandipert added a commit that referenced this issue Sep 18, 2018
- Upgrades FontAwesome to a new major (breaking) version, but
  is backwards compatible because we include the v4-shims CSS that maps
  old names to new.
- This is a step toward full V5 adoption that doesn't require us to
  come up with a plan for deprecating V4 icon names.
- Details: https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4
- Related to #2156 and #1966
jcheng5 pushed a commit that referenced this issue Sep 18, 2018
* Upgrade FontAwesome to 5.3.1

- Upgrades FontAwesome to a new major (breaking) version, but
  is backwards compatible because we include the v4-shims CSS that maps
  old names to new.
- This is a step toward full V5 adoption that doesn't require us to
  come up with a plan for deprecating V4 icon names.
- Details: https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4
- Related to #2156 and #1966

* Improvements to icon

- Clarify in docs that fontawesome V5 icons accessible with V4-style names
- Make icons browseable: icon('address-book') will now open the Viewer
  pane of RStudio IDE so that icons can be experimented with more easily.

* Update LICENSE with CC for FontAwesome .svgs

* Update NEWS
@jcheng5
Copy link
Member

jcheng5 commented Sep 18, 2018

We've decided to upgrade to 5.3.1 and include the fontawesome v4 compatibility shim. This should ensure that everybody can use the new icons without existing apps breaking (though some of the fancy new functionality in fontawesome 5 will not be available--hopefully you will be able to use that through the rstudio/fontawesome or ropenscilabs/icon package).

@jcheng5 jcheng5 closed this as completed Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants