-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit da2b5ee
Showing
11 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Package: spoiler | ||
Type: Package | ||
Title: Blur 'HTML' Elements in 'Shiny' Applications Using | ||
'Spoiler-Alert.js' | ||
Version: 1.0.0 | ||
Authors@R: | ||
person(given = "Etienne", | ||
family = "Bacher", | ||
role = c("aut", "cre", "cph"), | ||
email = "etienne.bacher@protonmail.com") | ||
Description: It can be useful to temporarily hide some text or other HTML elements | ||
in 'Shiny' applications. Building on 'Spoiler-Alert.js', it is possible to select the | ||
elements to hide at startup, to partially reveal them by hovering them, and to | ||
completely show them when clicking on them. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Imports: htmltools, shiny | ||
URL: https://github.com/etiennebacher/spoiler | ||
BugReports: https://github.com/etiennebacher/spoiler/issues | ||
RoxygenNote: 7.1.1 | ||
Suggests: spelling | ||
Language: en-US | ||
NeedsCompilation: no | ||
Packaged: 2021-06-05 07:11:00 UTC; etienne | ||
Author: Etienne Bacher [aut, cre, cph] | ||
Maintainer: Etienne Bacher <etienne.bacher@protonmail.com> | ||
Repository: CRAN | ||
Date/Publication: 2021-06-07 07:40:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2020 | ||
COPYRIGHT HOLDER: Etienne Bacher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
88ef29ce9c504b12e3d3a9a20d6082bc *DESCRIPTION | ||
33a8990641ad52a1bebeabfbc4f73be4 *LICENSE | ||
591d91630a10928a033890eaf4b53574 *NAMESPACE | ||
6ee3f4d7a58b93fe2fdea586dd6af558 *R/spoiler.R | ||
861bd75b7ca7679bedac0ef65c31c29c *R/zzz.R | ||
8921872da4fa19e777d6d012ce5c9ca3 *README.md | ||
7ef03f7162fbf4881e6b849ebc220840 *inst/WORDLIST | ||
53edefeb9ab352a838d07f27dfcd6d8e *inst/spoileralert/spoiler.min.js | ||
5ab2ff89d2b548ee5ab60c77e6d63397 *man/spoiler.Rd | ||
0622a97a2aaa3c342f09636052c2d7f5 *tests/spelling.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(use_spoiler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#' Use Spoiler-alert | ||
#' | ||
#' Load Spoiler-alert dependencies, mark some elements as spoilers, and define | ||
#' the blurring intensity for these elements. | ||
#' | ||
#' @export | ||
#' @rdname spoiler | ||
#' | ||
#' @examples | ||
#' if (interactive()) { | ||
#' library(shiny) | ||
#' library(spoiler) | ||
#' | ||
#' # works better in browser | ||
#' | ||
#' ui <- fluidPage( | ||
#' # Load dependencies | ||
#' use_spoiler(), | ||
#' column( | ||
#' 3, | ||
#' p("this text can be seen"), | ||
#' spoiler(p("this one can't be seen")) # This text will be blurred | ||
#' ), | ||
#' hide_spoilers() | ||
#' ) | ||
#' | ||
#' server <- function(input, output, session) {} | ||
#' | ||
#' shinyApp(ui, server) | ||
#' } | ||
|
||
use_spoiler <- function() { | ||
|
||
shiny::singleton( | ||
shiny::tags$head( | ||
shiny::tags$script( | ||
src = "spoiler-assets/spoiler.min.js" | ||
) | ||
) | ||
) | ||
} | ||
|
||
#' @param ui_element Element to blur | ||
#' | ||
#' @rdname spoiler | ||
|
||
spoiler <- function(ui_element) { | ||
|
||
htmltools::tagAppendAttributes( | ||
ui_element, | ||
class = "spoiler" | ||
) | ||
|
||
} | ||
|
||
#' @param max Blurring intensity of the element by default | ||
#' | ||
#' @param partial Blurring intensity when hovering the element | ||
#' | ||
#' @rdname spoiler | ||
|
||
hide_spoilers <- function(max = 10, partial = 4) { | ||
htmltools::tags$script( | ||
paste0( | ||
"spoilerAlert('spoiler, .spoiler', {max: ", max, ", partial: ", partial, "});" | ||
) | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.onLoad <- function(libname, pkgname) { | ||
shiny::addResourcePath( | ||
"spoiler-assets", | ||
system.file("spoileralert", package = "spoiler") | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
# spoiler | ||
|
||
|
||
The goal of `{spoiler}` is to blur any HTML elements (text, plots, etc.) in R Shiny apps, so that spoilers are avoided. | ||
|
||
## Installation | ||
|
||
You can install the GitHub version of `{spoiler}` with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("etiennebacher/spoiler") | ||
``` | ||
|
||
## Demo | ||
|
||
``` r | ||
library(shiny) | ||
library(spoiler) | ||
|
||
# works better in browser | ||
|
||
ui <- fluidPage( | ||
use_spoiler(), | ||
column( | ||
4, | ||
spoiler(plotOutput("test")) | ||
), | ||
hide_spoilers(max = 10, partial = 4) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
|
||
output$test <- renderPlot(plot(mtcars$mpg)) | ||
|
||
} | ||
|
||
shinyApp(ui, server) | ||
``` | ||
|
||
![](demo.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if(requireNamespace('spelling', quietly = TRUE)) | ||
spelling::spell_check_test(vignettes = TRUE, error = FALSE, | ||
skip_on_cran = TRUE) |