Package 'sever'

Title: Customise 'Shiny' Disconnected Screens and Error Messages
Description: Customise 'Shiny' disconnected screens as well as sanitize error messages to make them clearer and friendlier to the user.
Authors: John Coene [aut, cre]
Maintainer: John Coene <[email protected]>
License: MIT + file LICENSE
Version: 0.0.8
Built: 2024-11-12 02:39:32 UTC
Source: https://github.com/johncoene/sever

Help Index


Chisel

Description

Customise silent error messages: messages raised by shiny::validate() and shiny::need(). If used in combination with cleave() make sure you are setting silent_errors to FALSE.

Usage

chisel(
  html = NULL,
  color = NULL,
  bg_color = NULL,
  duration = NULL,
  center_vertical = NULL,
  center_horizontal = NULL,
  ids = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

html

Html content to display instead of error messages, if NULL the original message is displyed.

color

Color of error message text.

bg_color

Background color of error message overlay. If NULL will be transparent.

duration

Duration of animation showing the error message, set to 0 to have none.

center_vertical

Whether to center the message vertically and horizontally, a boolean.

center_horizontal

Whether to center the message vertically and horizontally, a boolean.

ids

Ids of elements to apply the cleave to. If NULL applies to all error messages.

session

A valid shiny session.

Value

None


Chisel Theme

Description

Define a theme to apply to all subsequent chisel().

Usage

chisel_theme(
  color = "darkgrey",
  bg_color = NULL,
  duration = 0.1,
  center_vertical = TRUE,
  center_horizontal = TRUE
)

Arguments

color

Color of error message text.

bg_color

Background color of error message overlay. If NULL will be transparent.

duration

Duration of animation showing the error message, set to 0 to have none.

center_vertical

Whether to center the message vertically and horizontally, a boolean.

center_horizontal

Whether to center the message vertically and horizontally, a boolean.

Value

None


Cleave

Description

Customise hard error messages.

Usage

cleave(
  html = NULL,
  color = NULL,
  bg_color = NULL,
  duration = NULL,
  center_vertical = NULL,
  center_horizontal = NULL,
  ids = NULL,
  silent_errors = FALSE,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

html

Html content to display instead of error messages, if NULL the original message is displyed.

color

Color of error message text.

bg_color

Background color of error message overlay. If NULL will be transparent.

duration

Duration of animation showing the error message, set to 0 to have none.

center_vertical, center_horizontal

Whether to center the message vertically and horizontally, a boolean.

ids

Ids of elements to apply the cleave to. If NULL applies to all error messages.

silent_errors

Set to TRUE to also cleave silent errors: errors that are raised by shiny::validate(). Alternatively you might want to use chisel() to specifically stylise those messages.

session

A valid shiny session.

Value

None

See Also

chisel() for soft error messages.


Cleave Theme

Description

Define a theme to apply to all subsequent cleave().

Usage

cleave_theme(
  color = "red",
  bg_color = NULL,
  duration = 0.1,
  center_vertical = TRUE,
  center_horizontal = TRUE
)

Arguments

color

Color of error message text.

bg_color

Background color of error message overlay. If NULL will be transparent.

duration

Duration of animation showing the error message, set to 0 to have none.

center_vertical

Whether to center the message vertically and horizontally, a boolean.

center_horizontal

Whether to center the message vertically and horizontally, a boolean.

Value

None


Dependencies

Description

Import dependencies, place this in your shiny UI.

Usage

useSever()

use_sever()

Value

shiny::tags containing the necessary dependencies.


Reload

Description

Create a button to reload/reconnect to shiny.

Usage

reconnect_button(
  text = "reconnect",
  class = c("default", "danger", "info", "success", "warning")
)

reconnect_link(
  text = "reconnect",
  class = c("default", "danger", "info", "success", "warning")
)

f7_reconnect_button(text = "reconnect", color = "#000")

Arguments

text

The text to use on the button.

class

The class to apply to the button.

color

Color of button.

Value

A button or link in the form of shiny::tags.

Functions

  • reconnect_button - Returns a button.

  • reconnect_link - Returns a link.

  • f7_reconnect_button - A reconnect button for shinyMobile.


Reload

Description

Create a button to reload/reconnect to shiny.

Usage

reload_button(
  text = "reload",
  class = c("default", "danger", "info", "success", "warning"),
  .class = ""
)

reload_link(
  text = "reload",
  class = c("default", "danger", "info", "success", "warning"),
  .class = ""
)

f7_reload_button(text = "reload", color = "#000")

Arguments

text

The text to use on the button.

class

The class to apply to the button.

.class

Additional class to pass to the link or the button.

color

Color of button.

Value

A button or link in the form of shiny::tags.

Functions

  • reload_button - Returns a button.

  • reload_link - Returns a link.

  • f7_reload_button - A reload button for shinyMobile.


Rupture

Description

Displays a disconnected screen after ms milliseconds of inactivity.

Usage

rupture(
  html = rupture_default(),
  color = "#fff",
  opacity = 1,
  bg_color = "#333e48",
  bg_image = NULL,
  ms = 1000 * 60 * 15,
  session = shiny::getDefaultReactiveDomain(),
  box = FALSE
)

Arguments

html

Shiny tags to use as content for the disconnected screen, generally shiny::tagList().

opacity

Opacity of background.

bg_color, color

Background color, color of text.

bg_image

Background image to use.

ms

Milliseconds before showing the disconnected screen, defaults to 1000 * 60 * 15 which is 15 minutes (same as shinyapps.io).

session

A valid shiny session.

box

Set to TRUE to enclose the html in a box.

Value

None

Examples

library(shiny)

ui <- fluidPage(
 useSever(),
 h1("rupture")
)

server <- function(input, output){
 rupture(
   tagList(
     h1("Whoops"),
     reconnect_button()
   )
 )
}

if(interactive())
 shinyApp(ui, server)

Default Rupture Screen

Description

The default rupture screen for convenience.

Usage

rupture_default(
  title = "Idle",
  subtitle = "Your session is disconnected",
  button = "Reconnect",
  button_class = "default"
)

Arguments

title

Title and subtitle to display.

subtitle

Title and subtitle to display.

button

Text to display on button, passed to reload_button().

button_class

Class of button, passed to reload_button().

Value

shiny::tags.


Sever

Description

Customise the Shiny disconnected screen.

Usage

sever(
  html = sever_default(),
  color = "#fff",
  opacity = 1,
  bg_color = "#333e48",
  bg_image = NULL,
  session = shiny::getDefaultReactiveDomain(),
  box = FALSE
)

Arguments

html

Shiny tags to use as content for the disconnected screen, generally shiny::tagList().

opacity

Opacity of background.

bg_color, color

Background color, color of text.

bg_image

Background image to use.

session

A valid shiny session.

box

Set to TRUE to enclose the html in a box.

Value

None

Examples

library(shiny)

ui <- fluidPage(
 useSever(),
 h1("sever")
)

server <- function(input, output){
 sever(
   tagList(
     h1("Whoops"),
     reload_button()
   )
 )
}

if(interactive())
 shinyApp(ui, server)

Default Sever Screen

Description

The default sever screen for convenience.

Usage

sever_default(
  title = "Whoops!",
  subtitle = "You have been disconnected",
  button = "Reload",
  button_class = "default"
)

Arguments

title, subtitle

Title and subtitle to display.

button

Text to display on button, passed to reload_button().

button_class

Class of button, passed to reload_button().

Value

shiny::tags.


Uses Golem

Description

Checks if uses golem.

Usage

uses_golem()

runs_golem()