All Projects → JohnCoene → awn

JohnCoene / awn

Licence: other
Awesome notifications for shiny

Programming Languages

r
7636 projects
javascript
184084 projects - #8 most used programming language

awn

Awesome notifications for shiny.

Installation

Install from Github.

# install.packages("remotes")
remotes::install_github("JohnCoene/awn")

Demo

Run the gallery to view a demo app and the functionalities of the package.

awn::gallery()

Notify

Show a notification. Place useAwn in the UI.

library(awn)
library(shiny)

ui <- fluidPage(
	useAwn(),
	actionButton("show", "Show")
)

server <- function(input, output, session) {

	observeEvent(input$show, {
		type <- sample(
			c("tip", "info", "warning", "success", "alert"),
			1
		)

		notify(
			"Hello {awn}!",
			type = type
		)
	})

}

shinyApp(ui, server)

Modal

Display a modal. Place useAwn in the UI.

library(awn)
library(shiny)

ui <- fluidPage(
	useAwn(),
	actionButton("show", "Show")
)

server <- function(input, output, session) {

	observeEvent(input$show, {
		modal(
			h1("Hello {awn}!")
		)
	})

}

shinyApp(ui, server)

Ask

Prompt the user. Place useAwn in the UI.

library(awn)
library(shiny)

ui <- fluidPage(
	useAwn(),
	actionButton("show", "Show")
)

server <- function(input, output, session) {

	observeEvent(input$show, {
		ask(
			"confirmed", # id of input
			p("Are you sure?")
		)
	})

	observeEvent(input$confirmed, {
		print(input$confirmed)
	})

}

shinyApp(ui, server)

Options

There are numerous options that are not hard-coded but nonetheless accessible.

You can also define global options to avoid having to repeat options at every notification, modal, etc.

library(awn)
library(shiny)

ui <- fluidPage(
	useAwn(),
	actionButton("show", "Show")
)

server <- function(input, output, session) {

	awn_globals(durations = list(tip = 10000))

	observeEvent(input$show, {
		notify(
			"Hello {awn}!",
			type = "tip",
			labels = list(
				tip = "ADVICE"
			)
		)
	})

}

shinyApp(ui, server)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].