Giter Site home page Giter Site logo

confetti's Introduction

confetti

An rmarkdown extension to add confetti!

Have you ever been working on a report or producing a statistical publication and thought how do I add a confetti button?

Well this R package has been developed to make this routine task easier with pre-built html widgets that can be slotted into an rmarkdown report to add some jazz.

But what if your business case involves using emojis as the confetti? This is fully supported and can be fully configured.

Installation

devtools::install_github('https://github.com/Kiki-Jiji/confetti')

Alternatively clone and build locally.

Usage

In an rmarkdown r code block simply use:


library(confetti)
confetti_button()

You can also supply a config to affect the behaviour such as the choice of emojis or the number. You can also change the button name

# rainbow = "\U0001f308"
# flashlight = "\U0001f526"
# dog = "\U0001f436"

config <- list('emojis' = c("\U0001f308", "\U0001f526", "\U0001f436"),
               'confettiNumber' = 300,
               'confettiColors' = c('#ff0a54', '#ff477e', '#ff7096', '#ff85a1', '#fbb1bd', '#f9bec7')
)

confetti::confetti_button(button_text = "CLick me!",  config = config)


You can supply any valid emoji! Sources include emojipedia or unicode

You can use the emojifont package to find emojis or to RAP the emoji selection

config <- list('emojis' = sapply(sample(emojifont::sample_emoji(), 3), emojifont::emoji))


confetti::confetti_button(button_text = "CLick me!",  config = config)

# Everytime you knit you get 3 new emojis! Very efficient

Confetti on page load

If efficiency is the game why don't you help your users and trigger the confetti for them!

confetti::confetti_on_page_load()

This will trigger the confetti on page load. As always this is customisable, so get creative with them emojis!

config <- list('emojis' = c("\U0001f308", "\U0001f526", "\U0001f436"),
               'confettiNumber' = 300,
               'confettiColors' = c('#ff0a54', '#ff477e', '#ff7096', '#ff85a1', '#fbb1bd', '#f9bec7')
)

confetti::confetti_on_page_load(config)

DIY

Maybe you want to build your own html but add confetti?

Simply use the confetti::diy_confetti() and the trigger_con javascript function is available to use! It's a Create your own, fun for the whole family, type of thing.

<h1 onmouseover="trigger_con()"> Latest GDP Figures</h1>

Now people get the ... fun of confetti whenever they even hover over your titles! No more clicking needed!

Configuration

Options are

  • emojis
  • emojiSize
  • confettiColors
  • confettiRadius
  • confettiNumber

Supply config as a named list, with the name one of the above, and then the parameters. For some, such as emojiSize this is a number, for others such as emojis this is a vector of emojis.

JavaScript Confetti library

This package is an r wrapper around the javascript library js-confetti.

Thanks to the js-confetti package authors and maintainers.

confetti's People

Contributors

kiki-jiji avatar

Watchers

James Cloos avatar  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.