From 08aefbcb92375d38f5028ce7127ee0177ebe4dd8 Mon Sep 17 00:00:00 2001 From: DivadNojnarg Date: Wed, 15 Nov 2023 13:47:23 +0100 Subject: [PATCH] refine power column --- inst/showcase/app.R | 2 +- inst/showcase/modules/mod_poke_move.R | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/inst/showcase/app.R b/inst/showcase/app.R index f6daac8..56fae0c 100644 --- a/inst/showcase/app.R +++ b/inst/showcase/app.R @@ -46,7 +46,7 @@ server <- function(input, output, session) { main <- mod_poke_select_server("poke_select_1") mod_poke_info_server("poke_info_1", main$selected, main$is_shiny) mod_poke_stats_server("poke_stats_1", main$selected, reactive(input$theme)) - mod_poke_move_server("poke_move_1", main$selected) + mod_poke_move_server("poke_move_1", main$selected, reactive(input$theme)) } shinyApp(ui, server) diff --git a/inst/showcase/modules/mod_poke_move.R b/inst/showcase/modules/mod_poke_move.R index 6cc78c0..7b1caaf 100644 --- a/inst/showcase/modules/mod_poke_move.R +++ b/inst/showcase/modules/mod_poke_move.R @@ -3,7 +3,7 @@ mod_poke_move_ui <- function(id) { uiOutput(ns("poke_moves"), style = "max-height: 400px; overflow-y: scroll;") } -mod_poke_move_server <- function(id, selected) { +mod_poke_move_server <- function(id, selected, theme) { moduleServer(id, function(input, output, session) { ns <- session$ns @@ -15,17 +15,24 @@ mod_poke_move_server <- function(id, selected) { dat <- lapply(moves, function(move) { list( - name = chip(move$name), + name = move$name, type = chip( move$type, - style = sprintf("background: %s", get_type_colors(move$type)) - ), - power = progress( - value = move$power, - valueLabel = move$power, - maxValue = 150, - showValueLabel = TRUE + style = paste( + sprintf("background: %s", get_type_colors(move$type)), + if (move$type == "normal" && theme() == "dark") "text-color: white" + ) ), + power = if (is.na(move$power)) { + "NA" + } else { + progress( + value = move$power, + valueLabel = move$power, + maxValue = 150, + showValueLabel = TRUE + ) + }, pp = move$pp, priority = move$priority, accuracy = move$accuracy,