I have some experience building R-Shiny apps but I'm new to material design. Stumbled across the shinymaterial package and it's great, however, missing some functionality that the shiny-bootstrap UI frameworks provide such as accordion/expansion panel.
There is material_card() in shinymaterial package to create card, I'm wondering if there is a way to add a bit of HTML to enable expand/collapse functionality for the material_card function, using tags$div for HTML and/or tags$script for js.
Here is my (sad) attempt below. See reprex:
library(shiny)
library(shinymaterial)
# Wrap shinymaterial apps in material_page
ui <- material_page(
title = "Basic Page + Side-Nav + Tabs",
# Place side-nav in the beginning of the UI
material_side_nav(
fixed = FALSE,
tags$h3("Side-Nav Content")
),
# Define tabs
material_row(
material_tabs(
tabs = c(
"First Tab" = "first_tab",
"Second Tab" = "second_tab"
)
),
material_column(width = 8,
# Define tab content
material_tab_content(
tab_id = "first_tab",
material_card(title = "mycard",
tags$h1("First Tab Content"),
tags$div(
HTML("<mat-card>
<mat-card-header>
<mat-card-title style='font-size: 20px;'>mycard</mat-card-title>
</mat-card-header>
<mat-card-content *ngIf='!collapsed'>
<p>This is some example text.</p>
<p>This text will disappear when you use the action button in the actions bar below.</p>
</mat-card-content>
<mat-card-actions>
<button mat-button (click)='collapsed=true'>Collapse text</button>
<button mat-button (click)='collapsed=false'>Uncollapse text</button>
</mat-card-actions>
</mat-card>")
)
)
),
material_tab_content(
tab_id = "second_tab",
material_card(title = NULL,
tags$h1("Second Tab Content")
)
)
),
material_column(width=4,
div(style='padding:15px;'),
material_tabs(
tabs = c(
"Third Tab" = "third_tab",
"Fourth Tab" = "fourth_tab"
)
),
material_tab_content(
tab_id = "third_tab",
material_card(title = NULL,
tags$h1("Third Tab Content")
)
),
material_tab_content(
tab_id = "fourth_tab",
material_card(title = NULL,
tags$h1("Fourth Tab Content")
)
)
)
)
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)