Skip to content

Instantly share code, notes, and snippets.

@jtrecenti
Created October 27, 2022 21:54
Show Gist options
  • Save jtrecenti/85453d66041af6fcc58eaa513f93dee9 to your computer and use it in GitHub Desktop.
Save jtrecenti/85453d66041af6fcc58eaa513f93dee9 to your computer and use it in GitHub Desktop.
# remotes::install_github("rstudio/shiny")
# remotes::install_github("rstudio/bslib@dev")
# remotes::install_github("rstudio/bsicons")
library(shiny)
library(bslib)
library(bsicons)
card1 <- navs_tab_card(
title = "HTML Widgets",
nav(
"Plotly",
card_title("A plotly plot"),
card_body_fill(plotly::plotlyOutput("g1"))
),
nav(
"Leaflet",
card_title("A leaflet plot"),
card_body_fill(leaflet::leafletOutput("m1"))
),
nav(
shiny::icon("circle-info"),
"Learn more about",
tags$a("htmlwidgets", href = "http://www.htmlwidgets.org/")
)
)
card2 <- navs_pill_card(
title = "HTML Widgets",
nav(
"Plotly",
card_title("A plotly plot"),
card_body_fill(plotly::plotlyOutput("g2"))
),
nav(
"Leaflet",
card_title("A leaflet plot"),
card_body_fill(leaflet::leafletOutput("m2"))
),
nav(
shiny::icon("circle-info"),
"Learn more about",
tags$a("htmlwidgets", href = "http://www.htmlwidgets.org/")
)
)
card3 <- card(
card_header(
class = "bg-dark",
"A header"
),
card_body(
markdown("Some text with a [link](https://github.com)")
)
)
card4 <- card(
card_header(
class = "bg-dark",
"Gráfico"
),
card_body_fill(plotly::plotlyOutput("g3"))
)
vbox1 <- value_box(
"Titulo",
markdown("Texto **muito** legal"),
span(
bsicons::bs_icon("arrow-up"),
" muito mais que antes!!"
),
showcase = bsicons::bs_icon("piggy-bank"),
class = "bg-success"
)
vbox2 <- value_box(
title = "Problemas",
value = "outros problemas",
showcase = bs_icon("music-note-beamed")
)
ui <- page_navbar(
title = "Observatório",
bg = "#20356b",
theme = bs_theme(version = 5),
nav(
"Aba 1",
layout_column_wrap(
1/4, vbox1, vbox2, vbox1, vbox2
),
br(),
layout_column_wrap(
width = 1/2, height = 300,
card1, card2
),
br(),
layout_column_wrap(
width = 1/2, height = 300,
card3, card3
)
),
nav("Aba 2", "Aba 2"),
nav_item(
tags$a(
icon("github"),
"GitHub",
href = "https://github.com/abjur",
target = "_blank"
)
),
nav_spacer(),
nav_menu(
"Mais links", align = "right",
nav("Aba 3!!!", "CONTEUDO"),
nav_item(
tags$a(
icon("sign-out"),
"Sair",
href = "https://abj.org.br", target = "_blank"
)
)
)
)
server <- function(input, output, session) {
# graficos de exemplo
plotly_widget <- plotly::plot_ly(x = ggplot2::diamonds$cut, color = "#20356b") |>
plotly::config(displayModeBar = FALSE) |>
plotly::layout(margin = list(t = 0, b = 0, l = 0, r = 0))
leaflet_widget <- leaflet::leaflet() |>
leaflet::addTiles()
output$g1 <- plotly::renderPlotly({
plotly_widget
})
output$g2 <- plotly::renderPlotly({
plotly_widget
})
output$g3 <- plotly::renderPlotly({
plotly_widget
})
output$m3 <- leaflet::renderLeaflet({
leaflet_widget
})
}
shiny::shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment