1298 enhancement/cleanup code quality#1320
Conversation
…accessibility (pharmaverse#1298) - Remove print() debug statements from TLG module, use log_error() instead - Remove unused require(magrittr) and require(stats) from app.R - Replace deprecated HTML align attributes with inline CSS - Standardize button CSS classes (remove duplicate btn prefix) - Add aria-label to 15 icon-only buttons for screen reader support - Remove redundant disabled=FALSE default from actionButton Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…bles (pharmaverse#1298) - Create inst/shiny/functions/colors.R with 16 semantic color constants - Expand _colors.scss with grey-6/7/8, accent, and border variables - Replace ~25 inline hex values across 9 Shiny module files Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
| @@ -0,0 +1,26 @@ | |||
| # Color constants — keep in sync with inst/shiny/www/styles/modules/_colors.scss | |||
There was a problem hiding this comment.
Color constants duplicate and diverge from existing SCSS variables
The existing _colors.scss already defines a palette ($anca-blue: #007bc2, $grey-1 through $grey-5). The new constants here introduce a parallel set that doesn't reference or align with those:
ACCENT_BLUEis#0d6efd(Bootstrap blue) vs$anca-blue: #007bc2— different blues, but naming doesn't distinguish intent.BG_GREY_LIGHTis#eeeeeevs$grey-5: #dadada— similar purpose, different values.
The sync comment on line 1 is good, but there's no mechanism to enforce it. A future developer changing the SCSS variable won't know to update the R constant (and vice versa).
Suggestion: Add a matching comment in _colors.scss pointing back to this file (bidirectional sync note). Also consider whether some of these should reuse existing SCSS variable values rather than introducing new ones.
There was a problem hiding this comment.
Thank you for the review. Now added bidirectional sync comment in _colors.scss pointing back to colors.R (commit a5b78fe). The new variables expand the shared palette — they mirror the R constants and will be consumed by future CSS rules. For now both files serve as the single source of truth for their respective domains (SCSS for CSS rules, R for inline styles).
| ) | ||
| tags$blockquote( | ||
| style = "border-left: 3px solid #ccc; padding-left: 1em; color: #555;", | ||
| style = paste0("border-left: 3px solid ", BORDER_MUTED, "; padding-left: 1em; color: ", TEXT_HEADING, ";"), |
There was a problem hiding this comment.
paste0() for inline styles reduces readability
The original one-liner was easy to scan. The replacement fragments the string across multiple paste0() concatenations:
# Before
style = "border-left: 3px solid #ccc; padding-left: 1em; color: #555;"
# After
style = paste0("border-left: 3px solid ", BORDER_MUTED, "; padding-left: 1em; color: ", TEXT_HEADING, ";")Since glue is already in DESCRIPTION Imports, consider using it for cleaner interpolation:
style = glue("border-left: 3px solid {BORDER_MUTED}; padding-left: 1em; color: {TEXT_HEADING};")This applies to all similar paste0() style interpolations in this PR (this file, saved_outputs.R, zip.R, etc.).
There was a problem hiding this comment.
Switched all color-related style interpolations from paste0() to glue::glue() across 8 files. glue was already in DESCRIPTION Imports so no dependency change. The nested paste()/paste0() block in zip.R is now a single glue::glue() call.
| require(shinyjs) | ||
| require(shinyjqui) | ||
| require(shinyWidgets) | ||
| require(stats) |
There was a problem hiding this comment.
require(stats) removal — likely safe but worth verifying
Removing require(magrittr) is clearly correct (%>% is re-exported by dplyr). Removing require(stats) is almost certainly fine since stats is a base package that's always loaded in R sessions, but worth a quick grep -r "stats::" inst/shiny/ to confirm no module code relies on the namespace being explicitly attached.
There was a problem hiding this comment.
Good suggestion, grep -r "stats::" inst/shiny/ returns zero results.
| $grey-4: #cdcdcd; | ||
| $grey-5: #dadada; | ||
| $grey-6: #dddddd; | ||
| $grey-7: #e9e9e9; |
There was a problem hiding this comment.
main.css not updated with new SCSS variables
Per AGENTS.md, SCSS changes must also be applied to inst/shiny/www/main.css. These new variables aren't consumed by any CSS rules in this PR (they're reference-only to stay in sync with colors.R), so there's no functional impact — but the checklist item "If any .scss change was done, run data-raw/compile_css.R" is marked N/A when it should apply.
If these variables are purely documentary, consider noting that explicitly in the PR description. If they're meant to be used in future CSS rules, main.css should be recompiled.
There was a problem hiding this comment.
Aware of that. These variables are not purely documentary — they sync the CSS palette with colors.R so future SCSS rules can reference them (e.g., background: $accent-danger;) instead of hardcoding hex values. main.css has been recompiled via data-raw/compile_css.R; the output is identical because no existing CSS rules reference the new variables yet, but the compiled output is ready for when they do.
| ), | ||
| style = "unite", | ||
| icon = icon("question"), | ||
| icon = icon("question"), `aria-label` = "Help", |
There was a problem hiding this comment.
aria-label on dropdown() — verify it reaches the DOM
The aria-label is passed to shinyWidgets::dropdown(), not directly to an HTML <button> element. This works only if dropdown() forwards ... args to the trigger button. If it doesn't, the aria-label won't appear in the rendered HTML.
Please verify in the browser devtools (as described in the test instructions) that the aria-label="Help" attribute actually appears on the rendered <button> element for at least one of these 12 dropdown instances.
There was a problem hiding this comment.
That's right, shinyWidgets::dropdown() passes ... to the inner content div . Verified this by reading the dropdown() source. Replaced aria-label = "Help" with label = "Help" on all 12 dropdown instances. The label parameter is the native way to add accessible text to the dropdown trigger button.
| "background-color: #dc3545;", | ||
| "color: #fff;", | ||
| paste0("background-color: ", ACCENT_DANGER, ";"), | ||
| paste0("color: ", ANCA_WHITE, ";"), |
There was a problem hiding this comment.
Inconsistent paste() / paste0() nesting
The outer paste() joins with spaces while inner paste0() calls handle color interpolation:
style = paste(
"display: inline-block;",
paste0("background-color: ", ACCENT_DANGER, ";"),
paste0("color: ", ANCA_WHITE, ";"),
"border-radius: 20px;",
...
)This works but is awkward to read. A single glue() call would be cleaner:
style = glue(
"display: inline-block; ",
"background-color: {ACCENT_DANGER}; ",
"color: {ANCA_WHITE}; ",
"border-radius: 20px; ",
"padding: 5px 14px; ",
"font-size: 0.85rem;"
)There was a problem hiding this comment.
Now fixed as part of the glue::glue() refactoring (same as #2). The nested paste()/paste0() block is now a single clean glue::glue() call.
|
Otherwise, looks good :) |
… sync notes (pharmaverse#1298) - Replace paste0/paste with glue::glue() for cleaner style string interpolation across 8 files (tab_about.R, saved_outputs.R, zip.R, utils-exclusions.R, nca_results.R, manual_slopes_table.R, settings.R, tlg_option_table.R) - Replace ineffective `aria-label` with `label = "Help"` on 12 dropdown() calls — dropdown() forwards `label` to the trigger button but `aria-label` only reaches the inner content div - Add bidirectional sync note in _colors.scss pointing back to colors.R - Recompile main.css (no visual changes — new SCSS variables are not yet consumed by any CSS rules) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
22a0917 to
6b8de75
Compare
…verse#1298) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
d257457 to
a5b78fe
Compare
Co-authored-by: Ona <no-reply@ona.com>
|
The This is not caused by the PR's changes — the example code is unchanged — but the new inline ggplot2 implementation (from the Fix: Wrap the Apply this diff to #' @examples
+#' \donttest{
#' # Make an example small dataset
#' adnca <- adnca_example
#' adnca <- adnca[adnca$USUBJID %in% unique(adnca$USUBJID)[c(1, 2)],]
@@ -403,6 +404,7 @@
#' plots <- pkcg02(adnca)
#' plots_log <- pkcg02(adnca, scale = "LOG")
#' plotly::plotly_build(plots[[1]]) # View the first plot
+#' }
#'
#' @exportThen run |
Blocker:
|
|
Shaakon35
left a comment
There was a problem hiding this comment.
please see comments above
…or help dropdowns (pharmaverse#1320) - Fix .gitignore: missing trailing newline caused desktop.ini and tests/testthat/Rplots.pdf to be concatenated into one invalid pattern - Replace label="Help" with tooltip=tooltipOptions(title="Help") on all 12 shinyWidgets::dropdown() instances to preserve original icon-only visual appearance while maintaining accessibility Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…harmaverse#1320) The pkcg02 example exceeds the 5s R CMD check timing threshold on Windows CI runners (5.83s elapsed), producing a NOTE that fails the check. The new inline ggplot2 implementation from pharmaverse#1316 runs slightly slower on Windows. Wrapping in \donttest{} skips the example during automated checks while keeping it runnable for users. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
wangzhengdna-lang
left a comment
There was a problem hiding this comment.
@Shaakon35 All three issues from your review have been addressed:
1. .gitignore corruption (BLOCKER) — Fixed
The missing trailing newline caused desktop.ini and tests/testthat/Rplots.pdf to be concatenated into one invalid pattern (desktop.initests/testthat/Rplots.pdf). Split into two proper lines with correct newline separation.
2. label = "Help" visual change — Fixed
Replaced all 12 instances of label = "Help" with tooltip = tooltipOptions(title = "Help"). This preserves the original icon-only visual appearance of all help dropdown buttons while maintaining screen-reader accessibility via data-bs-title.
3. Windows CI timeout (pkcg02 example) — Fixed
Wrapped the pkcg02 example in \donttest{} (same pattern already used by pkcg03 with \dontrun{}). The example remains valid and runnable, but R CMD check skips it for timing. Ran devtools::document() to regenerate man/pkcg02.Rd.
|
Three items to address before this can merge:
|
|
@h5hoang Could you please have a review? :) |
Issue
Closes #1298
Description
Code quality cleanup across Shiny app modules — removing debug artifacts, modernizing deprecated patterns, standardizing CSS classes, and improving accessibility. Seven self-contained changes, no functional behavior modified.
Changes
print()debug statements — Replacedprint(tlg_order())intab_tlg.R(removed) andprint(e)intlg_module.R(→log_error(e$message))require()calls — Removedrequire(magrittr)andrequire(stats)fromapp.R;%>%is re-exported bydplyr, base stats functions are always availablealignattributes — Changed 3div(align = "...")todiv(style = "text-align: ...")intlg_module.Rinst/shiny/functions/colors.Rwith 16 semantic color constants, expanded SCSS_colors.scsswith matching variables, replaced ~25 inline hex values across 9 module filesbtnprefix from 12actionButton/downloadButtoncalls (Shiny auto-addsbtnclass)aria-labelto icon-only buttons — 15 buttons: 12 dropdown help icons (aria-label="Help"), 1 remove exclusion (aria-label="Remove exclusion"), 1 remove ratio pair (aria-label="Remove ratio pair"), 1 remove from exports (aria-label="Remove from exports")disabled = FALSE— Removed fromunits_table.RactionButton (default value)Definition of Done
print()calls remain in production Shiny code (outsiderenderPrint)require(stats)andrequire(magrittr)removed fromapp.Ralignattributes in module filesaria-labelattributesHow to test
devtools::load_all(); aNCA::run_app()aria-label="Help"align→stylechangedisabled = FALSEContributor checklist
.scsschange was done, rundata-raw/compile_css.R— N/Adata-raw/test_suggests_hidden.R— N/ANotes to reviewer
inst/shiny/(Shiny app) with no modifications toR/(package API). The onlyR/-adjacent change isNEWS.mdandDESCRIPTIONversion bump.alignuses (insettings.Randmanual_slopes_table.R) arereactable::colDef(align = ...)— valid reactable API, not deprecated HTML attributes.