diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index f793325..34cdbb0 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -46,7 +46,7 @@ We agree to restrict the following behaviors in our community. Instances, threat Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. -When an incident does occur, it is important to report it promptly. To report a possible violation, **please reach out to the DARA team at RIVM via dara-team-list@rivm.nl.** +When an incident does occur, it is important to report it promptly. To report a possible violation, **please reach out to the SPIN team at RIVM via spin@rivm.nl.** Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fda385e..637fabb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,7 +16,7 @@ While the package was originally developed for RIVM (and was previously called D ### 1. Open an issue -**Before submitting any code changes**, please open an issue on the [GitHub issue board](TODO) to: +**Before submitting any code changes**, please open an issue on the [GitHub issue board](https://github.com/rivm-syso/ROvis.table/issues) to: - Describe the bug you want to fix or the feature you want to add - Explain why the change is needed @@ -127,7 +127,7 @@ Please avoid contributions that: If you have questions about contributing: -- Open a discussion issue on [GitHub](TODO) +- Open a discussion issue on [GitHub](https://github.com/rivm-syso/ROvis.table/issues) - Email the SPIN team: [spin@rivm.nl](mailto:spin@rivm.nl) - Review existing code and documentation in the repository to understand patterns and conventions diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index fe247c0..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Note, this is a template from DARAtools. - -variables: - R_LIBS: "ci/lib" - LINTR_ERROR_ON_LINT: true - -# use tidyverse rocker image, includes R, tidyverse, devtools: https://github.com/rocker-org/rocker -image: rocker/tidyverse - -# define cache (for package installs, reduces job time) -cache: - key: cache-$CI_COMMIT_REF_SLUG - paths: - - $R_LIBS - -# define stages of runner -stages: - # - source - - build - - test - # - deploy (pkgdown + release) - -.install_deps_os: - before_script: - - echo $CI_COMMIT_REF_SLUG - - echo "Library path for packages:" $R_LIBS - - mkdir -p $R_LIBS - # install system packages because it runs on linux - - apt-get update - - >- - ACCEPT_EULA=Y apt-get install -y --no-install-recommends \ - libudunits2-dev \ - libgdal-dev \ - gdal-bin \ - libgeos-dev \ - libproj-dev \ - libglpk-dev -.install_deps_r: - before_script: - - | - R -e ' - devtools::install_deps(dependencies = TRUE, repos = "http://cran.r-project.org", upgrade = "never") - ' - -build_package: - stage: build - before_script: - - !reference [".install_deps_os", "before_script"] - - !reference [".install_deps_r", "before_script"] - script: - - R -e 'devtools::check(error_on = "warning", cran = FALSE)' - -run_unittests: - stage: test - before_script: - - !reference [".install_deps_os", "before_script"] - - !reference [".install_deps_r", "before_script"] - script: - - R -e 'devtools::test()' - -run_coverage: - stage: test - before_script: - - !reference [".install_deps_os", "before_script"] - - !reference [".install_deps_r", "before_script"] - script: - - R -e 'covr::package_coverage()' - # pattern to search for in log for coverage button - coverage: '/Coverage: \d+(?:\.\d+)?/' - -run_lint: - stage: test - script: - - | - R -e ' - installed.packages(lib.loc = "/builds/spin/ROvis.table/ci/lib")[, c("Package", "Version", "LibPath")] - install.packages("lintr") - lintr::lint_package() - ' -# generate_docs: -# stage: pkgdown -# script: -# - R -e 'devtools::install()' SA: kan weg denk ik? -# - R -e 'pkgdown::build_site()' -# rules: -# - if: $CI_COMMIT_BRANCH == "production" && $CI_COMMIT_TAG != "" -# when: always -# artifacts: -# paths: -# - public/ -# expire_in: 30 days -# only: -# - production - -# deploy step diff --git a/DESCRIPTION b/DESCRIPTION index 2db78a3..6deb3a0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,14 @@ Package: ROvis.table -Title: ROvis.table is an R package that provides a comprehensive suite of utilities for visualizing in Rijksoverheid style -Version: 0.0.0.9000 -Authors@R: person("spin@rivm.nl", email = "spin@rivm.nl", role = c("cre", "aut")) -Description: Provides accessible, keyboard-navigable data tables and themed - visualizations using the gt and DT packages, with RIVM styling guidelines. +Title: Accessible Data Tables with Rijksoverheid Styling +Version: 0.1.0 +Authors@R: person("ROvis team", email = "spin@rivm.nl", role = c("cre", "aut")) +Description: Provides accessible, keyboard-navigable data tables and themed + visualizations using the 'gt' and 'DT' packages, with Rijksoverheid styling + guidelines. License: Apache License (>= 2) -Imports: +Depends: + R (>= 4.5.0) +Imports: cli (>= 3.6.2), dplyr (>= 1.1.4), DT (>= 0.34.0), @@ -22,12 +25,10 @@ Suggests: knitr (>= 1.50), rmarkdown (>= 2.30), testthat (>= 3.0.0) -Remotes: - git@github.com:rivm-syso/ROvis.utils.git +Remotes: + rivm-syso/ROvis.utils VignetteBuilder: quarto -Config/Roxygen2/markdown: TRUE -Config/Roxygen2/version: 8.1.0 Config/testthat/edition: 3 Encoding: UTF-8 -Config/roxygen2/version: 8.0.0 - +Config/roxygen2/markdown: TRUE +Config/roxygen2/version: 8.1.0 diff --git a/NAMESPACE b/NAMESPACE index 0f7a9a1..f45bc22 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,27 +4,35 @@ export(ro_dt_table) export(ro_dt_theme) export(ro_gt_theme) import(rlang) -importFrom(DT,JS) -importFrom(DT,datatable) -importFrom(ROvis.utils,ro_check_if_font_available) -importFrom(ROvis.utils,ro_color) +importFrom(DT, + JS, + datatable +) +importFrom(ROvis.utils, + ro_check_if_font_available, + ro_color +) importFrom(cli,cli_abort) importFrom(dplyr,filter) -importFrom(gt,cell_text) -importFrom(gt,cells_body) -importFrom(gt,cells_column_labels) -importFrom(gt,cells_row_groups) -importFrom(gt,cells_title) -importFrom(gt,cols_align) -importFrom(gt,everything) -importFrom(gt,gt) -importFrom(gt,opt_row_striping) -importFrom(gt,px) -importFrom(gt,sub_missing) -importFrom(gt,tab_options) -importFrom(gt,tab_style) -importFrom(gt,where) +importFrom(gt, + cell_text, + cells_body, + cells_column_labels, + cells_row_groups, + cells_title, + cols_align, + everything, + gt, + opt_row_striping, + px, + sub_missing, + tab_options, + tab_style, + where +) importFrom(magrittr,"%>%") -importFrom(shiny,HTML) -importFrom(shiny,tags) +importFrom(shiny, + HTML, + tags +) importFrom(systemfonts,system_fonts) diff --git a/NEWS.md b/NEWS.md index f742277..716b4b9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,22 +1,24 @@ -List all changes in chronological order (new -> old ) to the package here. After release, write release notes and/or a blogpost for the package mailing list and/or pkg down website. This NEWS.md file will be visible in the pkg down website under News > Changelog. - -We have chosen to include the headers "Added", "Changed", "Fixed", and "Deprecated". You are free to change these. - -GitLab issue numbers are mentioned where applicable. - -Sentences start with a capital letter and end with a point. - -Use '-' before each entry. - -Follow guidelines in documentation of pkgdown::build_news() for version headings. - -# ROvis.table v0.0.0.9000 - -### :sparkles: Added - -### :hammer_and_wrench: Changed - -### :bug: Fixed - -### :coffin: Deprecated - +# ROvis.table v0.1.0 + +First release since `ROvis.table` was split out of the `ROvis` monolith into its own +package, and the repository moved from GitLab to GitHub. + +### :sparkles: Added + +- `ro_gt_theme()`: RIVM-styled theme for `gt` tables. +- `ro_dt_table()` and `ro_dt_theme()`: accessible, keyboard-navigable `DT` tables. +- Added a "Getting Started" vignette. +- Added community health files: `CONTRIBUTING.md`, `CONTRIBUTORS.md`, and issue and +pull request templates. + +### :hammer_and_wrench: Changed + +- Migrated the repository from GitLab to GitHub (`rivm-syso/ROvis.table`). +- Replaced GitLab CI with a GitHub Actions workflow covering lint, R CMD check, test +coverage, and pkgdown. + +### :bug: Fixed + +### :coffin: Deprecated +- Removed the stray `.gitlab-ci.yml` left over from the pre-GitHub setup. + diff --git a/R/ROvis.table-package.R b/R/ROvis.table-package.R index f04b310..b26e89d 100644 --- a/R/ROvis.table-package.R +++ b/R/ROvis.table-package.R @@ -7,7 +7,7 @@ #' @importFrom cli cli_abort #' @importFrom dplyr filter #' @importFrom magrittr %>% -#' @importFrom systemfonts systemfonts +#' @importFrom systemfonts system_fonts #' @importFrom DT datatable #' @importFrom gt gt #' @importFrom ROvis.utils ro_check_if_font_available diff --git a/R/ro_dt_table.R b/R/ro_dt_table.R index eb1b6e3..46db7a9 100644 --- a/R/ro_dt_table.R +++ b/R/ro_dt_table.R @@ -1,6 +1,7 @@ #' datatable table to be used with DT #' #' @description +#' `r ROvis.utils::ro_group_badge('DT')` #' Rendering an accessible, keyboard-navigable (with customJS) data table #' table with options for sorting and page length. #' diff --git a/R/ro_dt_theme.R b/R/ro_dt_theme.R index 0c0fa23..a06a9fa 100644 --- a/R/ro_dt_theme.R +++ b/R/ro_dt_theme.R @@ -1,8 +1,9 @@ #' Custom DT Table CSS Styling #' #' @description +#' `r ROvis.utils::ro_group_badge('DT')` #' Returns a Shiny tags object containing custom CSS styles for DT tables, -#' following preliminary RIVM huisstijl. +#' following preliminary Rijksoverheid huisstijl. #' #' @importFrom shiny tags HTML #' @importFrom ROvis.utils ro_check_if_font_available diff --git a/R/ro_gt_theme.R b/R/ro_gt_theme.R index 8a99811..ab8eff7 100644 --- a/R/ro_gt_theme.R +++ b/R/ro_gt_theme.R @@ -1,15 +1,14 @@ #' Use a standardized theme for gt tables #' #' @description -#' `r ro_group_badge('gt')` +#' `r ROvis.utils::ro_group_badge('gt')` #' This function implements a stylized theme for gt tables. #' -#' @importFrom gt gt tab_options cols_align sub_missing opt_row_striping tab_ -#' style cells_title cell_text cells_column_labels cells_row_groups cells_body -#' everything where px +#' @importFrom gt gt tab_options cols_align sub_missing opt_row_striping +#' tab_style cells_title cell_text cells_column_labels cells_row_groups +#' cells_body everything where px #' @importFrom systemfonts system_fonts #' @importFrom ROvis.utils ro_color -#' @importFrom gt gt #' #' @param df Dataframe. #' @param ROfont Default is FALSE, will change to TRUE for next major release (1.0.0). diff --git a/README.md b/README.md index 0cca03e..fa4c58e 100644 --- a/README.md +++ b/README.md @@ -6,39 +6,42 @@ # ROvis.table -## ROvis.table is an R package that provides a comprehensive suite of utilities for visualizing in Rijksoverheid style +## Rijksoverheid Visualisatie - table ## Description -TBD +ROvis.table provides accessible, keyboard-navigable data tables and themed visualizations using the gt and DT packages, with Rijksoverheid styling guidelines. ## Installation ```r -# Install from GitLab -# install.packages("devtools") -devtools::install_gitlab("spin/ROvis.table", host = "gitlab.rivm.nl") +# Install from GitHub (private repo - requires GitHub auth, e.g. a PAT +# via usethis::create_github_token() / gitcreds, since this repo is private) +# install.packages("remotes") +remotes::install_github("rivm-syso/ROvis.table") ``` -For more information, check out the [wiki page about daratools](https://gitlab.rivm.nl/dara/wiki/-/wikis/DARAtools). +## Usage +```r +library(ROvis.table) -## Usage -*Use examples liberally, and show the expected output if you can. It's helpful to have the smallest example of usage that you can demonstrate inline, while providing links to more sophisticated examples if they are too long to reasonably include in the README.* +# Apply the Rijksoverheid-styled gt theme to a data frame +ro_gt_theme(head(mtcars, 5)) +``` ## Support -First point of contact for questions: TBD (spin@rivm.nl) +First point of contact for questions: SPIN team (spin@rivm.nl) ## Roadmap *If you have ideas for releases in the future, it is a good idea to list them in the README.* ## Contributing -*State if you are open to contributions and what your requirements are for accepting them.* +See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for guidelines on how to contribute, and [CONTRIBUTORS.md](CONTRIBUTORS.md) for the list of contributors. ## Instructions for developers -Check out the [wiki page about r packages](https://gitlab.rivm.nl/dara/wiki/-/wikis/DARAtools) -for elaborate information about R package development. Below we describe the most important -guidelines and practicalities. +Below we describe the most important guidelines and practicalities for R package +development on this project. ### Requirements @@ -48,13 +51,13 @@ development to adhere to standards for R packages and make developing easier! In in your Rstudio environment: ```r -install.packages(testthat) -install.packages(lintr) -install.packages(roxygen2) -install.packages(quarto) -install.packages(pkgdown) -install.packages(devtools) -install.packages(usethis) +install.packages("testthat") +install.packages("lintr") +install.packages("roxygen2") +install.packages("quarto") +install.packages("pkgdown") +install.packages("devtools") +install.packages("usethis") ``` ### Guidelines @@ -67,11 +70,10 @@ To ensure code standardization and quality, follow these guidelines: the `min_version` argument to specify a minimum version. - Add a new function dependency to the NAMESPACE with `usethis::use_import_from()` - Add documentation to new functions by inserting a roxygen skeleton and use `devtools::document()` to -create automatic documentation in the `man` folder, for more information check out this -[wiki section](https://gitlab.rivm.nl/dara/wiki/-/wikis/Create%20your%20own%20R%20packages#documentation) +create automatic documentation in the `man` folder ## Authors and acknowledgment -This R packages was created by TBD (spin@rivm.nl). +This R package was created by the SPIN team (spin@rivm.nl). ## License -*For open source projects, indicate how it is licensed.* +This package is licensed under the Apache License 2.0. See [LICENSE.md](LICENSE.md) for details. diff --git a/man/ROvis.table-package.Rd b/man/ROvis.table-package.Rd index 8235a0a..3c463ff 100644 --- a/man/ROvis.table-package.Rd +++ b/man/ROvis.table-package.Rd @@ -4,16 +4,18 @@ \name{ROvis.table-package} \alias{ROvis.table} \alias{ROvis.table-package} -\title{ROvis.table: ROvis.table is an R package that provides a comprehensive suite of utilities for visualizing in Rijksoverheid style} +\title{ROvis.table: Accessible Data Tables with Rijksoverheid Styling} \description{ -Provides accessible, keyboard-navigable data tables and themed visualizations using the gt and DT packages, with RIVM styling guidelines. +\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} + +Provides accessible, keyboard-navigable data tables and themed visualizations using the 'gt' and 'DT' packages, with Rijksoverheid styling guidelines. } \author{ -\strong{Maintainer}: spin@rivm.nl \email{spin@rivm.nl} +\strong{Maintainer}: ROvis team \email{spin@rivm.nl} Authors: \itemize{ - \item spin@rivm.nl \email{spin@rivm.nl} + \item ROvis team \email{spin@rivm.nl} } } diff --git a/man/figures/group-DT.svg b/man/figures/group-DT.svg new file mode 100644 index 0000000..3ff9324 --- /dev/null +++ b/man/figures/group-DT.svg @@ -0,0 +1,30 @@ + + ROvis: DT + + + + + + + + + + + + + + + + ROvis + + + + DT + + + + diff --git a/man/figures/group-gt.svg b/man/figures/group-gt.svg new file mode 100644 index 0000000..58d8129 --- /dev/null +++ b/man/figures/group-gt.svg @@ -0,0 +1,30 @@ + + ROvis: gt + + + + + + + + + + + + + + + + ROvis + + + + gt + + + + diff --git a/man/ro_dt_table.Rd b/man/ro_dt_table.Rd index 1427667..c378495 100644 --- a/man/ro_dt_table.Rd +++ b/man/ro_dt_table.Rd @@ -19,6 +19,7 @@ ro_dt_table(data, caption, sorting = FALSE, pagelength = 10) data table html } \description{ +\ifelse{html}{\figure{group-DT.svg}{options: alt='[DT]'}}{\strong{[DT]}}\cr\cr Rendering an accessible, keyboard-navigable (with customJS) data table table with options for sorting and page length. } diff --git a/man/ro_dt_theme.Rd b/man/ro_dt_theme.Rd index ff1d0d7..2b96c91 100644 --- a/man/ro_dt_theme.Rd +++ b/man/ro_dt_theme.Rd @@ -17,8 +17,9 @@ A \code{shiny.tags} object with a \code{} tag containing custom CSS for DT tables. } \description{ +\ifelse{html}{\figure{group-DT.svg}{options: alt='[DT]'}}{\strong{[DT]}}\cr\cr Returns a Shiny tags object containing custom CSS styles for DT tables, -following preliminary RIVM huisstijl. +following preliminary Rijksoverheid huisstijl. } \examples{ if (interactive()) { diff --git a/man/ro_gt_theme.Rd b/man/ro_gt_theme.Rd index 618a91e..c60826f 100644 --- a/man/ro_gt_theme.Rd +++ b/man/ro_gt_theme.Rd @@ -18,7 +18,7 @@ If Rijksoverheid font is not available on your device, Verdana will be used.} gt table object. } \description{ -`r ro_group_badge('gt')` +\ifelse{html}{\figure{group-gt.svg}{options: alt='[gt]'}}{\strong{[gt]}}\cr\cr This function implements a stylized theme for gt tables. } \examples{ diff --git a/tests/testthat/_snaps/ro_gt_theme.md b/tests/testthat/_snaps/ro_gt_theme.md index def2e77..142a77f 100644 --- a/tests/testthat/_snaps/ro_gt_theme.md +++ b/tests/testthat/_snaps/ro_gt_theme.md @@ -1,7 +1,7 @@ # ro_gt_theme works and all styling choices are working Code - as_raw_html(tab_header(ro_gt_theme(mtcars, groupname_col = "cyl", id = "abc"), + gt::as_raw_html(gt::tab_header(ro_gt_theme(mtcars, groupname_col = "cyl", id = "abc"), title = "mtcars", subtitle = "Open dataset from dplyr")) Output
diff --git a/vignettes/getting-started.qmd b/vignettes/getting-started.qmd new file mode 100644 index 0000000..ac1d7da --- /dev/null +++ b/vignettes/getting-started.qmd @@ -0,0 +1,62 @@ +--- +title: "Getting Started with ROvis.table" +format: html +vignette: > + %\VignetteIndexEntry{Getting Started with ROvis.table} + %\VignetteEngine{quarto::html} + %\VignetteEncoding{UTF-8} +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +ROvis.table provides two ways to build accessible, Rijksoverheid-styled tables: +`ro_gt_theme()` for static `gt` tables, and `ro_dt_table()` (with `ro_dt_theme()`) for +interactive, keyboard-navigable `DT` tables. + +```{r libraries, message=FALSE} +library(ROvis.table) +``` + +## Static tables with gt + +Apply `ro_gt_theme()` to a `gt` table built from any data frame: + +```{r gt-example, eval=requireNamespace("gt", quietly = TRUE)} +ro_gt_theme(head(mtcars, 5)) +``` + +## Interactive tables with DT + +`ro_dt_table()` wraps `DT::datatable()` with accessible defaults (ARIA-labelled +pagination, sensible page length). Pair it with `ro_dt_theme()` in a Shiny UI for +consistent styling: + +```{r dt-example, eval=requireNamespace("DT", quietly = TRUE)} +ro_dt_table( + data = head(mtcars, 20), + caption = "Motor Trend car road tests", + sorting = TRUE, + pagelength = 10 +) +``` + +In a Shiny app, add `ro_dt_theme()` alongside your `DTOutput()`: + +```{r shiny-example, eval=FALSE} +library(shiny) + +ui <- fluidPage( + ro_dt_theme(sorting = TRUE), + DT::DTOutput("mytable") +) + +server <- function(input, output, session) { + output$mytable <- DT::renderDT( + ro_dt_table(mtcars, caption = "Motor Trend car road tests", sorting = TRUE) + ) +} + +shinyApp(ui, server) +```