diff --git a/.Rbuildignore b/.Rbuildignore index 2eaa305..dbac8d9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,5 @@ $run_dev.* ^app\.R$ ^rsconnect$ ^\.github$ +^\.lintr$ +^R/_disable_autoload\.R$ diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE diff --git a/NAMESPACE b/NAMESPACE index 5edcbca..2d7a31e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ importFrom(golem,add_resource_path) importFrom(golem,bundle_resources) importFrom(golem,favicon) importFrom(golem,with_golem_options) +importFrom(pkgload,load_all) importFrom(shiny,NS) importFrom(shiny,shinyApp) importFrom(shiny,tagList) diff --git a/R/app_server.R b/R/app_server.R index 6778b0c..948bb6c 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -5,6 +5,56 @@ #' @noRd app_server <- function(input, output, session) { # Your application server logic + ns <- session$ns() + + cancel_btn <- modalButton("cancel") + cancel_btn <- tagAppendAttributes( + cancel_btn, + class = "btn-success" + ) + + observeEvent(TRUE, { + showModal( + modalDialog( + title = "WeLCOME to the PoKeMON APP", + "Do you want to start the app!", + size = "s", + footer = tagList( + cancel_btn, + actionButton( + "continue", + "Continue", + class = "btn-danger", + `data-dismiss` = "modal" + ) + ) + ) + ) + }) + + observeEvent(input$continue, { + showModal( + modalDialog( + title = "The N1 poKemON APP IN THE WORLD!!!!", + size = "s", + "Please confirm", + footer = tagList( + modalButton("continue"), + actionButton( + "cancel", + "Cancel", + class = "btn-success", + `data-dismiss` = "modal" + ) + ) + ) + ) + }, priority = 10) + + observeEvent(input$cancel, { + session$reload() + }) + main <- mod_poke_select_server("poke_select_1") mod_poke_info_server("poke_info_1", main$selected, main$is_shiny) mod_poke_type_server("poke_type_1", main$selected) diff --git a/R/app_ui.R b/R/app_ui.R index f6cf1d9..9147878 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -25,7 +25,7 @@ app_ui <- function(request) { url = "https://pokeapi.co/static/logo-6221638601ef7fa7c835eae08ef67a16.png", status = "success", date = NULL, - "This app use pokeApi by Paul Hallet and PokéAPI contributors." + "This app use pokeApi by Paul Hallet and PokeAPI contributors." ) ) ) @@ -89,6 +89,16 @@ golem_add_external_resources <- function() { bundle_resources( path = app_sys("app/www"), app_title = "shinyMons2" + ), + # custom font setup + tags$link( + href = "https://fonts.googleapis.com/css?family=Press+Start+2P", + rel = "stylesheet" + ), + tags$style( + "html, body, pre, code, kbd, samp { + font-family: 'Press Start 2P'; + }" ) ) } diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..de1ca7f --- /dev/null +++ b/R/data.R @@ -0,0 +1,22 @@ +#' Pokemon API data +#' +#' Extract of some data from the 151 first Pokemons. +#' +#' @format ## `poke_data` +#' A nested list with 151 entries. Each sublist contains: +#' \describe{ +#' \item{name}{Char: Pokemon name.} +#' \item{description}{Char: Pokemon description.} +#' \item{shape}{Char: Pokemon shape.} +#' \item{sprites}{List: Front and back sprites (images).} +#' \itemize{ +#' \item{front_default}{Char: front sprite URL} +#' \item{shiny_default}{Char: front sprite URL (shiny form)} +#' } +#' \item{habitat}{Char: Pokemon habitat.} +#' ... +#' } +#' @note Have a look to inst/app-doc/data-doc.html to get an +#' interactive overview. +#' @source +"poke_data" diff --git a/R/shinyMons2-package.R b/R/shinyMons2-package.R index 5104fe7..35a783f 100644 --- a/R/shinyMons2-package.R +++ b/R/shinyMons2-package.R @@ -1,9 +1,12 @@ #' shinyMons2 #' +#' All the first generation Pokemon data in a shiny app. +#' #' @name shinyMons2 #' @import shiny #' @import tablerDash #' @import echarts4r +#' @importFrom pkgload load_all #' @importFrom shinyWidgets pickerInput prettySwitch #' @importFrom dplyr as_tibble summarise across all_of rowwise pull #' @docType package diff --git a/R/utils.R b/R/utils.R index 494c08e..ef646e1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -122,6 +122,9 @@ get_max_of_max <- function(data = get_max_stats()) { #' @return A chart htmlwidget. #' @export create_radar_stats <- function(pokemon) { + # R CMD check stop crying ... + x <- y <- z <- NULL + stats <- pokemon$stats # Prepare data data <- process_pokemon_stats(stats) @@ -200,3 +203,7 @@ select_pokemon <- function(selected) { poke_data[[selected]] } } + +# R CMD check ... +globalVariables("poke_data") + diff --git a/README.Rmd b/README.Rmd index aac9e7a..f2f1cf6 100644 --- a/README.Rmd +++ b/README.Rmd @@ -25,11 +25,10 @@ This project is hosted on Posit Cloud in this [space](https://posit.cloud/spaces ## Work instructions -Each one of you will be working in a group, an ID will be assigned to you prior to the workshop. Therefore, only one person/group will have to commit the code to GitHub. Group leads will be randomly assigned prior to the workshop and communicated to you. +Each one of you will be working in a group, an ID will be assigned to you prior to the workshop. Group leads will be randomly assigned prior to the workshop and communicated to you. Therefore, only one person/group will have to commit the code to GitHub. -1. Create a new branch named `` (1 per group!). -2. Run `renv::restore()`. -3. Ready to start? +1. Group lead: Create a new branch named `` (1 per group!). +2. Anyone: Run `renv::restore()`. Please remember that you can run `styler::style_pkg()` and `devtools::lint()` so the code style stays consistent. @@ -49,9 +48,9 @@ Please remember that you can run `styler::style_pkg()` and `devtools::lint()` so ## App structure -This app leveraging `{golem}` is composed of 6 modules. The main module is `mod_poke_select`, which returns the selected pokemon (picker input) as well as its variant (shiny or not). Those data are passed to other modules. General pokemon data, namely `poke_data`, have been pre-processed for you so you don't have to focus on the data wrangling but the UI design (This also avoids us to flood the underlying API with too many requests). +This app leveraging `{golem}` is composed of 6 modules. The main module is `mod_poke_select`, which returns the selected Pokemon (picker input) as well as its variant (shiny or not). Those data are passed to other modules. General Pokemon data, namely `poke_data`, have been pre-processed for you so you don't have to focus on the data wrangling but the UI design (This also avoids us to flood the underlying API with too many requests). -If you're more curious, browse to `inst/doc` and have a look to: +If you're more curious, browse to `inst/app-doc` and have a look to: - `data-doc.html`: htmlwidget showing the data structure for the first pokemon, so you get an idea on what is available to you. - `flow`: app module structure, powered by [`{flow}`](https://github.com/moodymudskipper/flow). diff --git a/README.md b/README.md index ca1f46a..e1fdb14 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,12 @@ and deployed [here](https://dgranjon.shinyapps.io/shinyMonsUgly). ## Work instructions Each one of you will be working in a group, an ID will be assigned to -you prior to the workshop. Therefore, only one person/group will have to -commit the code to GitHub. Group leads will be randomly assigned prior -to the workshop and communicated to you. +you prior to the workshop. Group leads will be randomly assigned prior +to the workshop and communicated to you. Therefore, only one +person/group will have to commit the code to GitHub. -1. Create a new branch named `` (1 per group!). -2. Run `renv::restore()`. -3. Ready to start? +1. Group lead: Create a new branch named `` (1 per group!). +2. Anyone: Run `renv::restore()`. Please remember that you can run `styler::style_pkg()` and `devtools::lint()` so the code style stays consistent. @@ -53,14 +52,14 @@ Please remember that you can run `styler::style_pkg()` and ## App structure This app leveraging `{golem}` is composed of 6 modules. The main module -is `mod_poke_select`, which returns the selected pokemon (picker input) +is `mod_poke_select`, which returns the selected Pokemon (picker input) as well as its variant (shiny or not). Those data are passed to other -modules. General pokemon data, namely `poke_data`, have been +modules. General Pokemon data, namely `poke_data`, have been pre-processed for you so you don’t have to focus on the data wrangling but the UI design (This also avoids us to flood the underlying API with too many requests). -If you’re more curious, browse to `inst/doc` and have a look to: +If you’re more curious, browse to `inst/app-doc` and have a look to: - `data-doc.html`: htmlwidget showing the data structure for the first pokemon, so you get an idea on what is available to you. diff --git a/inst/doc/data-doc.html b/inst/app-doc/data-doc.html similarity index 100% rename from inst/doc/data-doc.html rename to inst/app-doc/data-doc.html diff --git a/inst/doc/data-doc_files/htmlwidgets-1.6.2/htmlwidgets.js b/inst/app-doc/data-doc_files/htmlwidgets-1.6.2/htmlwidgets.js similarity index 100% rename from inst/doc/data-doc_files/htmlwidgets-1.6.2/htmlwidgets.js rename to inst/app-doc/data-doc_files/htmlwidgets-1.6.2/htmlwidgets.js diff --git a/inst/doc/data-doc_files/jsonedit-binding-3.0.0/jsonedit.js b/inst/app-doc/data-doc_files/jsonedit-binding-3.0.0/jsonedit.js similarity index 100% rename from inst/doc/data-doc_files/jsonedit-binding-3.0.0/jsonedit.js rename to inst/app-doc/data-doc_files/jsonedit-binding-3.0.0/jsonedit.js diff --git a/inst/doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.png b/inst/app-doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.png similarity index 100% rename from inst/doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.png rename to inst/app-doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.png diff --git a/inst/doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.svg b/inst/app-doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.svg similarity index 100% rename from inst/doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.svg rename to inst/app-doc/data-doc_files/jsoneditor-5.25.6/img/jsoneditor-icons.svg diff --git a/inst/doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.css b/inst/app-doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.css similarity index 100% rename from inst/doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.css rename to inst/app-doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.css diff --git a/inst/doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.js b/inst/app-doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.js similarity index 100% rename from inst/doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.js rename to inst/app-doc/data-doc_files/jsoneditor-5.25.6/jsoneditor.min.js diff --git a/inst/doc/flow/app-structure.pdf b/inst/app-doc/flow/app-structure.pdf similarity index 100% rename from inst/doc/flow/app-structure.pdf rename to inst/app-doc/flow/app-structure.pdf diff --git a/inst/doc/reactlog/reactlog.html b/inst/app-doc/reactlog/reactlog.html similarity index 100% rename from inst/doc/reactlog/reactlog.html rename to inst/app-doc/reactlog/reactlog.html diff --git a/inst/doc/reactlog/reactlogAsset/fira-mono_source-sans-pro_latin-ext.css b/inst/app-doc/reactlog/reactlogAsset/fira-mono_source-sans-pro_latin-ext.css similarity index 100% rename from inst/doc/reactlog/reactlogAsset/fira-mono_source-sans-pro_latin-ext.css rename to inst/app-doc/reactlog/reactlogAsset/fira-mono_source-sans-pro_latin-ext.css diff --git a/inst/doc/reactlog/reactlogAsset/images/iconSearch.svg b/inst/app-doc/reactlog/reactlogAsset/images/iconSearch.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/iconSearch.svg rename to inst/app-doc/reactlog/reactlogAsset/images/iconSearch.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/next-end.svg b/inst/app-doc/reactlog/reactlogAsset/images/next-end.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/next-end.svg rename to inst/app-doc/reactlog/reactlogAsset/images/next-end.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/next-idle.svg b/inst/app-doc/reactlog/reactlogAsset/images/next-idle.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/next-idle.svg rename to inst/app-doc/reactlog/reactlogAsset/images/next-idle.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/next-mark.svg b/inst/app-doc/reactlog/reactlogAsset/images/next-mark.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/next-mark.svg rename to inst/app-doc/reactlog/reactlogAsset/images/next-mark.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/next-output-calc.svg b/inst/app-doc/reactlog/reactlogAsset/images/next-output-calc.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/next-output-calc.svg rename to inst/app-doc/reactlog/reactlogAsset/images/next-output-calc.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/next-step.svg b/inst/app-doc/reactlog/reactlogAsset/images/next-step.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/next-step.svg rename to inst/app-doc/reactlog/reactlogAsset/images/next-step.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/prev-idle.svg b/inst/app-doc/reactlog/reactlogAsset/images/prev-idle.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/prev-idle.svg rename to inst/app-doc/reactlog/reactlogAsset/images/prev-idle.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/prev-mark.svg b/inst/app-doc/reactlog/reactlogAsset/images/prev-mark.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/prev-mark.svg rename to inst/app-doc/reactlog/reactlogAsset/images/prev-mark.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/prev-output-calc.svg b/inst/app-doc/reactlog/reactlogAsset/images/prev-output-calc.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/prev-output-calc.svg rename to inst/app-doc/reactlog/reactlogAsset/images/prev-output-calc.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/prev-start.svg b/inst/app-doc/reactlog/reactlogAsset/images/prev-start.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/prev-start.svg rename to inst/app-doc/reactlog/reactlogAsset/images/prev-start.svg diff --git a/inst/doc/reactlog/reactlogAsset/images/prev-step.svg b/inst/app-doc/reactlog/reactlogAsset/images/prev-step.svg similarity index 100% rename from inst/doc/reactlog/reactlogAsset/images/prev-step.svg rename to inst/app-doc/reactlog/reactlogAsset/images/prev-step.svg diff --git a/inst/doc/reactlog/reactlogAsset/reactlog.css b/inst/app-doc/reactlog/reactlogAsset/reactlog.css similarity index 100% rename from inst/doc/reactlog/reactlogAsset/reactlog.css rename to inst/app-doc/reactlog/reactlogAsset/reactlog.css diff --git a/inst/doc/reactlog/reactlogAsset/reactlog.js b/inst/app-doc/reactlog/reactlogAsset/reactlog.js similarity index 100% rename from inst/doc/reactlog/reactlogAsset/reactlog.js rename to inst/app-doc/reactlog/reactlogAsset/reactlog.js diff --git a/man/poke_data.Rd b/man/poke_data.Rd new file mode 100644 index 0000000..ba35bdc --- /dev/null +++ b/man/poke_data.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{poke_data} +\alias{poke_data} +\title{Pokemon API data} +\format{ +## `poke_data` +A nested list with 151 entries. Each sublist contains: +\describe{ + \item{name}{Char: Pokemon name.} + \item{description}{Char: Pokemon description.} + \item{shape}{Char: Pokemon shape.} + \item{sprites}{List: Front and back sprites (images).} + \itemize{ + \item{front_default}{Char: front sprite URL} + \item{shiny_default}{Char: front sprite URL (shiny form)} + } + \item{habitat}{Char: Pokemon habitat.} + ... +} +} +\source{ + +} +\usage{ +poke_data +} +\description{ +Extract of some data from the 151 first Pokemons. +} +\note{ +Have a look to inst/app-doc/data-doc.html to get an +interactive overview. +} +\keyword{datasets} diff --git a/man/shinyMons2.Rd b/man/shinyMons2.Rd index 91f3289..0ec5070 100644 --- a/man/shinyMons2.Rd +++ b/man/shinyMons2.Rd @@ -4,3 +4,6 @@ \name{shinyMons2} \alias{shinyMons2} \title{shinyMons2} +\description{ +All the first generation Pokemon data in a shiny app. +}