Coder Social home page Coder Social logo

phosphoricons's Introduction

phosphoricons

version Codecov test coverage R-CMD-check

R wrapper for using Phosphor Icons in shiny applications or rmarkdown documents. Visit phosphoricons.com for a list of all available icons.

Installation

Install from CRAN with:

install.packages("phosphoricons")

You can install development version from GitHub with:

remotes::install_github("dreamRs/phosphoricons")

Icons usage

Create an icon with ph() function:

library(phosphoricons)
ph("lightning")

There’s 5 weights available:

ph("lightning", weight = "thin")

ph("lightning", weight = "light")

ph("lightning", weight = "regular")

ph("lightning", weight = "bold")

ph("lightning", weight = "fill")

Colorize icon using fill argument:

ph("lightning", weight = "bold", fill = "gold")

There’s two type of icons:

  • SVG icons, created with ph()
  • Font icons, created with ph_i()

There’s a big debate between Web Fonts vs SVG for icons, but mainly:

  • Web fonts require an htmlDependency that include all icons even if you use one, it will increase the size of your document in self contained mode.
  • SVG icons won’t currently work with some shiny functions with an icon argument.

Bonus

Fill icon according to percentage:

ph_fill(
  ph("heart", weight = "fill", height = 128),
  colors = c("#DF0101", "#F6CECE"),
  breaks = 0.7
)

ph_fill(
  ph("star", weight = "fill", height = 128, stroke = "gold", `stroke-width` = 10),
  colors = c("gold", "#FFF"),
  breaks = 0.5,
  orientation = "h"
)

Icon waffle:

waffle_icon(
  values = sample(c("Cats", "Dogs"), 200, TRUE),
  colors = list(
    Cats = "#456990",
    Dogs = "#F45B69"
  ),
  icons = list(
    Cats = ph("cat", height = NULL),
    Dogs = ph("dog", height = NULL)
  ),
  ncol = 15,
  nrow = 8,
  width = "500px"
)

phosphoricons's People

Contributors

pvictor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.