Skip to content

Commit

Permalink
cleanup R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Aug 28, 2023
1 parent 0cb2efc commit 9449da1
Show file tree
Hide file tree
Showing 35 changed files with 148 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ $run_dev.*
^app\.R$
^rsconnect$
^\.github$
^\.lintr$
^R/_disable_autoload\.R$
File renamed without changes.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
)
)
Expand Down Expand Up @@ -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';
}"
)
)
}
22 changes: 22 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -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 <https://pokeapi.co/docs/v2>
"poke_data"
3 changes: 3 additions & 0 deletions R/shinyMons2-package.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -200,3 +203,7 @@ select_pokemon <- function(selected) {
poke_data[[selected]]
}
}

# R CMD check ...
globalVariables("poke_data")

11 changes: 5 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<group_ID>` (1 per group!).
2. Run `renv::restore()`.
3. Ready to start?
1. Group lead: Create a new branch named `<group_ID>` (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.

Expand All @@ -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).
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<group_ID>` (1 per group!).
2. Run `renv::restore()`.
3. Ready to start?
1. Group lead: Create a new branch named `<group_ID>` (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.
Expand All @@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions man/poke_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/shinyMons2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9449da1

Please sign in to comment.