Debian Codegraph @

inst/sass-font/app.R

raw
1 library(shiny)
2 library(sass)
3 library(colourpicker)
4
5 ui <- fluidPage(
6 headerPanel("Sass Font Example"),
7 uiOutput("sass"),
8
9 sidebarPanel(
10 colourInput("color", "Background Color", value = "#6498d2",
11 showColour = "text")
12 ),
13
14 mainPanel(
15 plotOutput("distPlot"),
16 br()
17 ),
18
19 column(6, verbatimTextOutput("scssTxt"), verbatimTextOutput("sassFile")),
20 column(6, verbatimTextOutput("cssTxt"))
21 )
22
23 server <- function(input, output) {
24 output$distPlot <- renderPlot({
25 hist(rnorm(500))
26 })
27
28 variables <- reactive({
29 list(
30 color = input$color
31 )
32 })
33
34 sass_input <- reactive({
35 list(
36 variables(),
37 sass_file("sass-font.scss")
38 )
39 })
40 compiled_css <- reactive({
41 sass(sass_input())
42 })
43
44 output$sass <- renderUI({
45 tags$head(tags$style(compiled_css()))
46 })
47
48 output$scssTxt <- renderText({
49 paste0("/* Sass */\n", as_sass(sass_input()))
50 })
51 output$sassFile <- renderText({
52 paste0(
53 "/* sass-font.scss */\n\n",
54 paste0(readLines("sass-font.scss"), collapse = "\n")
55 )
56 })
57
58 output$cssTxt <- renderText({
59 paste0("/* Compiled CSS */\n", compiled_css())
60 })
61 }
62
63 shinyApp(ui, server)