Skip to content

Commit a566897

Browse files
committed
add fill argument to support bslib cards; fixes #76
1 parent fa10f57 commit a566897

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: shinycssloaders
22
Title: Add Loading Animations to a 'shiny' Output While It's Recalculating
3-
Version: 1.1.0.9004
3+
Version: 1.1.0.9005
44
Authors@R: c(
55
person("Dean","Attali",email="[email protected]",role=c("aut","cre"),
66
comment = c("Maintainer/developer of shinycssloaders since 2019", ORCID="0000-0002-5645-3493")),

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Unreleased version
22

3-
- **BREAKING CHANGE** Remove `custom.css` argument that has almost no usage. If you still want to achieve a similar behaviour, use `type=0`
3+
- **BREAKING CHANGE** Remove `custom.css` argument that has almost no usage. If you still want to achieve a similar behaviour, use `type=0`
44
- Add `delay` argument to show the spinner after a short delay (#95)
5+
- Add `fill` argument to support {bslib} cards and fillable containers (#76)
56
- Add `inline` argument to allow displaying spinner inline (#25)
67
- Add `width` argument that can be used in rare cases where the spinner has no inherent width (#85)
78

R/buildSpinner.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ buildSpinner <- function(
1414
caption,
1515
delay,
1616
inline,
17-
width
17+
width,
18+
fill
1819
) {
1920
spinner_type <- match.arg(spinner_type)
2021
output_spinner <- (spinner_type == "output")
@@ -57,6 +58,10 @@ buildSpinner <- function(
5758
if (inline) {
5859
parent_cls <- paste(parent_cls, "shiny-spinner-inline")
5960
}
61+
if (fill) {
62+
# in the future, when bslib becomes more mature, consider using bslib::as_fill_carrier() instead
63+
parent_cls <- paste(parent_cls, "html-fill-item html-fill-container")
64+
}
6065

6166
child_cls <- "load-container"
6267
if (output_spinner) {

R/pageSpinner.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ showPageSpinner <- function(
9797
hide.ui = FALSE,
9898
delay = 0,
9999
inline = FALSE,
100-
width = NULL
100+
width = NULL,
101+
fill = FALSE
101102
)
102103

103104
hidePageSpinner()

R/withSpinner.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#' is not appearing on the screen due to it having no inherent width (for example, when using
3737
#' `inline = TRUE` or when the output is inside a CSS flexbox without a specified width). Do not
3838
#' use this parameter if the spinner already works.
39+
#' @param fill If `TRUE`, the spinner will act as a "fillable carrier" in the `{bslib}` flexbox system. This is especially
40+
#' useful when placing a spinner inside a `{bslib}` [card][bslib::card()]. See the documentation on fillable containers
41+
#' and flexboxes in the `{bslib}` package
42+
#' for more information.
3943
#' @seealso [showSpinner()], [hideSpinner()], [showPageSpinner()]
4044
#' @examples
4145
#' if (interactive()) {
@@ -71,7 +75,8 @@ withSpinner <- function(
7175
caption = getOption("spinner.caption"),
7276
delay = getOption("spinner.delay", default = 0),
7377
inline = getOption("spinner.inline", default = FALSE),
74-
width = getOption("spinner.width")
78+
width = getOption("spinner.width"),
79+
fill = getOption("spinner.fill", default = FALSE)
7580
) {
7681

7782
if (!inherits(ui_element, "shiny.tag") && !inherits(ui_element, "shiny.tag.list")) {
@@ -94,7 +99,8 @@ withSpinner <- function(
9499
caption = caption,
95100
delay = delay,
96101
inline = inline,
97-
width = width
102+
width = width,
103+
fill = fill
98104
)
99105

100106
htmltools::attachDependencies(spinner, getDependencies())

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ By default, the out-dated output gets hidden while the spinner is showing. You c
166166

167167
A spinner will take up the full available width by default. If you'd like to place multiple spinners next to each other, or if the spinner wraps an inline output (for example, `textOutput(inline = TRUE)`) then you can use the `inline = TRUE` parameter. When using inline spinners, you will generally also want to use the `width` argument.
168168

169+
### Support for {bslib} fillable containers
170+
171+
When using a spinner inside {bslib} cards or other fillable containers, use the `fill = TRUE` parameter to ensure the output will behave correctly in the flexbox.
172+
169173
<h2 id="sponsors">
170174

171175
Sponsors 🏆

man/withSpinner.Rd

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)