Skip to content

Commit

Permalink
Merge pull request #8 from pierina-ixpantia/T7
Browse files Browse the repository at this point in the history
Adds top 3
  • Loading branch information
andyquinterom authored Jun 14, 2024
2 parents e1b6070 + 9d206df commit 2303d03
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ box::use(

box::use(
. / table,
./ selectors
. / selectors,
. / top_3
)

#' @export
Expand Down Expand Up @@ -34,6 +35,7 @@ ui <- function(id) {
class = "row px-4 pt-4",
div(
class = "col-3",
top_3$ui(ns("top_3")),
selectors$ui(ns("selectors"))
),
div(
Expand All @@ -49,6 +51,7 @@ ui <- function(id) {
server <- function(id) {
moduleServer(id, function(input, output, session) {
selectors <- selectors$server("selectors")
top_3$server("top_3")
table$server("table",
selected_date = selectors$selected_date,
selected_packages = selectors$selected_package)
Expand Down
57 changes: 57 additions & 0 deletions src/R/top_3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
box::use(
shiny[NS, tagList, h1, h5, div, moduleServer, textOutput, renderText],
cranlogs[cran_top_downloads]
)

top_3 <- cran_top_downloads(when = "last-day",
count = 3)$package

#' @export
ui <- function(id) {
ns <- NS(id)
tagList(
div(
style = "margin-bottom: 10px; border: 2px solid #ccc; padding: 20px;
text-align: center; margin-top: 20px;",
h5(style = "font-weight: bold;", "🌟 Today's Top 3:"),
div(
style = "display: grid; grid-template-columns: 1fr;
grid-template-rows: auto auto;",
div(
style = "text-align: center; margin: 10px;",
h1("🥇"),
h5(style = "margin-top: 0;", textOutput(ns("package1")))
),
div(
style = "display: grid; grid-template-columns: 1fr 1fr;
grid-template-rows: auto;",
div(
style = "text-align: center; margin: 10px;",
h1("🥈"),
h5(style = "margin-top: 0;", textOutput(ns("package2")))
),
div(
style = "text-align: center; margin: 10px;",
h1("🥉"),
h5(style = "margin-top: 0;", textOutput(ns("package3")))
)
)
)
)
)
}

#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
output$package1 <- renderText({
top_3[1]
})
output$package2 <- renderText({
top_3[2]
})
output$package3 <- renderText({
top_3[3]
})
})
}

0 comments on commit 2303d03

Please sign in to comment.