Skip to content

Commit a5bfc06

Browse files
authored
feat(layout_column_wrap): Allow items to be smaller than min width (#851)
1 parent 6359904 commit a5bfc06

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
* `layout_sidebar()` now uses an `<aside>` element for the sidebar's container and a `<header>` element for the sidebar title. The classes of each element remain the same, but the semantic meaning of the elements is now better reflected in the HTML markup. (#580)
4444

45+
* In `layout_column_wrap()`, when `width` is a CSS unit -- e.g. `width = "400px"` or `width = "25%"` -- and `fixed_width = FALSE`, `layout_column_wrap()` will ensure that the columns are at least `width` wide, unless the parent container is narrower than `width`. (#851)
46+
4547
## Bug fixes
4648

4749
* `toggle_switch()` now works correctly when called from within a Shiny module. `update_switch()` worked as expected, but `toggle_switch()` didn't apply the module's namespace to the `id` of the switch to be updated. (#769)

R/layout.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020
#' * `NULL`
2121
#' * Allows power users to set the `grid-template-columns` CSS property
2222
#' manually, either via a `style` attribute or a CSS stylesheet.
23-
#' @param fixed_width Whether or not to interpret the `width` as a minimum
24-
#' (`fixed_width=FALSE`) or fixed (`fixed_width=TRUE`) width when it is a CSS
25-
#' length unit.
23+
#' @param fixed_width When `width` is greater than 1 or is a CSS length unit,
24+
#' e.g. `"200px"`, `fixed_width` indicates whether that `width` value
25+
#' represents the absolute size of each column (`fixed_width=TRUE`) or the
26+
#' minimum size of a column (`fixed_width=FALSE`). When `fixed_width=FALSE`,
27+
#' new columns are added to a row when `width` space is available and columns
28+
#' will never exceed the container or viewport size. When `fixed_width=TRUE`,
29+
#' all columns will be exactly `width` wide, which may result in columns
30+
#' overflowing the parent container.
2631
#' @param heights_equal If `"all"` (the default), every card in every row of the
2732
#' grid will have the same height. If `"row"`, then every card in _each_ row
2833
#' of the grid will have the same height, but heights may vary between rows.
@@ -77,7 +82,10 @@ layout_column_wrap <- function(
7782
if (fixed_width) {
7883
paste0("repeat(auto-fit, ", validateCssUnit(width), ")")
7984
} else {
80-
paste0("repeat(auto-fit, minmax(", validateCssUnit(width), ", 1fr))")
85+
sprintf(
86+
"repeat(auto-fit, minmax(min(%s, 100%%), 1fr))",
87+
validateCssUnit(width)
88+
)
8189
}
8290
}
8391
}

R/sysdata.rda

711 Bytes
Binary file not shown.

man/layout_column_wrap.Rd

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)