From caa35d7970f794d2a41fa3991149359194b852d5 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 26 Sep 2022 11:34:35 -0500 Subject: [PATCH 1/5] Add vfill-item CSS class when height isn't specified This gives widgets the potential to stretch vertically when used inside a vfill-container like shiny::fillPage(), bslib::card(), etc --- R/htmlwidgets.R | 61 +++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/R/htmlwidgets.R b/R/htmlwidgets.R index 28a09fb..61e0eaf 100644 --- a/R/htmlwidgets.R +++ b/R/htmlwidgets.R @@ -170,32 +170,15 @@ addHook <- function(x, hookName, jsCode, data = NULL) { toHTML <- function(x, standalone = FALSE, knitrOptions = NULL) { - sizeInfo <- resolveSizing(x, x$sizingPolicy, standalone = standalone, knitrOptions = knitrOptions) - - if (!is.null(x$elementId)) - id <- x$elementId - else - id <- paste("htmlwidget", createWidgetId(), sep="-") - - w <- validateCssUnit(sizeInfo$width) - h <- validateCssUnit(sizeInfo$height) - - # create a style attribute for the width and height - style <- paste( - "width:", w, ";", - "height:", h, ";", - sep = "") - - x$id <- id + x$id <- x$elementId %||% paste("htmlwidget", createWidgetId(), sep = "-") - container <- if (isTRUE(standalone)) { - function(x) { - div(id="htmlwidget_container", x) - } - } else { - identity + container <- identity + if (isTRUE(standalone)) { + container <- function(x) div(id = "htmlwidget_container", x) } + sizeInfo <- resolveSizing(x, x$sizingPolicy, standalone = standalone, knitrOptions = knitrOptions) + html <- htmltools::tagList( container( htmltools::tagList( @@ -203,18 +186,25 @@ toHTML <- function(x, standalone = FALSE, knitrOptions = NULL) { widget_html( name = class(x)[1], package = attr(x, "package"), - id = id, - style = style, - class = paste(class(x)[1], "html-widget"), + id = x$id, + style = htmltools::css( + width = validateCssUnit(sizeInfo$width), + height = validateCssUnit(sizeInfo$height) + ), + class = paste( + class(x)[1], + "html-widget", + if (is.null(x$height)) "vfill-item" + ), width = sizeInfo$width, height = sizeInfo$height ), x$append ) ), - widget_data(x, id), + widget_data(x, x$id), if (!is.null(sizeInfo$runtime)) { - tags$script(type="application/htmlwidget-sizing", `data-for` = id, + tags$script(type="application/htmlwidget-sizing", `data-for` = x$id, toJSON(sizeInfo$runtime) ) } @@ -263,7 +253,7 @@ lookup_widget_html_method <- function(name, package) { list(fn = widget_html.default, name = "widget_html.default", legacy = FALSE) } -widget_html <- function (name, package, id, style, class, inline = FALSE, ...) { +widget_html <- function(name, package, id, style, class, inline = FALSE, ...) { fn_info <- lookup_widget_html_method(name, package) @@ -489,13 +479,14 @@ shinyWidgetOutput <- function(outputId, name, width, height, package = name, class = paste0( name, " html-widget html-widget-output", if (reportSize) " shiny-report-size", - if (reportTheme) " shiny-report-theme" + if (reportTheme) " shiny-report-theme", + if (is.null(height)) " vfill-item" ), - style = sprintf("width:%s; height:%s; %s", - htmltools::validateCssUnit(width), - htmltools::validateCssUnit(height), - if (inline) "display: inline-block;" else "" - ), width = width, height = height + style = htmltools::css( + width = htmltools::validateCssUnit(width), + height = htmltools::validateCssUnit(height), + display = if (inline) "inline-block" + ) ) ) From 4e38b23d26eff296036f55a53b97055522403d76 Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 7 Oct 2022 10:55:33 -0500 Subject: [PATCH 2/5] Bump ubuntu version --- .github/workflows/R-CMD-check.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 82195e0..41b53df 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -27,12 +27,12 @@ jobs: - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} - {os: windows-latest, r: '3.6'} - - {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.3.0 (ubuntu-20.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true From ae1d588ced460a8bb2fcee2d16ba8fec8f8d4536 Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 20 Oct 2022 13:55:15 -0500 Subject: [PATCH 3/5] Use shiny-workflows --- .github/workflows/R-CMD-check.yaml | 109 ++++------------------------- 1 file changed, 13 insertions(+), 96 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 41b53df..7cd3cf1 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,104 +1,21 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. +# Workflow derived from https://github.com/rstudio/shiny-workflows # -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# NOTE: This Shiny team GHA workflow is overkill for most R packages. +# For most R packages it is better to use https://github.com/r-lib/actions on: push: - branches: - - master + branches: [main, rc-**] pull_request: - branches: - - master + branches: [main] + schedule: + - cron: '0 5 * * 1' # every monday -name: R-CMD-check +name: Package checks jobs: + website: + uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1 + routine: + uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1 R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: macOS-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6'} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.3.0 (ubuntu-20.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@master - with: - r-version: ${{ matrix.config.r }} - http-user-agent: ${{ matrix.config.http-user-agent }} - - - uses: r-lib/actions/setup-pandoc@master - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1 From 2bc22482f21334a9a748f52a62a65b75340f2e0b Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 20 Oct 2022 14:08:54 -0500 Subject: [PATCH 4/5] Probably can't use shiny-workflows --- .github/workflows/R-CMD-check.yaml | 61 +++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 7cd3cf1..66d8969 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,21 +1,56 @@ -# Workflow derived from https://github.com/rstudio/shiny-workflows +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help # -# NOTE: This Shiny team GHA workflow is overkill for most R packages. -# For most R packages it is better to use https://github.com/r-lib/actions +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: - branches: [main, rc-**] + branches: [main, master] pull_request: - branches: [main] - schedule: - - cron: '0 5 * * 1' # every monday + branches: [main, master] -name: Package checks +name: R-CMD-check jobs: - website: - uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1 - routine: - uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1 R-CMD-check: - uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1 + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true From f09e532e8cdf33a0d9000090de95b2833efa1410 Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 20 Oct 2022 14:20:21 -0500 Subject: [PATCH 5/5] bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index a9e269a..d8721f2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: htmlwidgets Type: Package Title: HTML Widgets for R -Version: 1.5.4.9000 +Version: 1.5.4.9001 Authors@R: c( person("Ramnath", "Vaidyanathan", role = c("aut", "cph")), person("Yihui", "Xie", role = c("aut")),