We're in for 20 minutes of fun!
David
Senior Expert Data Scientist, Novartis
{Shiny} is about 10 years old ๐ฒ๐ฒ๐ฒ. 


111 lines of CSS.
29 lines of JavaScript code.
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
36 lines of R code ({wavesurfer} htmlWidget).
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
36 lines of R code ({wavesurfer} htmlWidget).
Few custom HTML tags.
Tweak apps style with CSS and Sass
{sass}.{bslib} and {fresh}.Unleash app interactivity with JavaScript (JS)
{packer}.Create a new template from scratch
{charpente}. Sorry I don't have time ...
{truelle}.
CSS stands for Cascading Style Sheets,
selector { property: value;}tags$style( "p { color: red; } ")

An R interface exists: {sass}.
install.packages("sass")
library(sass)rule1 <- ".class-1{ color: $color; }"rule2 <- ".class-2{ background-color: $color; }"sass(input = list(color = "purple", rule1, rule2))
#> /* CSS */#> .class-1 {#> color: purple;#> }#> #> .class-2 {#> background-color: purple;#> }sass( list( a = 2, b = 4, "@function multiply($parm1, $parm2) { @debug 'parm1 is #{$parm1}'; @debug 'parm2 is #{$parm2}'; @return $parm1 * $parm2; }", ".my-class { width: multiply($a, $b) * 1px; }" ))
stdin:4 DEBUG: parm1 is 2stdin:5 DEBUG: parm2 is 4#> /* CSS */#> .my-class {#> width: 8px;#> }sass(input = list( colors = c("green", "red"), "@each $color in $colors { .alert-#{$color} { color: $color; } }"))
#> .alert-green {#> color: green;#> }#> #> .alert-red {#> color: red;#> }# CSS to include in your appcss <- sass( sass_layer( defaults = list( turquoise = "#03a4ff", cyan = "#e705be", green = "#f3d6e9", yellow = "#fdaf2c", red = "#ff483e", "scheme-main" = "hsl(0, 0%, 10%)" ), rules = sass_file( input = system.file( "sass/bulma/bulma.sass", package = "OSUICode" ) ) ))
{sass}.{shiny}, {shinydashboard}, ...install.packages("fresh")
{sass}.{shiny}, {shinydashboard}, ...install.packages("fresh")
{sass}.{shiny}.install.packages("bslib")
library(fresh)dark_theme <- create_theme( bs4dash_vars( navbar_light_color = "#bec5cb", navbar_light_active_color = "#FFF", navbar_light_hover_color = "#FFF" ), bs4dash_yiq( contrasted_threshold = 10, text_dark = "#FFF", text_light = "#272c30" ), bs4dash_layout(main_bg = "#353c42"), bs4dash_sidebar_dark( bg = "#272c30", color = "#bec5cb", hover_color = "#FFF", submenu_bg = "#272c30", submenu_color = "#FFF", submenu_hover_color = "#FFF" ), bs4dash_status(dark = "#272c30"), bs4dash_color(gray_900 = "#FFF", white = "#272c30"))

library(bslib)bslib_neon_theme <- bs_theme( version = 4, bg = "#000000", fg = "#FFFFFF", primary = "#9600FF", secondary = "#1900A0", success = "#38FF12", info = "#00F5FB", warning = "#FFF100", danger = "#FF00E3", base_font = "Marker Felt", heading_font = "Marker Felt", code_font = "Chalkduster")bs_theme_preview(bslib_neon_theme, with_themer = FALSE)
Static plot (base R, ggplot2, ...) theming requires {thematic}.
Only 1 code base, 2 possible outputs ๐๏ธ
What can JS do for me โ
How do I include JS in my Shiny project โ
What are the best practices around JS code management โ
How do I include JS in my Shiny project โ
What are the best practices around JS code management โ
Let's try to bring some answers ...
{usethis} for JavaScript/R projects.install.packages("packer")remotes::install_github("JohnCoene/packer")
We call:
golem::create_golem(...)packer::scaffold_golem(framework7 = TRUE)packer::bundle()
R in Pharma 2021 RinteRface workshop.
Advantages:
dummy_task <- reactive({ Sys.sleep(5) 12})output$custom_box <- renderUI({ dummy_task() box( title = "Box", width = dummy_task(), "Box body", background = input$background )})
dummy_task <- reactive({ Sys.sleep(5) 12})observeEvent(dummy_task(), { updateBox2( "mybox", action = "update", options = list( width = dummy_task(), title = tagList( shinydashboardPlus::dashboardBadge( "New", color = "red" ), "New title" ) ) )})
library(charpente)path <- file.path(tempdir(), "mypkg")create_charpente(path, license = "mit")# Once the package is created and opened# Look for all bulma flavorsget_dependency_versions("bulma")# Download bulma locallycreate_dependency("bulma")# Create JS handlercreate_custom_handler("modal")# Create input bindingcreate_input_binding("myinput")# Compress JS for productionbuild_js()devtools::load_all()
Built on top of Framework7.
We're in for 20 minutes of fun!
David
Senior Expert Data Scientist, Novartis
Keyboard shortcuts
| โ, โ, Pg Up, k | Go to previous slide |
| โ, โ, Pg Dn, Space, j | Go to next slide |
| Home | Go to first slide |
| End | Go to last slide |
| Number + Return | Go to specific slide |
| b / m / f | Toggle blackout / mirrored / fullscreen mode |
| c | Clone slideshow |
| p | Toggle presenter mode |
| t | Restart the presentation timer |
| ?, h | Toggle this help |
| o | Tile View: Overview of Slides |
| Alt + f | Fit Slides to Screen |
| Esc | Back to slideshow |
We're in for 20 minutes of fun!
David
Senior Expert Data Scientist, Novartis
{Shiny} is about 10 years old ๐ฒ๐ฒ๐ฒ. 


111 lines of CSS.
29 lines of JavaScript code.
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
36 lines of R code ({wavesurfer} htmlWidget).
111 lines of CSS.
29 lines of JavaScript code.
2 png images (dj gear + rotating wheel).
36 lines of R code ({wavesurfer} htmlWidget).
Few custom HTML tags.
Tweak apps style with CSS and Sass
{sass}.{bslib} and {fresh}.Unleash app interactivity with JavaScript (JS)
{packer}.Create a new template from scratch
{charpente}. Sorry I don't have time ...
{truelle}.
CSS stands for Cascading Style Sheets,
selector { property: value;}tags$style( "p { color: red; } ")

An R interface exists: {sass}.
install.packages("sass")
library(sass)rule1 <- ".class-1{ color: $color; }"rule2 <- ".class-2{ background-color: $color; }"sass(input = list(color = "purple", rule1, rule2))
#> /* CSS */#> .class-1 {#> color: purple;#> }#> #> .class-2 {#> background-color: purple;#> }sass( list( a = 2, b = 4, "@function multiply($parm1, $parm2) { @debug 'parm1 is #{$parm1}'; @debug 'parm2 is #{$parm2}'; @return $parm1 * $parm2; }", ".my-class { width: multiply($a, $b) * 1px; }" ))
stdin:4 DEBUG: parm1 is 2stdin:5 DEBUG: parm2 is 4#> /* CSS */#> .my-class {#> width: 8px;#> }sass(input = list( colors = c("green", "red"), "@each $color in $colors { .alert-#{$color} { color: $color; } }"))
#> .alert-green {#> color: green;#> }#> #> .alert-red {#> color: red;#> }# CSS to include in your appcss <- sass( sass_layer( defaults = list( turquoise = "#03a4ff", cyan = "#e705be", green = "#f3d6e9", yellow = "#fdaf2c", red = "#ff483e", "scheme-main" = "hsl(0, 0%, 10%)" ), rules = sass_file( input = system.file( "sass/bulma/bulma.sass", package = "OSUICode" ) ) ))
{sass}.{shiny}, {shinydashboard}, ...install.packages("fresh")
{sass}.{shiny}, {shinydashboard}, ...install.packages("fresh")
{sass}.{shiny}.install.packages("bslib")
library(fresh)dark_theme <- create_theme( bs4dash_vars( navbar_light_color = "#bec5cb", navbar_light_active_color = "#FFF", navbar_light_hover_color = "#FFF" ), bs4dash_yiq( contrasted_threshold = 10, text_dark = "#FFF", text_light = "#272c30" ), bs4dash_layout(main_bg = "#353c42"), bs4dash_sidebar_dark( bg = "#272c30", color = "#bec5cb", hover_color = "#FFF", submenu_bg = "#272c30", submenu_color = "#FFF", submenu_hover_color = "#FFF" ), bs4dash_status(dark = "#272c30"), bs4dash_color(gray_900 = "#FFF", white = "#272c30"))

library(bslib)bslib_neon_theme <- bs_theme( version = 4, bg = "#000000", fg = "#FFFFFF", primary = "#9600FF", secondary = "#1900A0", success = "#38FF12", info = "#00F5FB", warning = "#FFF100", danger = "#FF00E3", base_font = "Marker Felt", heading_font = "Marker Felt", code_font = "Chalkduster")bs_theme_preview(bslib_neon_theme, with_themer = FALSE)
Static plot (base R, ggplot2, ...) theming requires {thematic}.
Only 1 code base, 2 possible outputs ๐๏ธ
What can JS do for me โ
How do I include JS in my Shiny project โ
What are the best practices around JS code management โ
How do I include JS in my Shiny project โ
What are the best practices around JS code management โ
Let's try to bring some answers ...
{usethis} for JavaScript/R projects.install.packages("packer")remotes::install_github("JohnCoene/packer")
We call:
golem::create_golem(...)packer::scaffold_golem(framework7 = TRUE)packer::bundle()
R in Pharma 2021 RinteRface workshop.
Advantages:
dummy_task <- reactive({ Sys.sleep(5) 12})output$custom_box <- renderUI({ dummy_task() box( title = "Box", width = dummy_task(), "Box body", background = input$background )})
dummy_task <- reactive({ Sys.sleep(5) 12})observeEvent(dummy_task(), { updateBox2( "mybox", action = "update", options = list( width = dummy_task(), title = tagList( shinydashboardPlus::dashboardBadge( "New", color = "red" ), "New title" ) ) )})
library(charpente)path <- file.path(tempdir(), "mypkg")create_charpente(path, license = "mit")# Once the package is created and opened# Look for all bulma flavorsget_dependency_versions("bulma")# Download bulma locallycreate_dependency("bulma")# Create JS handlercreate_custom_handler("modal")# Create input bindingcreate_input_binding("myinput")# Compress JS for productionbuild_js()devtools::load_all()
Built on top of Framework7.