# NOT RUN {
## ------------------------------------------------
## Method `Linne$define`
## ------------------------------------------------
Linne$new()$define(baseColor = "blue")
## ------------------------------------------------
## Method `Linne$rule`
## ------------------------------------------------
Linne$new()$rule(sel_id("myButton"), color = "blue", fontSize = 50)
## ------------------------------------------------
## Method `Linne$build`
## ------------------------------------------------
Linne$
new()$
define(primary_color = 'red')$
rule(
sel_id("myButton"),
color = primary_color,
fontSize = 50
)$
rule(
sel_class("container"),
backgroundColor = primary_color
)$
build()
## ------------------------------------------------
## Method `Linne$get_css`
## ------------------------------------------------
Linne$new()$rule(sel_id("myId"), fontSize = 20)$get_css()
## ------------------------------------------------
## Method `Linne$show_css`
## ------------------------------------------------
Linne$new()$rule(sel_id("myButton"), color = "blue")$show_css()
## ------------------------------------------------
## Method `Linne$import`
## ------------------------------------------------
Linne$new()$import('https://fonts.googleapis.com/css2?family=Roboto')
## ------------------------------------------------
## Method `Linne$include`
## ------------------------------------------------
# generate CSS
css <- Linne$
new()$
define(grey = '#c4c4c4')$
rule(
sel_id("myButton"),
backgroundColor = 'red',
fontSize = 20,
color = grey
)$
rule(
sel_class("aClass"),
color = grey
)
# include in an app
library(shiny)
ui <- fluidPage(
css$include(),
h1("Some text", class = "aClass"),
actionButton("myButton", "Am I red?", class = "aClass")
)
server <- function(input, output){
output$myPlot <- renderPlot(plot(cars))
}
if(interactive())
shinyApp(ui, server)
## ------------------------------------------------
## Method `Linne$write`
## ------------------------------------------------
if(interactive())
Linne$new()$rule(sel_id("id"), fontStyle = "italic")$write("styles.css")
## ------------------------------------------------
## Method `Linne$inject`
## ------------------------------------------------
library(shiny)
ui <- fluidPage(
useLinne(),
actionButton("change", "Change me!")
)
server <- function(input, output){
linne <- Linne$
new()$
rule(
sel_id("change"),
color = "white",
backgroundColor = "black"
)
observeEvent(input$change, {
linne$inject()
})
}
if(interactive())
shinyApp(ui, server)
# }
Run the code above in your browser using DataLab