Skip to content

Commit

Permalink
separate 'urgency_style' fn from gt-table main block
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Mar 18, 2024
1 parent e3e3f64 commit 473a2b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashboard
Title: What the Package Does (One Line, Title Case)
Version: 0.0.3.025
Version: 0.0.3.026
Authors@R:
person(given = "First",
family = "Last",
Expand Down
53 changes: 18 additions & 35 deletions R/gt-table.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ open_gt_table <- function (dat) {

dat_url$urgency [dat_url$urgency > ncols] <- ncols
dat_url$urgency [grepl ("holding", dat_url$labels)] <- 0
urgency_cols <- c ("number", "title", "stage_date", "labels")

gt::gt (
dat_url,
Expand Down Expand Up @@ -113,44 +114,26 @@ open_gt_table <- function (dat) {
spanners = c ("ed_span", "rev1span")
)
) |>
add_urgency_style (1, "#FFFF8088", urgency_cols) |>
add_urgency_style (2, "#FFFF0088", urgency_cols) |>
add_urgency_style (3, "#FFAA0088", urgency_cols) |>
add_urgency_style (4, "#FF550088", urgency_cols) |>
add_urgency_style (5, "#FF000088", urgency_cols) |>
add_bg_colours ()
}

#' styles for "stage_date" columns to highlight need for action.
#' @noRd
add_urgency_style <- function (tab, urgency_val, colour, col_names) {
urgency <- NULL # suppress no visible binding note
tab |>
gt::tab_style (
# Finally styles for "stage_date" columns to highlight need for
# action. Each grade of "urgency" has to be individually specified.
style = list (gt::cell_fill (color = "#FFFF8088")),
locations = gt::cells_body (
columns = c (`number`, `title`, `stage_date`, `labels`),
rows = urgency == 1
)
) |>
gt::tab_style (
style = list (gt::cell_fill (color = "#FFFF0088")),
locations = gt::cells_body (
columns = c (`number`, `title`, `stage_date`, `labels`),
rows = urgency == 2
)
) |>
gt::tab_style (
style = list (gt::cell_fill (color = "#FFAA0088")),
locations = gt::cells_body (
columns = c (`number`, `title`, `stage_date`, `labels`),
rows = urgency == 3
)
) |>
gt::tab_style (
style = list (gt::cell_fill (color = "#FF550088")),
locations = gt::cells_body (
columns = c (`number`, `title`, `stage_date`, `labels`),
rows = urgency == 4
)
) |>
gt::tab_style (
style = list (gt::cell_fill (color = "#FF000088")),
style = list (gt::cell_fill (color = colour)),
locations = gt::cells_body (
columns = c (`number`, `title`, `stage_date`, `labels`),
rows = urgency == 5
columns = col_names,
rows = urgency == urgency_val
)
) |>
add_bg_colours ()
)
}

add_bg_colours <- function (tab) {
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "dashboard: What the Package Does (One Line, Title Case)",
"codeRepository": "https://github.com/ropensci-review-tools/dashboard",
"license": "https://spdx.org/licenses/MIT",
"version": "0.0.3.025",
"version": "0.0.3.026",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 473a2b8

Please sign in to comment.