Skip to content

Commit

Permalink
feat: Move examples to inst/examples-shiny (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie authored Jun 9, 2024
1 parent 745c241 commit e6ae1d7
Show file tree
Hide file tree
Showing 30 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/shiny-workflows/__update_website_deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set_desc_with_packages <- function(field, known_pkgs) {


demo_pkgs <-renv::dependencies(
c("inst/themer-demo", list.dirs("inst/examples")),
c("inst/themer-demo", list.dirs("inst/examples-shiny")),
progress = FALSE
)$Package
# BH/cpp11 is not picked up for some reason
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
docs/
sandbox/
inst/themer-demo/deploy/rsconnect
inst/examples/*/rsconnect/
inst/examples-shiny/*/rsconnect/

node_modules/

Expand Down
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

## New features

* Page functions (e.g., `page_fixed()`, `page_fluid()`, etc) now include `shiny::useBusyIndicators()` automatically if available. If this behavior isn't desirable (perhaps because a package like `{shinycssloaders}` is being used to indicate busy state), then disable by putting `shiny::useBusyIndicators(spinners=FALSE, pulse=FALSE)` in the page. (#1053)
* Page functions (e.g., `page_fixed()`, `page_fluid()`, etc) now include `shiny::useBusyIndicators()` automatically if available. If this behavior isn't desirable (perhaps because a package like `{shinycssloaders}` is being used to indicate busy state), then disable by putting `shiny::useBusyIndicators(spinners=FALSE, pulse=FALSE)` in the page. (#1053)

## Improvements

* Adjusted the border color of checkbox and radio buttons to match the border color of the input group in `bs_theme(preset="shiny")`. (#1038)

* Example apps provided with bslib have now moved from `examples` to `examples-shiny` to take advantage of the new `package` argument in `shiny::runExample()` with shiny >= 1.8.1. For example, try `shiny::runExample("build-a-box", package = "bslib")`. (#1049)

## Bug fixes

* `toggle_sidebar()` once again correctly closes a sidebar. (@fredericva, #1043)
Expand Down Expand Up @@ -42,8 +44,8 @@ This large release includes many improvements and bug fixes for newer UI compone

* Full-screen cards are now supported on mobile devices: the _Expand card_ button is revealed when a user taps on the card (thanks @Damonsoul, #961).

* The _Expand card_ button is now accessible via keyboard navigation and appropriate ARIA attributes connect the card with the expand and close buttons.
* The _Expand card_ button is now accessible via keyboard navigation and appropriate ARIA attributes connect the card with the expand and close buttons.

* For JavaScript-oriented users, the expansion/collapse is now accompanied by a custom `bslib.card` event with the full screen state reported in the `event.detail.fullScreen` property. (#959)

* Improvements to the default theme (i.e., Shiny preset):
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
6 changes: 5 additions & 1 deletion R/value-box.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#' run the app locally with:
#'
#' ```r
#' shiny::runApp(system.file("examples", "build-a-box", package = "bslib"))
#' # shiny >= 1.8.1
#' shiny::runExample("build-a-box", package = "bslib")
#'
#' # shiny < 1.8.1
#' shiny::runApp(system.file("examples-shiny", "build-a-box", package = "bslib"))
#' ```
#'
#' @section Themes:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ withr::local_temp_libpaths()
install.packages("shiny")

rsconnect::deployApp(
rprojroot::find_package_root_file("inst/examples/build-a-box"),
rprojroot::find_package_root_file("inst/examples-shiny/build-a-box"),
appName = "build-a-box",
account = "bslib",
forceUpdate = TRUE
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rsconnect::deployApp(
rprojroot::find_package_root_file("inst/examples/card"),
rprojroot::find_package_root_file("inst/examples-shiny/card"),
appName = "card",
account = "bslib",
forceUpdate = TRUE
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ ui <- page_navbar(
tags$span(
bsicons::bs_icon("code-slash"), "Source code"
),
href = "https://github.com/rstudio/bslib/tree/main/inst/examples/flights",
href = "https://github.com/rstudio/bslib/tree/main/inst/examples-shiny/flights",
target = "_blank"
)
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rsconnect::deployApp(
rprojroot::find_package_root_file("inst/examples/flights"),
rprojroot::find_package_root_file("inst/examples-shiny/flights"),
appName = "flights",
account = "bslib",
forceUpdate = TRUE
Expand Down
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rsconnect::deployApp(
rprojroot::find_package_root_file("inst/examples/value_box"),
rprojroot::find_package_root_file("inst/examples-shiny/value_box"),
appName = "value_box",
account = "bslib",
forceUpdate = TRUE
Expand Down
6 changes: 5 additions & 1 deletion man/value_box.Rd

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

2 changes: 1 addition & 1 deletion vignettes/value-boxes/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Under-the-hood, `value_box()` is implemented using `card()`, mainly to inherit i

Note that, since this example is statically rendered (outside of Shiny), we make use of `htmlwidgets::onRender()` to add some JavaScript that effectively says: "Show the xaxis of the chart when it's taller than 200 pixels; otherwise, hide it".

Those of you who aren't wanting to write JavaScript can achieve similar behavior (i.e., displaying a different chart depending on it's size) via `shiny::getCurrentOutputInfo()`, as mentioned in the [article on cards](../cards#shiny). In fact, here's the [source code](https://github.com/rstudio/bslib/tree/main/inst/examples/value_box) for a Shiny app does effectively the same thing without any JavaScript (note how it also leverages other `getCurrentOutputInfo()` values to avoid hard coding `"white"` into the colors of the sparklines).
Those of you who aren't wanting to write JavaScript can achieve similar behavior (i.e., displaying a different chart depending on it's size) via `shiny::getCurrentOutputInfo()`, as mentioned in the [article on cards](../cards#shiny). In fact, here's the [source code](https://github.com/rstudio/bslib/tree/main/inst/examples-shiny/value_box) for a Shiny app does effectively the same thing without any JavaScript (note how it also leverages other `getCurrentOutputInfo()` values to avoid hard coding `"white"` into the colors of the sparklines).
:::

::: col-md-6
Expand Down

0 comments on commit e6ae1d7

Please sign in to comment.