Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

* We increased the spacing between elements just slightly in the Shiny preset. This change is most noticeable in the `layout_columns()` or `layout_column_wrap()` component. In these and other components, you can use `gap` and `padding` arguments to choose your own values, or you can set the `$bslib-spacer` (Sass) or `--bslib-spacer` (CSS) variable. (#998)

* `value_box()`, `layout_columns()` and `layout_column_wrap()` now all have `min_height` and `max_height` arguments. These are useful in filling layouts, like `page_fillable()`, `page_sidebar(fillable = TRUE)` or `page_navbar(fillable = TRUE)`. For example, you can use `layout_columns(min_height = 300, max_height = 500)` to ensure that a set of items (likely arranged in a row of columns) are always between 300 and 500 pixels tall. (#1016)

## Bug fixes

* `layout_columns()` now always uses a 12-unit grid when the user provides an integer value to `col_widths` for any breakpoint. For example, `breakpoints(md = 3, lg = NA)` will pick a best-fitting layout for large screen sizes using the 12-column grid. Previously, the best fit algorithm might adjust the number of columns as a shortcut to an easy solution. That shortcut is only taken when an auto-fit layout is requested for every breakpoint, e.g. `col_widths = breakpoints(md = NA, lg = NA)` or `col_widths = NA`. (#928)
Expand Down
16 changes: 14 additions & 2 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#' @param fillable Whether or not each element is wrapped in a fillable container.
#' @param height_mobile Any valid CSS unit to use for the height when on mobile
#' devices (or narrow windows).
#' @param min_height,max_height The maximum or minimum height of the layout container.
#' Can be any valid [CSS unit][htmltools::validateCssUnit] (e.g.,
#' `max_height="200px"`). Use these arguments in filling layouts to ensure that a
#' layout container doesn't shrink below `min_height` or grow beyond `max_height`.
#' @inheritParams card
#' @inheritParams card_body
#'
Expand Down Expand Up @@ -74,6 +78,8 @@ layout_column_wrap <- function(
fillable = TRUE,
height = NULL,
height_mobile = NULL,
min_height = NULL,
max_height = NULL,
gap = NULL,
class = NULL
) {
Expand Down Expand Up @@ -137,7 +143,9 @@ layout_column_wrap <- function(
# doesn't get inherited in a scenario like layout_column_wrap(height=200, ..., layout_column_wrap(...))
"--bslib-grid-height" = validateCssUnit(height %||% "auto"),
"--bslib-grid-height-mobile" = validateCssUnit(height_mobile %||% "auto"),
gap = validateCssUnit(gap)
gap = validateCssUnit(gap),
min_height = validateCssUnit(min_height),
max_height = validateCssUnit(max_height)
),
!!!attribs,
children,
Expand Down Expand Up @@ -252,7 +260,9 @@ layout_columns <- function(
fillable = TRUE,
gap = NULL,
class = NULL,
height = NULL
height = NULL,
min_height = NULL,
max_height = NULL
) {
args <- separate_arguments(...)
attribs <- args$attribs
Expand All @@ -274,6 +284,8 @@ layout_columns <- function(
style = css(
height = validateCssUnit(height),
gap = validateCssUnit(gap),
min_height = validateCssUnit(min_height),
max_height = validateCssUnit(max_height)
),
# We don't enable the next option by default, but users could add this
# attribute to hide the internal elements until after the custom element
Expand Down
10 changes: 7 additions & 3 deletions R/value-box.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
#' `"text-light"`) to customize the background/foreground colors.
#' @param fill Whether to allow the value box to grow/shrink to fit a fillable
#' container with an opinionated height (e.g., `page_fillable()`).
#' @param max_height The maximum height of the value box or the showcase area.
#' Can be any valid [CSS unit][htmltools::validateCssUnit] (e.g.,
#' `max_height="200px"`).
#' @param max_height The maximum height of the `value_box()` or the showcase
#' area when used in a `showcase_layout_*()` function. Can be any valid [CSS
#' unit][htmltools::validateCssUnit] (e.g., `max_height="200px"`).
#' @param min_height The minimum height of the values box. Can be any valid [CSS
#' unit][htmltools::validateCssUnit] (e.g., `min_height="200px"`).
#' @inheritParams card
#' @param theme_color `r lifecycle::badge("deprecated")` Use `theme` instead.
#'
Expand Down Expand Up @@ -97,6 +99,7 @@ value_box <- function(
theme = NULL,
height = NULL,
max_height = NULL,
min_height = NULL,
fill = TRUE,
class = NULL,
id = NULL,
Expand Down Expand Up @@ -163,6 +166,7 @@ value_box <- function(
full_screen = full_screen,
height = height,
max_height = max_height,
min_height = min_height,
fill = fill,
style = css(
color = theme$fg,
Expand Down
7 changes: 7 additions & 0 deletions man/layout_column_wrap.Rd

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

9 changes: 8 additions & 1 deletion man/layout_columns.Rd

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

8 changes: 5 additions & 3 deletions man/value_box.Rd

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