diff --git a/DESCRIPTION b/DESCRIPTION index 031d9ea0..af583bb5 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,59 +1,61 @@ -Package: shiny.semantic Type: Package +Package: shiny.semantic Title: Semantic UI Support for Shiny -Version: 0.4.3.9002 +Version: 0.5.0 Authors@R: c(person("Filip", "Stachura", email = "filip@appsilon.com", role = "aut"), - person("Dominik", "Krzeminski", email = "dominik@appsilon.com", role = "aut"), - person("Krystian", "Igras", email = "krystian@appsilon.com", role = "aut"), - person("Adam", "Forys", email = "adam@appsilon.com", role = "aut"), + person("Dominik", "Krzeminski", role = "aut"), + person("Krystian", "Igras", role = "aut"), + person("Adam", "Forys", role = "aut"), person("Paweł", "Przytuła", email = "pawel@appsilon.com", role = "aut"), person("Jakub", "Chojna", email = "jakub.chojna@appsilon.com", role = "aut"), person("Olga", "Mierzwa-Sulima", email = "olga@appsilon.com", role = "aut"), + person("Jakub", "Nowicki", email = "opensource+kuba@appsilon.com", role = c("aut", "cre")), person("Ashley", "Baldry", role = "ctb"), - person("Jakub", "Chojna", email = "jakub.chojna@appsilon.com", role = "ctb"), - person("Olga", "Mierzwa-Sulima", email = "olga@appsilon.com", role = "ctb"), person("Pedro", "Manuel Coutinho da Silva", email = "pedro@appsilon.com", role = "ctb"), - person("Paweł", "Przytuła", email = "pawel@appsilon.com", role = "ctb"), person("Kamil", "Żyła", email = "kamil@appsilon.com", role = "ctb"), - person("Rabii", "Bouhestine", email = "rabii@appsilon.com", role = "ctb"), - person("Developers", "Appsilon", email = "support+opensource@appsilon.com", role = "cre"), + person("Rabii", "Bouhestine", role = "ctb"), + person("Federico", "Rivandeira", email = "federico@appsilon.com", role = "ctb"), person(family = "Appsilon Sp. z o.o.", role = c("cph"))) -Description: Creating a great user interface for your Shiny apps - can be a hassle, especially if you want to work purely in R - and don't want to use, for instance HTML templates. This - package adds support for a powerful UI library Fomantic UI - - (before Semantic). It also supports - universal UI input binding that works with various DOM elements. -BugReports: https://github.com/Appsilon/shiny.semantic/issues -Encoding: UTF-8 -LazyData: TRUE +Description: Creating a great user interface for your Shiny apps can be a + hassle, especially if you want to work purely in R and don't want to + use, for instance HTML templates. This package adds support for a + powerful UI library Fomantic UI - (before + Semantic). It also supports universal UI input binding that works with + various DOM elements. License: MIT + file LICENSE -VignetteBuilder: knitr +URL: https://appsilon.github.io/shiny.semantic/, https://github.com/Appsilon/shiny.semantic +BugReports: https://github.com/Appsilon/shiny.semantic/issues Imports: - shiny (>= 0.12.1), + glue, + grDevices, htmltools (>= 0.2.6), htmlwidgets (>= 0.8), - purrr (>= 0.2.2), - stats, - magrittr, jsonlite, - grDevices, - glue, + magrittr, + purrr (>= 0.2.2), R6, - semantic.assets (>= 1.1.0) + semantic.assets (>= 1.1.0), + shiny (>= 0.12.1), + stats Suggests: + covr, dplyr, - tibble, - knitr, - testthat, - lintr, DT, - covr, + gapminder, + knitr, leaflet, - plotly, - rmarkdown, + lintr, markdown, - rcmdcheck, mockery, + plotly, + rcmdcheck, + rmarkdown, + testthat, + tibble, withr +VignetteBuilder: + knitr +Encoding: UTF-8 +Language: en-US +LazyData: TRUE RoxygenNote: 7.2.3 diff --git a/NEWS.md b/NEWS.md index 99ff8185..3af9a004 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,10 @@ - `uirender` uses assets from `semantic.assets`. +- Replaced class to string comparisons. + +- Replaced deprecated `purrr::when` call. + # [shiny.semantic 0.4.3](https://github.com/Appsilon/shiny.semantic/releases/tag/0.4.3) - Removed inline-styled min-height from ``. diff --git a/R/checkbox.R b/R/checkbox.R index 7c0017a0..bb240775 100644 --- a/R/checkbox.R +++ b/R/checkbox.R @@ -36,9 +36,9 @@ #' #' The following \code{type}s are allowed: #' \itemize{ -#' \item{NULL}{ The standard checkbox (default)} -#' \item{toggle}{ Each checkbox has a toggle form} -#' \item{slider}{ Each checkbox has a simple slider form} +#' \item{NULL} The standard checkbox (default) +#' \item{toggle} Each checkbox has a toggle form +#' \item{slider} Each checkbox has a simple slider form #' } #' #' @rdname checkbox @@ -85,9 +85,9 @@ toggle <- function(input_id, label = "", is_marked = TRUE, style = NULL) { #' @details #' The following \code{type}s are allowed: #' \itemize{ -#' \item{NULL}{The standard checkbox (default)} -#' \item{toggle}{Each checkbox has a toggle form} -#' \item{slider}{Each checkbox has a simple slider form} +#' \item{NULL} The standard checkbox (default) +#' \item{toggle} Each checkbox has a toggle form +#' \item{slider} Each checkbox has a simple slider form #' } #' #' @rdname multiple_checkbox diff --git a/R/dropdown.R b/R/dropdown.R index 3da8a09f..fc5dd224 100644 --- a/R/dropdown.R +++ b/R/dropdown.R @@ -41,27 +41,25 @@ dropdown_input <- function(input_id, choices, choices_value = choices, icon("dropdown"), shiny::div(class = "default text", default_text), menu( - purrr::when( - choices, - is.null(names(.)) ~ - purrr::map2( - choices, choices_value, - ~ shiny::div(class = "item", `data-value` = .y, .x) - ), - !is.null(names(.)) ~ - purrr::map( - seq_len(length(choices)), ~ { - shiny::tagList( - menu_header(names(choices)[.x], is_item = FALSE), - menu_divider(), - purrr::map2( - choices[[.x]], choices_value[[.x]], - ~ shiny::div(class = "item", `data-value` = .y, .x) - ) + if (is.null(names(choices))) { + purrr::map2( + choices, choices_value, + ~ shiny::div(class = "item", `data-value` = .y, .x) + ) + } else { + purrr::map( + seq_len(length(choices)), ~ { + shiny::tagList( + menu_header(names(choices)[.x], is_item = FALSE), + menu_divider(), + purrr::map2( + choices[[.x]], choices_value[[.x]], + ~ shiny::div(class = "item", `data-value` = .y, .x) ) - } - ) - ) + ) + } + ) + } ) ) } diff --git a/R/dsl.R b/R/dsl.R index 32f50eb3..5c7d5769 100644 --- a/R/dsl.R +++ b/R/dsl.R @@ -860,7 +860,7 @@ accordion <- function(accordion_list, fluid = TRUE, active_title = "", div(class = paste("title", active), icon("dropdown"), x$title), div(class = paste("content", active), p(class = "transition hidden", - if (class(x$content) == "shiny.tag") x$content else div(x$content) + if (inherits(x$content, "shiny.tag")) x$content else div(x$content) ) ) ) diff --git a/R/input.R b/R/input.R index 78be2d3d..21923b61 100644 --- a/R/input.R +++ b/R/input.R @@ -46,12 +46,12 @@ uiinput <- function(..., class = "") { #' @details #' The following \code{type} s are allowed: #' \itemize{ -#' \item{text} {The standard input} -#' \item{textarea} {An extended space for text} -#' \item{password} {A censored version of the text input} -#' \item{email} {A special version of the text input specific for email addresses} -#' \item{url} {A special version of the text input specific for URLs} -#' \item{tel} {A special version of the text input specific for telephone numbers} +#' \item{text} The standard input +#' \item{textarea} An extended space for text +#' \item{password} A censored version of the text input +#' \item{email} A special version of the text input specific for email addresses +#' \item{url} A special version of the text input specific for URLs +#' \item{tel} A special version of the text input specific for telephone numbers #' } #' #' The inputs are updateable by using \code{\link[shiny]{updateTextInput}} or @@ -189,7 +189,6 @@ numeric_input <- function(input_id, label, value = NULL, min = NA, max = NA, ste if (!is.null(value)) { if (!is.numeric(value) & !grepl("^\\d*(\\.\\d*|)$", value)) stop("Non-numeric input detected") } - input_tag <- tags$input(id = input_id, value = value, type = "number", placeholder = placeholder) if (!is.na(min)) input_tag$attribs$min <- min diff --git a/R/layouts.R b/R/layouts.R index c6a154bd..e945ab54 100644 --- a/R/layouts.R +++ b/R/layouts.R @@ -217,7 +217,7 @@ sidebarLayout <- function(sidebarPanel, #' shinyApp(ui, server) #' } split_layout <- function(..., cell_widths = NULL, cell_args = "", style = NULL){ - if (class(cell_args) == "list") + if (inherits(cell_args, "list")) stop("In this implementation of `split_layout` cell_args must be character with style css") ui_elements <- list(...) n_elems <- length(ui_elements) diff --git a/R/menu.R b/R/menu.R index a32f4b9d..9a93f65d 100644 --- a/R/menu.R +++ b/R/menu.R @@ -80,7 +80,7 @@ horizontal_menu <- function(menu_items, active_location = "", logo = NULL) { logo_ui <- "" else { number_items <- length(menu_items) + 1 - if (class(logo) == "shiny.tag") + if (inherits(logo, "shiny.tag")) logo_ui <- shiny::div(class = "item", logo) else diff --git a/R/rating.R b/R/rating.R index 8dfde877..75d2027f 100644 --- a/R/rating.R +++ b/R/rating.R @@ -36,7 +36,7 @@ rating_input <- function(input_id, label = "", value = 0, max = 3, icon = "star" warning("Size value not supported.") size <- "" } - if (class(icon) == "shiny.tag") { + if (inherits(icon, "shiny.tag")) { icon <- extract_icon_name(icon) } class <- glue::glue("ui {size} {color} rating") diff --git a/R/semantic_search.R b/R/semantic_search.R index 83b6bf9c..fa9983b1 100644 --- a/R/semantic_search.R +++ b/R/semantic_search.R @@ -24,7 +24,7 @@ define_selection_type <- function(input_id, multiple) { #' FALSE otherwise (default FALSE). #' @param default_text Text to be visible on dropdown when nothing is selected. #' -#'#'@examples +#' @examples #' ## Only run examples in interactive R sessions #' if (interactive()) { #' library(shiny) diff --git a/R/utils.R b/R/utils.R index e5338e1b..a742e0ea 100644 --- a/R/utils.R +++ b/R/utils.R @@ -74,9 +74,9 @@ generate_random_id <- function(prefix, id_length = 20) { #' @param args list or vector with extra arguments #' @keywords internal warn_unsupported_args <- function(args) { - if (class(args) == "list") + if (inherits(args, "list")) to_wrn <- paste0(as.character(names(args)), collapse = ',') - else if (class(args) == "character") + else if (inherits(args, "character")) to_wrn <- paste0(args, collapse = ',') else if (is.null(args)) return() diff --git a/man/checkbox.Rd b/man/checkbox.Rd index 7baa0f6c..605667c5 100644 --- a/man/checkbox.Rd +++ b/man/checkbox.Rd @@ -51,9 +51,9 @@ The inputs are updateable by using \code{\link[shiny]{updateCheckboxInput}}. The following \code{type}s are allowed: \itemize{ -\item{NULL}{ The standard checkbox (default)} -\item{toggle}{ Each checkbox has a toggle form} -\item{slider}{ Each checkbox has a simple slider form} +\item{NULL} The standard checkbox (default) +\item{toggle} Each checkbox has a toggle form +\item{slider} Each checkbox has a simple slider form } } \examples{ diff --git a/man/multiple_checkbox.Rd b/man/multiple_checkbox.Rd index 7b14fe36..5b076ad7 100644 --- a/man/multiple_checkbox.Rd +++ b/man/multiple_checkbox.Rd @@ -53,9 +53,9 @@ This creates a multiple checkbox using Semantic UI styles. \details{ The following \code{type}s are allowed: \itemize{ -\item{NULL}{The standard checkbox (default)} -\item{toggle}{Each checkbox has a toggle form} -\item{slider}{Each checkbox has a simple slider form} +\item{NULL} The standard checkbox (default) +\item{toggle} Each checkbox has a toggle form +\item{slider} Each checkbox has a simple slider form } } \examples{ diff --git a/man/search_selection_api.Rd b/man/search_selection_api.Rd index 8ef16d16..8996f95a 100644 --- a/man/search_selection_api.Rd +++ b/man/search_selection_api.Rd @@ -20,9 +20,15 @@ fields `name` and `value`.} \item{multiple}{TRUE if the dropdown should allow multiple selections, FALSE otherwise (default FALSE).} -\item{default_text}{Text to be visible on dropdown when nothing is selected. - -#'@examples +\item{default_text}{Text to be visible on dropdown when nothing is selected.} +} +\description{ +Define the (multiple) search selection dropdown input for retrieving remote +selection menu content from an API endpoint. API response is expected to be +a JSON with property fields `name` and `value`. Using a search selection +dropdown allows to search more easily through large lists. +} +\examples{ ## Only run examples in interactive R sessions if (interactive()) { library(shiny) @@ -47,12 +53,12 @@ if (interactive()) { has_matching <- function(field) { startsWith(field, q) } - gapminder %>% - mutate(country = as.character(country)) %>% - select(country) %>% - unique %>% - filter(has_matching(country)) %>% - head(5) %>% + gapminder \%>\% + mutate(country = as.character(country)) \%>\% + select(country) \%>\% + unique \%>\% + filter(has_matching(country)) \%>\% + head(5) \%>\% transmute(name = country, value = country) } @@ -67,11 +73,6 @@ if (interactive()) { }) shinyApp(ui = ui(), server = server) -}} } -\description{ -Define the (multiple) search selection dropdown input for retrieving remote -selection menu content from an API endpoint. API response is expected to be -a JSON with property fields `name` and `value`. Using a search selection -dropdown allows to search more easily through large lists. + } diff --git a/man/text_input.Rd b/man/text_input.Rd index e6d30b7c..7bfe403e 100644 --- a/man/text_input.Rd +++ b/man/text_input.Rd @@ -47,12 +47,12 @@ under \code{input[[input_id]]}. \details{ The following \code{type} s are allowed: \itemize{ -\item{text} {The standard input} -\item{textarea} {An extended space for text} -\item{password} {A censored version of the text input} -\item{email} {A special version of the text input specific for email addresses} -\item{url} {A special version of the text input specific for URLs} -\item{tel} {A special version of the text input specific for telephone numbers} +\item{text} The standard input +\item{textarea} An extended space for text +\item{password} A censored version of the text input +\item{email} A special version of the text input specific for email addresses +\item{url} A special version of the text input specific for URLs +\item{tel} A special version of the text input specific for telephone numbers } The inputs are updateable by using \code{\link[shiny]{updateTextInput}} or diff --git a/vignettes/basics.Rmd b/vignettes/basics.Rmd index 4d2dcd14..76f59579 100644 --- a/vignettes/basics.Rmd +++ b/vignettes/basics.Rmd @@ -20,7 +20,7 @@ library(shiny.semantic) ``` -In this tutorial we will walk you through the basics of `shiny.semantic`. +In this tutorial we will walk you through the basics of `shiny.semantic`. ## Quick Q&A @@ -98,7 +98,7 @@ width = "400px", height = "150px") ### (b) Using predefined objects -If you are not that comfortable with web development, you can take advantage of the +If you are not that comfortable with web development, you can take advantage of the number of elements that we implemented for you. See some examples below: ```{r echo = T, include = T, eval = FALSE, screenshot.force = FALSE} @@ -107,7 +107,7 @@ text_input("txt", type = "text", placeholder = "Enter Text") date_input("date") ``` -For more components visit our [Components live demo website](https://demo.appsilon.com/apps/semantic) +For more components visit our [Components live demo website](https://connect.appsilon.com/shiny-semantic-components/) or the `examples/` folder on our [repository](https://github.com/Appsilon/shiny.semantic/). Little sneak-peak of what you can get is listed on the graphics below. Most of the components