Title: | Customizable Timer for 'shiny' Applications |
---|---|
Description: | Provides a customizable timer widget for 'shiny' applications. Key features include countdown and count-up mode, multiple display formats (including simple seconds, minutes-seconds, hours-minutes-seconds, and minutes-seconds-centiseconds), ability to pause, resume, and reset the timer. 'shinytimer' widget can be particularly useful for creating interactive and time-sensitive applications, tracking session times, setting time limits for tasks or quizzes, and more. |
Authors: | Maciej Banas [aut, cre] |
Maintainer: | Maciej Banas <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-03-08 06:44:43 UTC |
Source: | https://github.com/maciekbanas/shinytimer |
Set shinyTimer in motion: count down
countDown(inputId, session = shiny::getDefaultReactiveDomain())
countDown(inputId, session = shiny::getDefaultReactiveDomain())
inputId |
The input ID corresponding to the UI element. |
session |
The session object from the shiny server function. |
No return value, called for side effects.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("start", "Start Countdown") ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("start", "Start Countdown") ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer") }) } ) }
Set shinyTimer in motion: count up
countUp(inputId, session = shiny::getDefaultReactiveDomain())
countUp(inputId, session = shiny::getDefaultReactiveDomain())
inputId |
The input ID corresponding to the UI element. |
session |
The session object from the shiny server function. |
No return value, called for side effects.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Count Up Timer", seconds = 0, type = "mm:ss.cs"), actionButton("start", "Start Counting Up") ), server = function(input, output, session) { observeEvent(input$start, { countUp("timer") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Count Up Timer", seconds = 0, type = "mm:ss.cs"), actionButton("start", "Start Counting Up") ), server = function(input, output, session) { observeEvent(input$start, { countUp("timer") }) } ) }
Pause shinyTimer
pauseTimer(inputId, session = shiny::getDefaultReactiveDomain())
pauseTimer(inputId, session = shiny::getDefaultReactiveDomain())
inputId |
The input ID corresponding to the UI element. |
session |
The session object from the shiny server function. |
No return value, called for side effects.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("start", "Start Countdown"), actionButton("pause", "Pause Countdown") ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer") }) observeEvent(input$pause, { pauseTimer("timer") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("start", "Start Countdown"), actionButton("pause", "Pause Countdown") ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer") }) observeEvent(input$pause, { pauseTimer("timer") }) } ) }
Reset shinyTimer
resetTimer( inputId, hours = 0, minutes = 0, seconds = 0, session = shiny::getDefaultReactiveDomain() )
resetTimer( inputId, hours = 0, minutes = 0, seconds = 0, session = shiny::getDefaultReactiveDomain() )
inputId |
The input ID corresponding to the UI element. |
hours |
The new reset time in hours. |
minutes |
The new reset time in minutes. |
seconds |
The new reset time in seconds. |
session |
The session object from the shiny server function. |
No return value, called for side effects.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("reset", "Reset Timer") ), server = function(input, output, session) { observeEvent(input$reset, { resetTimer("timer", seconds = 20) }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 20, type = "mm:ss"), actionButton("reset", "Reset Timer") ), server = function(input, output, session) { observeEvent(input$reset, { resetTimer("timer", seconds = 20) }) } ) }
shinyTimer widget
shinyTimer( inputId, label = NULL, hours = 0, minutes = 0, seconds = 0, type = "simple", background = "none", ... )
shinyTimer( inputId, label = NULL, hours = 0, minutes = 0, seconds = 0, type = "simple", background = "none", ... )
inputId |
The input id. |
label |
The label to display above the countdown. |
hours |
An integer, the starting time in hours for the countdown. |
minutes |
An integer, the starting time in minutes for the countdown. |
seconds |
An integer, the starting time in seconds for the countdown. |
type |
The type of the countdown timer display ("simple", "mm:ss", "hh:mm:ss", "mm:ss.cs"). |
background |
The shape of the timer's container ("none", "circle", "rectangle"). |
... |
Any additional parameters you want to pass to the placeholder for the timer ( |
A shiny UI component for the countdown timer.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 10) ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer", session) }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 10) ), server = function(input, output, session) { observeEvent(input$start, { countDown("timer", session) }) } ) }
Update shinyTimer widget
updateShinyTimer( inputId, hours = NULL, minutes = NULL, seconds = NULL, type = NULL, label = NULL, background = NULL, session = shiny::getDefaultReactiveDomain() )
updateShinyTimer( inputId, hours = NULL, minutes = NULL, seconds = NULL, type = NULL, label = NULL, background = NULL, session = shiny::getDefaultReactiveDomain() )
inputId |
The input ID corresponding to the UI element. |
hours |
The new starting time in hours for the countdown. |
minutes |
The new starting time in minutes for the countdown. |
seconds |
The new starting time in seconds for the countdown. |
type |
The new type of the countdown timer display ("simple", "mm:ss", "hh:mm:ss", "mm:ss.cs"). |
label |
The new label to be displayed above the countdown timer. |
background |
The new shape of the timer's container ("none", "circle", "rectangle"). |
session |
The session object from the shiny server function. |
No return value, called for side effects.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 10, type = "mm:ss"), actionButton("update", "Update Timer") ), server = function(input, output, session) { observeEvent(input$update, { updateShinyTimer("timer", seconds = 20, type = "hh:mm:ss") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( shinyTimer("timer", label = "Countdown Timer", seconds = 10, type = "mm:ss"), actionButton("update", "Update Timer") ), server = function(input, output, session) { observeEvent(input$update, { updateShinyTimer("timer", seconds = 20, type = "hh:mm:ss") }) } ) }