Skip to content

Put some confetti in your Shiny App ๐ŸŽ‰

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

ArthurData/confetti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

23 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

{confetti}

R-CMD-check Codecov test coverage

The goal of {confetti} is to put some ๐ŸŽŠ confetti ๐ŸŽŠ in your Shiny Application.

This package uses a JavaScript library called: canvas-confetti.

Installation

You can install the development version of confetti from GitHub with:

# install.packages("devtools")
devtools::install_github("ArthurData/confetti")

Example

Letโ€™s make a fun application with some confetti!

โš  You will have to open your app in a new window with your favorite web browser to see confetti.

library(confetti)
library(shiny)

First, you have to use useConfetti() in the UI of your Shiny app. This function will attach all depencies for you.

ui <- fluidRow(
  useConfetti(),
  actionButton(
    inputId = "go",
    label =  "Default confetti"
  ),
  actionButton(
    inputId = "go2",
    label = "Colored confetti"
  )
)

Then, in you server, call the sendConfetti() or sendfireworks() function whatever you want.

Here, every time an actionButton is clicked, the according observeEvent is launch and send confetti.

A dedicated input called sentConfetti is added and counts the number of times confetti is sent.

server <- function(input, output, session) {
  observeEvent(input$go, {
    sendConfetti()
    message("You have sent ", input$sentConfetti, " confetti")
  })

  observeEvent(input$go2, {
    sendConfetti(
      colors = list("#DAB436", "#36DA62", "#365CDA", "#DA36AE")
    )
    message("You have sent ", input$sentConfetti, " confetti")
  })
}

Full code:

library(confetti)
library(shiny)

ui <- fluidRow(
  useConfetti(),
  actionButton(
    inputId = "go",
    label =  "Default confetti"
  ),
  actionButton(
    inputId = "go2",
    label = "Colored confetti"
  )
)

server <- function(input, output, session) {
  observeEvent(input$go, {
    sendConfetti()
    message("You have sent ", input$sentConfetti, " confetti")
  })

  observeEvent(input$go2, {
    sendConfetti(
      colors = list("#DAB436", "#36DA62", "#365CDA", "#DA36AE")
    )
    message("You have sent ", input$sentConfetti, " confetti")
  })
}

shinyApp(ui = ui, server = server)

or run this example:

runApp(system.file("shiny", "example", "app.R", package = "confetti"))

Code of Conduct

Please note that the confetti project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

Put some confetti in your Shiny App ๐ŸŽ‰

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published