Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(page_main_container): Remove fill container and min-height/width when fillable=FALSE #1188

Merged
merged 12 commits into from
Mar 5, 2025
Merged
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* `bs_theme_dependencies()` now avoids unecessarily copying internal package files to R's temporary directory more than once when preparing precompiled theme dependencies (e.g. for a standard `bs_theme()` theme). (#1184)

* Fixed an issue where the `<main>` areas of `page_sidebar()` and `page_navbar()` (with a `sidebar`) were made to be a fillable containers even when `fillable = FALSE`. (#1188)

# bslib 0.9.0

## Breaking changes
Expand Down
10 changes: 5 additions & 5 deletions R/bs-theme-preset-brand.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ brand_resolve.brand_yml <- function(brand, ...) {
brand_resolve_preset <- function(brand, preset = NULL, version = NULL) {
version_resolved <-
version %||%
brand_pluck(brand, "defaults", "shiny", "theme", "version") %||%
brand_pluck(brand, "defaults", "bootstrap", "version") %||%
version_default()
brand_pluck(brand, "defaults", "shiny", "theme", "version") %||%
brand_pluck(brand, "defaults", "bootstrap", "version") %||%
version_default()

preset_resolved <-
preset %||%
brand_pluck(brand, "defaults", "shiny", "theme", "preset") %||%
switch_version(version_resolved, five = "shiny", default = "bootstrap")
brand_pluck(brand, "defaults", "shiny", "theme", "preset") %||%
switch_version(version_resolved, five = "shiny", default = "bootstrap")

resolve_bs_preset(preset_resolved, version = version_resolved)
}
Expand Down
2 changes: 1 addition & 1 deletion R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ layout_column_wrap <- function(
if (missing(width)) {
first_is_width <-
is.null(children[[1]]) ||
is_probably_a_css_unit(children[[1]])
is_probably_a_css_unit(children[[1]])

if (first_is_width) {
# Assume an unnamed first argument that matches our expectations for
Expand Down
2 changes: 1 addition & 1 deletion R/navs-legacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ navbarPage_ <- function(
fillable = !isFALSE(fillable),
border_radius = FALSE,
border = !fluid,
page_main_container(contents)
page_main_container(contents, fillable = !isFALSE(fillable))
)
)

Expand Down
15 changes: 7 additions & 8 deletions R/page.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ page_sidebar <- function(
border = FALSE,
border_radius = FALSE,
!!!dots$attribs,
page_main_container(dots$children)
page_main_container(dots$children, fillable = fillable)
)

page_fillable(
Expand All @@ -297,13 +297,12 @@ page_sidebar <- function(
)
}

page_main_container <- function(...) {
as_fill_carrier(
tags$main(
class = "bslib-page-main bslib-gap-spacing",
...
)
page_main_container <- function(..., fillable = TRUE) {
main <- tags$main(
class = "bslib-page-main bslib-gap-spacing",
...
)
if (fillable) as_fill_carrier(main) else main
}

maybe_page_sidebar <- function(x) {
Expand Down Expand Up @@ -414,7 +413,7 @@ page_navbar <- function(
# TODO: Coordinate with next bslib version bump in Shiny to use the new interface
was_called_by_shiny <-
isNamespaceLoaded("shiny") &&
identical(rlang::caller_fn(), shiny::navbarPage)
identical(rlang::caller_fn(), shiny::navbarPage)

.navbar_options <- navbar_options_resolve_deprecated(
options_user = navbar_options,
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion inst/components/dist/components.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/components/scss/page_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ $bslib-sidebar-padding: $spacer * 1.5 !default;
// Ensure the page-level main area has a minimum height and width to prevent
// overly squished content in small screens, like IDE preview panels.
.bslib-sidebar-layout {
.bslib-page-main {
.bslib-page-main.html-fill-container {
min-height: var(--bslib-page-main-min-height, #{$bslib-page-main-min-height});
}

// But only apply the width constraint when the sidebar expanded (i.e.
// not collapsed or in transition) to prevent overlap with toggle button.
&:not(.sidebar-collapsed),
&.transitioning {
.bslib-page-main {
.bslib-page-main.html-fill-container {
min-width: var(--bslib-page-main-min-width, #{$bslib-page-main-min-width});
}
}
Expand Down
2 changes: 1 addition & 1 deletion inst/examples-shiny/brand.yml/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if (requireNamespace("thematic", quietly = TRUE)) {

is_app_hosted <-
Sys.getenv("R_CONFIG_ACTIVE") %in%
c("shinylive", "shinyapps", "rsconnect", "rstudio_cloud")
c("shinylive", "shinyapps", "rsconnect", "rstudio_cloud")
is_app_packaged <-
getwd() != system.file("examples-shiny/brand.yml", package = "bslib")

Expand Down
4 changes: 2 additions & 2 deletions inst/examples-shiny/build-a-box/R/random_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ random_plotly_plot <- function(type = NULL, color = "white") {

random_plotly_bar <- function(color, n = 50) {
plot_ly(
x = ~runif(n),
x = ~ runif(n),
type = "histogram",
histnorm = "probability",
nbinsx = 10,
Expand All @@ -66,7 +66,7 @@ random_plotly_bar <- function(color, n = 50) {
}

random_plotly_box <- function(color, n = 50) {
plot_ly(x = ~rnorm(n), type = "box", color = I(color))
plot_ly(x = ~ rnorm(n), type = "box", color = I(color))
}

random_plotly_line <- function(color, n) {
Expand Down
2 changes: 1 addition & 1 deletion inst/examples-shiny/flights/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ server <- function(input, output, session) {
size = ~mean_delay,
hoverinfo = "text",
alpha = 0.1,
text = ~paste0(
text = ~ paste0(
origin,
" -> ",
dest,
Expand Down
4 changes: 2 additions & 2 deletions inst/examples-shiny/value_box/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ server <- function(input, output) {
plotly_time_series(
economics,
x = ~date,
y = ~100 * unemploy / pop
y = ~ 100 * unemploy / pop
)
})

Expand All @@ -64,7 +64,7 @@ server <- function(input, output) {
plotly_time_series(
economics,
x = ~date,
y = ~100 * pce / pop
y = ~ 100 * pce / pop
)
})

Expand Down