diff --git a/inst/showcase/app.R b/inst/showcase/app.R index 56fae0c..394b724 100644 --- a/inst/showcase/app.R +++ b/inst/showcase/app.R @@ -39,7 +39,8 @@ ui <- nextui_page( ) ) ) - ) + ), + reactOutput("no_pokemon_modal") ) server <- function(input, output, session) { @@ -47,6 +48,31 @@ server <- function(input, output, session) { 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, reactive(input$theme)) + + modalVisible <- reactiveVal(FALSE) + observeEvent(main$select_state(), { + if (is.null(main$select_state())) modalVisible(TRUE) + }, ignoreNULL = FALSE, ignoreInit = TRUE) + + observeEvent(input$modal_closed, { + modalVisible(FALSE) + }) + + output$no_pokemon_modal <- renderReact({ + modal( + scrollBehavior = input$scroll, + isOpen = modalVisible(), + size = "sm", + backdrop = "blur", + onClose = JS( + "() => Shiny.setInputValue('modal_closed', true, {priority: 'event'}) + "), + modal_content( + modal_header("Oups, no pokemon is selected ..."), + modal_body("Select a pokemon to see the data!") + ) + ) + }) } shinyApp(ui, server) diff --git a/inst/showcase/modules/mod_poke_move.R b/inst/showcase/modules/mod_poke_move.R index 7b1caaf..da48b7a 100644 --- a/inst/showcase/modules/mod_poke_move.R +++ b/inst/showcase/modules/mod_poke_move.R @@ -35,7 +35,15 @@ mod_poke_move_server <- function(id, selected, theme) { }, pp = move$pp, priority = move$priority, - accuracy = move$accuracy, + accuracy = if (is.na(move$accuracy)) { + "NA" + } else { + progress( + value = move$accuracy, + maxValue = 100, + showValueLabel = TRUE + ) + }, text = move$text ) }) diff --git a/inst/showcase/modules/mod_poke_select.R b/inst/showcase/modules/mod_poke_select.R index 24d7ebf..e4461d5 100644 --- a/inst/showcase/modules/mod_poke_select.R +++ b/inst/showcase/modules/mod_poke_select.R @@ -55,7 +55,8 @@ mod_poke_select_server <- function(id) { return( list( selected = selected_pokemon, - is_shiny = reactive(input$is_shiny) + is_shiny = reactive(input$is_shiny), + select_state = reactive(input$selected) ) ) }) diff --git a/inst/showcase/modules/mod_poke_stats.R b/inst/showcase/modules/mod_poke_stats.R index 0fd680b..d90f6af 100644 --- a/inst/showcase/modules/mod_poke_stats.R +++ b/inst/showcase/modules/mod_poke_stats.R @@ -1,5 +1,6 @@ other_stats_names <- function() { - names(poke_data[[1]]$other_stats) + #names(poke_data[[1]]$other_stats) + c("height", "weight", "capture_rate") } extra_from_list <- function(l, key = "name", type = character(1)) { @@ -171,7 +172,7 @@ mod_poke_stats_server <- function(id, selected, theme) { # card wrapper for the charts output$poke_stats_card <- renderUI({ req(!is.null(selected())) - echarts4rOutput(outputId = ns("poke_stats"), height = "700px") + echarts4rOutput(outputId = ns("poke_stats")) }) }) }