Skip to content

Commit

Permalink
options for strict tests; few enhancements (#225)
Browse files Browse the repository at this point in the history
- part of
insightsengineering/coredev-tasks#478
- please read this for more info about the implementation:
insightsengineering/coredev-tasks#478 (comment)
- fix detected errors
- rm one big nolint block
- rm `teal.widgets::` from vignette as this is redundant from within
that repo

Signed-off-by: Pawel Rucki <[email protected]>
  • Loading branch information
pawelru authored Mar 18, 2024
1 parent 0d7edaf commit f9bd194
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 60 deletions.
1 change: 1 addition & 0 deletions R/draggable_buckets.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#'
#' @examples
#' library(shiny)
#'
#' ui <- fluidPage(
#' draggable_buckets("id", "Choices #1", c("a", "b"), c("bucket1", "bucket2")),
#' draggable_buckets("id2", "Choices #2", letters, c("vowels", "consonants")),
Expand Down
10 changes: 5 additions & 5 deletions R/ggplot2_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @export
#' @examples
#' ggplot2_args(
#' lab = list(title = "TITLE"),
#' labs = list(title = "TITLE"),
#' theme = list(title = ggplot2::element_text(size = 20))
#' )
ggplot2_args <- function(labs = list(), theme = list()) {
Expand Down Expand Up @@ -75,11 +75,11 @@ ggplot2_args <- function(labs = list(), theme = list()) {
#' @examples
#' resolve_ggplot2_args(
#' user_plot = ggplot2_args(
#' lab = list(title = "TITLE"),
#' labs = list(title = "TITLE"),
#' theme = list(title = ggplot2::element_text(size = 20))
#' ),
#' user_default = ggplot2_args(
#' lab = list(x = "XLAB")
#' labs = list(x = "XLAB")
#' )
#' )
resolve_ggplot2_args <- function(user_plot = ggplot2_args(),
Expand Down Expand Up @@ -121,15 +121,15 @@ resolve_ggplot2_args <- function(user_plot = ggplot2_args(),
#' @examples
#' parse_ggplot2_args(
#' resolve_ggplot2_args(ggplot2_args(
#' lab = list(title = "TITLE"),
#' labs = list(title = "TITLE"),
#' theme = list(title = ggplot2::element_text(size = 20))
#' ))
#' )
#'
#' parse_ggplot2_args(
#' resolve_ggplot2_args(
#' ggplot2_args(
#' lab = list(title = "TITLE"),
#' labs = list(title = "TITLE"),
#' theme = list(title = ggplot2::element_text(size = 20))
#' )
#' ),
Expand Down
28 changes: 14 additions & 14 deletions R/nested_closeable_modal.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
#' @export
#'
#' @examples
#' # nolint start
#' library(shiny)
#' library(shinyjs)
#'
#' ui <- fluidPage(
#' useShinyjs(),
#' actionButton("show_1", "$('#modal_1').modal('show')"),
#' actionButton("show_1", "$(\"#modal_1\").modal(\"show\")"),
#' nested_closeable_modal(
#' "modal_1",
#' modal_args = list(
Expand All @@ -31,16 +30,16 @@
#' footer = NULL
#' ),
#' tags$div(
#' "This modal can be closed by running", tags$code("$('#modal_1').modal('hide')"),
#' "This modal can be closed by running", tags$code("$(\"#modal_1\").modal(\"hide\")"),
#' "in the JS console!",
#' tags$br(),
#' "Note that the second modal is placed right within this modal",
#' tags$br(),
#' "Alternatively, calling the", tags$code("removeModal()"),
#' "will remove all the active modal popups",
#' tags$br(), tags$br(),
#' actionButton("show_2", "$('#modal_2').modal('show')"),
#' actionButton("hide_1", "$('#modal_1').modal('hide')"),
#' actionButton("show_2", "$(\"#modal_2\").modal(\"show\")"),
#' actionButton("hide_1", "$(\"#modal_1\").modal(\"hide\")"),
#' nested_closeable_modal(
#' id = "modal_2",
#' modal_args = list(
Expand All @@ -50,35 +49,36 @@
#' easyClose = TRUE
#' ),
#' tags$div(
#' "This modal can be closed by running", tags$code("$('#modal_1').modal('hide')"),
#' "This modal can be closed by running", tags$code("$(\"#modal_1\").modal(\"hide\")"),
#' "in the JS console!",
#' "Note that removing the parent will remove the child.
#' But, reopening will remember the open state of child",
#' actionButton("hide_2", "$('#modal_2').modal('hide')"),
#' actionButton("hide_all", "$('#modal_1').modal('hide')")
#' actionButton("hide_2", "$(\"#modal_2\").modal(\"hide\")"),
#' actionButton("hide_all", "$(\"#modal_1\").modal(\"hide\")")
#' )
#' )
#' )
#' )
#' )
#'
#' server <- function(input, output) {
#' observeEvent(input$show_1, {
#' runjs("$('#modal_1').modal('show')")
#' runjs("$(\"#modal_1\").modal(\"show\")")
#' })
#' observeEvent(input$show_2, {
#' runjs("$('#modal_2').modal('show')")
#' runjs("$(\"#modal_2\").modal(\"show\")")
#' })
#' observeEvent(c(input$hide_1, input$hide_all), {
#' runjs("$('#modal_1').modal('hide')")
#' runjs("$(\"#modal_1\").modal(\"hide\")")
#' })
#' observeEvent(input$hide_2, {
#' runjs("$('#modal_2').modal('hide')")
#' runjs("$(\"#modal_2\").modal(\"hide\")")
#' })
#' }
#'
#' if (interactive()) {
#' shinyApp(ui, server)
#' }
#' # nolint end
nested_closeable_modal <- function(id, ..., modal_args = list(easyClose = TRUE)) {
checkmate::assert_string(id)
checkmate::assert_list(modal_args)
Expand All @@ -90,7 +90,7 @@ nested_closeable_modal <- function(id, ..., modal_args = list(easyClose = TRUE))
children("div")$
children("div")$
children("div")$
sibling(".modal-footer")$
siblings(".modal-footer")$
find("button")$
removeAttrs(c("data-dismiss", "data-bs-dismiss"))$
addAttrs(onclick = paste0("$('#", id, "').modal('hide');"))$
Expand Down
11 changes: 6 additions & 5 deletions R/plot_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ plot_with_settings_ui <- function(id) {
#'
#' server <- function(input, output, session) {
#' plot_r <- reactive({
#' ggplot(faithful, aes(x = waiting, y = eruptions)) +
#' ggplot(faithful, aes(x = .data$waiting, y = .data$eruptions)) +
#' geom_point()
#' })
#'
Expand All @@ -140,6 +140,7 @@ plot_with_settings_ui <- function(id) {
#'
#' # Example using a function as input to plot_r
#' library(lattice)
#'
#' ui <- fluidPage(
#' radioButtons("download_option", "Select the Option", list("ggplot", "trellis", "grob", "base")),
#' plot_with_settings_ui(
Expand All @@ -152,14 +153,14 @@ plot_with_settings_ui <- function(id) {
#' plot_r <- function() {
#' numbers <- seq_len(input$nums)
#' if (input$download_option == "ggplot") {
#' ggplot(data.frame(n = numbers), aes(n)) +
#' ggplot(data.frame(n = numbers), aes(.data$n)) +
#' geom_bar()
#' } else if (input$download_option == "trellis") {
#' densityplot(numbers)
#' } else if (input$download_option == "grob") {
#' tr_plot <- densityplot(numbers)
#' ggplotGrob(
#' ggplot(data.frame(n = numbers), aes(n)) +
#' ggplot(data.frame(n = numbers), aes(.data$n)) +
#' geom_bar()
#' )
#' } else if (input$download_option == "base") {
Expand Down Expand Up @@ -194,7 +195,7 @@ plot_with_settings_ui <- function(id) {
#'
#' server <- function(input, output, session) {
#' plot_r <- reactive({
#' ggplot(faithful, aes(x = waiting, y = eruptions)) +
#' ggplot(faithful, aes(x = .data$waiting, y = .data$eruptions)) +
#' geom_point()
#' })
#'
Expand Down Expand Up @@ -231,7 +232,7 @@ plot_with_settings_ui <- function(id) {
#'
#' server <- function(input, output, session) {
#' plot_r <- plot_r <- reactive(
#' ggplot(faithful, aes(x = waiting, y = eruptions)) +
#' ggplot(faithful, aes(x = .data$waiting, y = .data$eruptions)) +
#' geom_point()
#' )
#'
Expand Down
1 change: 1 addition & 0 deletions R/verbatim_popup.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#'
#' @examples
#' library(shiny)
#'
#' ui <- fluidPage(verbatim_popup_ui("my_id", button_label = "Open popup"))
#' srv <- function(input, output) {
#' verbatim_popup_srv(
Expand Down
1 change: 1 addition & 0 deletions man/draggable_buckets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ggplot2_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions man/nested_closeable_modal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/parse_ggplot2_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions man/plot_with_settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/resolve_ggplot2_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/verbatim_popup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f9bd194

Please sign in to comment.