Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bs_theme_preview): Add more DT features and more tables #671

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions inst/themer-demo/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ if (isTRUE(IS_LEGACY)) {
theme_set(theme_minimal())
}

bs_table <- function(x, class = NULL, ...) {
class <- paste(c("table", class), collapse = " ")
class <- sprintf('class="%s"', class)
HTML(knitr::kable(x, format = "html", table.attr = class))
}

shinyApp(
page_navbar(
theme = theme,
Expand Down Expand Up @@ -159,7 +165,22 @@ shinyApp(
),
nav_panel(
"Tables",
DT::dataTableOutput("DT")
tabsetPanel(
id = "tables",
tab(
"DataTables",
DT::dataTableOutput("DT")
),
tab(
"Bootstrap",
h3("Plain tables", class = "mt-2 mb-1"),
bs_table(mtcars[1:5, 1:5]),
h3("Striped tables", class = "mt-4 mb-1"),
bs_table(mtcars[1:5, 1:5], class = "table-striped"),
h3("Striped tables with hover", class = "mt-4 mb-1"),
bs_table(mtcars[1:5, 1:5], class = "table-striped table-hover")
)
)
),
nav_panel(
"Notifications",
Expand Down Expand Up @@ -247,7 +268,17 @@ shinyApp(
function(input, output, session) {

output$DT <- DT::renderDataTable({
DT::datatable(mtcars, style = "bootstrap4")
cars <- mtcars
for (var in c("cyl", "vs", "am", "gear", "carb")) {
cars[[var]] <- factor(cars[[var]])
}

DT::datatable(
cars,
style = "auto",
caption = "A generic table made with the DT package and the DataTables library.",
filter = "top"
)
})

output$inputPanelOutputHeader <- renderText({
Expand Down