Git Product home page Git Product logo

shinythings's Introduction

shinyThings

shinyThings is a collection of reusable Shiny components (modules and inputs).

My personal DRY storage for Shiny bits I’ve used in my projects.

Installation

You can install shinyThings from Github via

# install.packages("devtools")
devtools::install_github("gadenbuie/shinyThings")

Components

dropdownButton

Implements Bootstrap 3 Button Dropdowns using Shiny modules.

# Try it out
shinyThings::buttonGroupDemo()

Pagination

Implements Bootstrap 3 pagination and pagers using Shiny modules.

# Try it out
shinyThings::pagerDemo()

Toggle Button Groups

Implements groups of toggle buttons using Bootstrap 3 button toolbars as a Shiny input. Each button can be toggled on or off, and the group may be limited to a single on button at a time, or multiple active buttons. (For one-button-always-selected behavior, see radio switch buttons below.)

# Try it out
shinyThings::buttonGroupDemo()

# UI Side
shinyThings::buttonGroup("input-id", choices = letters[1:3])

# Server Side
shinyThings::updateButtonGroupValue("input-id", values = "b")

Radio Switch Buttons

Implements a button-styled version of shiny::radioButtons(). One button is always active (unless unset by the app).

Adapted from CSS code by Mike Hemberger described in https://thestizmedia.com/radio-buttons-as-toggle-buttons-with-css/.

# Try it out
shinyThings::radioSwitchButtonsDemo()

# UI Side ----
# Set Default style
shinyThings::radioSwitchButtons_default_style(selected_background = "#00589a")
# Create input
shinyThings::radioSwitchButtons("input-id", choices = letters[1:5])

# Server Side ----
shinyThings::updateRadioSwitchButtons("input-id", selected = "b")

Undo/Redo History

A Shiny module for undo/redo history. The Shiny module accepts an arbitrary reactive data value. Changes in the state of this reactive value are tracked and added to the user’s history. The user can then repeatedly undo and redo to walk through this stack. The module returns the current selected value of the reactive from this historical stack, or NULL when the app state was changed by the user.

# Try it out
shinyThings::undoHistoryDemo()

# UI Side ----
# UI with undo/redo buttons
undoHistoryUI("module-id")

# Server Side ----
# Create a reactive value whose state will be tracked. Note that you control 
# the structure of the data being tracked and also how the data will be 
# restored. `undo_app_state` will have the same structure.
undo_app_state <- undoHistory("module-id", value = reactive({
  list(
    text = input$a_text_input_id,
    selected = input$a_select_input_id
  )
}))

# Use an observer to update inputs as required as the user steps through the
# undo/redo history stack.
observe({
  req(!is.null(undo_app_state))
  updateTextInput(session, "a_text_input_id", value = undo_app_state()$text)
  updateSelectInput(session, "a_select_input_id", selected = undo_app_state()$selected)
})

shinythings's People

Contributors

gadenbuie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shinythings's Issues

Enhancement request

Hi,

Can we have 2 specific tabs indication First and Last page?

Also, why the [...] is always deactivated?

Pagination

Hey @gadenbuie! Thanks a lot for this amazing package! It is quite handy!

Maybe I am working too late in the evening already, but I was trying to understand how the pagination functions work. Through the example provided, I do not seem to find a way to retrieve the current page. Like, I would like to render different things for page 1, page 2, and so on...

Any ideas?

Thanks in advance!
Felipe

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.