diff --git a/R/mod_metricBox.R b/R/mod_metricBox.R index 849d8670..1a05a049 100644 --- a/R/mod_metricBox.R +++ b/R/mod_metricBox.R @@ -37,7 +37,6 @@ metricBoxServer <- function(id, title, desc, value, score = "NULL", metric <- dbSelect("select * from metric", db_name = golem::get_golem_options('assessment_db_name')) - # Render metric. output$metricBox_ui <- renderUI({ req(title, desc) @@ -68,16 +67,17 @@ metricBoxServer <- function(id, title, desc, value, score = "NULL", title = if_else(stringr::str_extract(session$ns(id), "\\w+") != "databaseView" & !title %in% metric$long_name, paste0(title, "*"), title) + # define some styles prior to building card card_style <- "max-width: 400px; max-height: 250px; padding-left: 5%; padding-right: 5%;" # overflow-y: scroll; auto_font_out <- auto_font(value, txt_max = val_max_nchar, size_min = .85, size_max = 1.5 ) # , num_bins = 3 - body_p_style <- glue::glue("font-size: {auto_font_out}vw;") - # build the html card + + # Build the card's metric visual - either an icon or a meter if(score == "NULL" | # usually for non-riskmetric cards (like on comm or database tab) # riskmetric cards, both value and score must be missing to show an icon # if value is missing, but score isn't, then we need to show a meter @@ -96,25 +96,12 @@ metricBoxServer <- function(id, title, desc, value, score = "NULL", style = "padding-top: 40%; font-size:60px; padding-left: 20%;" ) } - } else { # use html version (displaying riskmetric score on a meter) - display_obj <- - div(style = "padding-top: 30%; padding-left: 10%;", - metric_gauge(score = score) - ) - } - if (title %in% c("Dependencies","Reverse Dependencies")){ # for dependencies/rev dep cards alone - link_button <- a(class="stretched-link", - # style = "position: relative;", - title = "Click for more details", - onclick = sprintf('(function () { - Shiny.setInputValue("%s", new Date().getTime()); - }());', NS(id,"dep_click"))) - } - else { - link_button <- NULL + display_obj <- div(style = "padding-top: 30%; padding-left: 10%;", + metric_gauge(score = score)) } + # Build HTML Card html_component <- div( class = "card mb-3 text-center border-info", style = card_style, div( @@ -124,7 +111,6 @@ metricBoxServer <- function(id, title, desc, value, score = "NULL", display_obj ), div( - link_button, class = "col-md-8", h5( class = "card-header bg-transparent", style = "font-size: 1vw", @@ -138,12 +124,16 @@ metricBoxServer <- function(id, title, desc, value, score = "NULL", div(class = "card-footer bg-transparent", desc) )) - + # Turn certain metric cards into hyperlinks that redirect to another tab (dependencies tab) if (title %in% c("Dependencies","Reverse Dependencies")){ - html_component <- shiny::tagAppendAttributes(html_component, - onMouseOver="this.style['box-shadow'] = '2px 2px 2px black'; - this.style['cursor'] = 'pointer'", - onMouseOut="this.style['box-shadow'] = 'none'") + html_component <- shiny::tagAppendAttributes( + html_component, + style = "--cursor: pointer; cursor: var(--cursor)", + onMouseOver="this.style['box-shadow'] = '2px 2px 2px black'", + onMouseOut="this.style['box-shadow'] = 'none'", + onclick = sprintf('(function () { + Shiny.setInputValue("%s", new Date().getTime()); + }());', NS(id,"dep_click"))) } else { html_component