Skip to content

Instantly share code, notes, and snippets.

@tylerlittlefield
Last active October 1, 2020 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerlittlefield/2c8b9ab003e13beacdfca48415431d90 to your computer and use it in GitHub Desktop.
Save tylerlittlefield/2c8b9ab003e13beacdfca48415431d90 to your computer and use it in GitHub Desktop.
Experimental "compartment" or container for shiny UI
compartment <- function(title, ...) {
container_css <- stringr::str_squish(
"border: 3px solid orange;
position: relative;
border-radius: 8px;
padding-top: 20px;
font-family: 'Fira Sans', sans-serif;
margin-top: 25px;
margin-bottom: 25px;"
)
label_css <- stringr::str_squish(
"font-family: 'Fira Sans', sans-serif;
font-size: 22px;
color: white;
position: absolute;
top: -10px;
left: 20px;
height: 35px;
background-color: orange;
border: 3px solid orange;
text-align: center;
border-radius: 4px;
padding-left: 10px;
padding-right: 10px;"
)
shiny::tagList(
shiny::tags$style(shiny::HTML(
"@import url('https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap');"
)),
shiny::tags$div(
style = container_css,
shiny::tags$div(
style = label_css,
title
),
...
)
)
}
htmltools::browsable(
fluidPage(
column(
width = 12,
compartment(
title = "Compartment A",
fluidPage(
h3("content here")
)
),
compartment(
title = "Compartment B",
fluidPage(
h3("content here")
)
),
compartment(
title = "Compartment C",
fluidPage(
h3("content here"),
h3("more content here")
)
)
)
)
)
@tylerlittlefield
Copy link
Author

tylerlittlefield commented Oct 1, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment