File: sass.R

package info (click to toggle)
r-cran-sass 0.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,012 kB
  • sloc: cpp: 29,639; ansic: 962; sh: 668; makefile: 321; perl: 56
file content (66 lines) | stat: -rw-r--r-- 2,082 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  message = FALSE,
  fig.align = "center",
  out.width = "80%",
  class.output = "css",
  comment = ""
)

## -----------------------------------------------------------------------------
library(sass)
variable <- "$body-bg: red;"
rule <- "body { background-color: $body-bg; }"
sass(input = list(variable, rule))

## -----------------------------------------------------------------------------
user_default <- list("body-bg" = "blue !default")
default <- list("body-bg" = "red !default")
sass(input = list(user_default, default, rule))

## -----------------------------------------------------------------------------
variable <- list("body-bg" = "rgba(black, 0.8)")
sass(input = list(variable, rule))

## -----------------------------------------------------------------------------
sass(
  list(
    variable,
    sass_file("color-contrast.scss"),
    "body {
      background-color: $body-bg;
      color: color-contrast($body-bg);
    }"
  )
)

## ---- eval=FALSE, ref.label='bs_sass'-----------------------------------------
#  NA

## ---- echo = FALSE, out.width='50%'-------------------------------------------
knitr::include_graphics('my-style.png')

## -----------------------------------------------------------------------------
layer1 <- sass_layer(
  defaults = list("body-bg" = "white !default"),
  declarations = sass_file("color-contrast.scss"),
  rules = "body{background-color: $body-bg; color: color-contrast($body-bg)}"
)
sass(layer1)

## -----------------------------------------------------------------------------
layer2 <- sass_layer(
  defaults = list("body-bg" = "white !default")
)
sass(sass_bundle(layer1, layer2))

## -----------------------------------------------------------------------------
sass(
  sass_file("my-style.scss"),
  options = sass_options(output_style = "compressed")
)

## ---- echo = FALSE------------------------------------------------------------
knitr::include_graphics("https://i.imgur.com/5cUEifg.gif")