The basic scaffold is minimal, though it will suit most use cases.
If more features are needed one can use the use_*
family
of functions.
These functions add features but often dependencies too.
You can easily include sass to easily style your applications.
leprechaun::use_sass()
✔ Creating scss
✔ Creating inst/dev/sass.R
✔ Adding 'sass' to Suggests in DESCRIPTION
✔ Adding '^scss$' to '.Rbuildignore'
! This requires `leprechaun::build()`
This creates a directory scss
with two .scss
files within it.
Importantly it adds a script to inst/dev
to generate the CSS.
Requires running leprechaun::build()
Suggests:
If you want to make use of a config file there is a feature for it. It adds a basic config file and helper functions to interact with it.
leprechaun::use_config()
✔ Creating inst/config.R
✔ Creating inst/config.yml
✔ Adding 'yaml' to Imports in DESCRIPTION
Imports:
The function leprechaun::use_js_utils()
adds useful
JavaScript functions to your projects.
Requires a packer scaffold in place.
These include function show or hide an element from the DOM and more.
leprechaun::use_packer()
✔ Creating inst/dev/packer.R
✔ Adding 'packer' to Suggests in DESCRIPTION
! This requires `leprechaun::build()`
This will add functions such as show
, hide
, and toggle
to control the visibility of elements.
library(shiny)
ui <- fluidPage(
actionButton("toggle", "Toggle"),
p(id = "element", "Hello", style = "display:none;")
)
server <- function(input, output, session){
observeEvent(input$toggle, {
toggle("element")
})
}
shinyApp(ui, server)
Requires running leprechaun::build()
Suggests:
Requires a packer scaffold in place and leprechaun::use_packer()
This adds JavaScript utility functions to, for example, show/hide an element from the R server.
packer::scaffold_leprechaun(edit = FALSE)
use_packer()
use_js_utils()
You can add HTML utility functions with use_html_utils
.
leprechaun::use_html_utils()
✔ Adding 'htmltools' to Imports in DESCRIPTION
✔ Creating R/html-utils.R
This includes functions to create columns, badges, etc.
fluidRow(
col4(badge("hello")),
col8("world")
)
Imports:
There is also a set of functions to help set up session-dependent endpoints.
leprechaun::use_endpoints_utils()
✔ Adding 'jsonlite' to Imports in DESCRIPTION
✔ Creating R/endpoint-utils.R
This adds a file with utility functions to generate endpoints.
Imports:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.