Skip to content

Commit 2ec3067

Browse files
gadenbuiecpsievert
andauthored
feat(layout_columns): Use sm as the default col_widths breakpoint (#1014)
* feat(layout_columns): Make `sm` the default breakpoint * fix(layout_columns): `--sm` css variable is needed, actually * refactor(layout_columns): set base row heights css var if xs is only breakpoint * tests: Update snapshots * docs(news): Add news items * docs(news): Fix typo Co-authored-by: Carson Sievert <[email protected]>
1 parent c86d63e commit 2ec3067

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
* `page_sidebar()` now places the `title` element in a `.navbar` container that matches the structure of `page_navbar()`. This ensures that the title elements of `page_sidebar()` and `page_navbar()` have consistent appearance. (#998)
1010

11+
* The `col_widths` argument of `layout_columns()` now sets the `sm` breakpoint by default, rather than the `md` breakpoint. For example, `col_widths = c(12, 6, 6)` is now equivalent to `breakpoints(sm = c(12, 6, 6))` rather than `breakpoints(md = c(12, 6, 6))`. (#1014)
12+
1113
## New features
1214

1315
* Added `input_task_button()`, a replacement for `shiny::actionButton()` that automatically prevents an operation from being submitted multiple times. It does this by, upon click, immediately transitioning to a "Processing..." visual state that does not let the button be clicked again. The button resets to its clickable state automatically after the reactive flush it causes is complete; or, for advanced scenarios, `update_task_button()` can be used to manually control when the button resets.
@@ -50,6 +52,8 @@
5052

5153
* Fixed an issue that could happen with a `card()` or `value_box()` that is rendered entirely via `renderUI()` when it is replaced by an updated card but the user had expanded the original card into full screen mode. Now the full screen state is reset for the new card or value box. If you want to update a card without potentially exiting the full-screen mode, update specific parts of the card using `uiOutput()` or `textOutput()`. (#1005)
5254

55+
* Fixed an issue where the `xs` breakpoint in a `breakpoints()` object used for `row_heights` in `layout_columns()` would override all other breakpoints. (#1014)
56+
5357
# bslib 0.6.1
5458

5559
## Bug fixes

R/layout.R

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ as_col_spec <- function(col_widths, n_kids) {
311311
if (is.null(col_widths) || rlang::is_na(col_widths)) return(NULL)
312312

313313
if (!is_breakpoints(col_widths)) {
314-
col_widths <- breakpoints(md = col_widths)
314+
col_widths <- breakpoints(sm = col_widths)
315315
}
316316

317317
for (break_name in names(col_widths)) {
@@ -367,23 +367,19 @@ row_heights_css_vars <- function(x) {
367367
x <- breakpoints(xs = x)
368368
}
369369

370-
idx_sm <- match("xs", names(x))
371-
372370
# creates classes that pair with CSS variables when set
373371
classes <- paste0("bslib-grid--row-heights--", names(x))
374372

375373
css_vars <- setNames(x, paste0("--", classes))
376374

377-
if (!is.na(idx_sm)) {
378-
# xs doesn't need a specific breakpoint var, we just set the base CSS var
379-
names(css_vars)[idx_sm] <- "--bslib-grid--row-heights"
380-
# and as result we don't need a class to activate it.
381-
classes <- classes[-idx_sm]
382-
}
383-
384375
# Treat numeric values as fractional units
385376
css_vars <- rapply(css_vars, how = "replace", maybe_fr_unit)
386377

378+
if (identical(names(css_vars), "--bslib-grid--row-heights--xs")) {
379+
names(css_vars) <- "--bslib-grid--row-heights"
380+
classes <- character()
381+
}
382+
387383
list(
388384
style = css(!!!css_vars),
389385
class = classes

tests/testthat/_snaps/layout.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
layout_columns(col_widths = 6, !!!children)
55
Output
66
<div class="container-fluid">
7-
<bslib-layout-columns class="bslib-grid grid bslib-mb-spacing html-fill-item" col-widths-md="6" data-require-bs-caller="layout_columns()" data-require-bs-version="5">
7+
<bslib-layout-columns class="bslib-grid grid bslib-mb-spacing html-fill-item" col-widths-sm="6" data-require-bs-caller="layout_columns()" data-require-bs-version="5">
88
<div class="bslib-grid-item bslib-gap-spacing html-fill-container">
99
<div class="layout-column-child-element"></div>
1010
</div>
@@ -20,7 +20,7 @@
2020
layout_columns(col_widths = c(4, 8), !!!children)
2121
Output
2222
<div class="container-fluid">
23-
<bslib-layout-columns class="bslib-grid grid bslib-mb-spacing html-fill-item" col-widths-md="4,8" data-require-bs-caller="layout_columns()" data-require-bs-version="5">
23+
<bslib-layout-columns class="bslib-grid grid bslib-mb-spacing html-fill-item" col-widths-sm="4,8" data-require-bs-caller="layout_columns()" data-require-bs-version="5">
2424
<div class="bslib-grid-item bslib-gap-spacing html-fill-container">
2525
<div class="layout-column-child-element"></div>
2626
</div>

0 commit comments

Comments
 (0)