Просмотр исходного кода

Add extra_fonts paramater and template variable

tags/v0.1.1
Garrick Aden-Buie 8 лет назад
Родитель
Сommit
bd5b5ae00c
27 измененных файлов: 101 добавлений и 11 удалений
  1. +1
    -0
      R/duo.R
  2. +1
    -0
      R/duo_accent.R
  3. +1
    -0
      R/duo_accent_inverse.R
  4. +1
    -0
      R/mono_accent.R
  5. +1
    -0
      R/mono_accent_inverse.R
  6. +1
    -0
      R/mono_dark.R
  7. +1
    -0
      R/mono_light.R
  8. +1
    -0
      R/solarized_dark.R
  9. +1
    -0
      R/solarized_light.R
  10. +11
    -0
      R/write_extra_css.R
  11. +3
    -0
      R/write_theme.R
  12. +9
    -0
      README.Rmd
  13. +12
    -1
      README.md
  14. +1
    -0
      inst/resources/template.css
  15. +1
    -0
      inst/scripts/generate_theme_functions.R
  16. +2
    -0
      inst/scripts/write_xaringan_theme_body.R
  17. +3
    -0
      man-roxygen/extra_css.R
  18. +5
    -1
      man/duo.Rd
  19. +5
    -1
      man/duo_accent.Rd
  20. +5
    -1
      man/duo_accent_inverse.Rd
  21. +5
    -1
      man/mono_accent.Rd
  22. +5
    -1
      man/mono_accent_inverse.Rd
  23. +5
    -1
      man/mono_dark.Rd
  24. +5
    -1
      man/mono_light.Rd
  25. +5
    -1
      man/solarized_dark.Rd
  26. +5
    -1
      man/solarized_light.Rd
  27. +5
    -1
      man/write_xaringan_theme.Rd

+ 1
- 0
R/duo.R Просмотреть файл

@@ -95,6 +95,7 @@ duo <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/duo_accent.R Просмотреть файл

@@ -99,6 +99,7 @@ duo_accent <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/duo_accent_inverse.R Просмотреть файл

@@ -99,6 +99,7 @@ duo_accent_inverse <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/mono_accent.R Просмотреть файл

@@ -97,6 +97,7 @@ mono_accent <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/mono_accent_inverse.R Просмотреть файл

@@ -97,6 +97,7 @@ mono_accent_inverse <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/mono_dark.R Просмотреть файл

@@ -97,6 +97,7 @@ mono_dark <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/mono_light.R Просмотреть файл

@@ -97,6 +97,7 @@ mono_light <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/solarized_dark.R Просмотреть файл

@@ -91,6 +91,7 @@ solarized_dark <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 1
- 0
R/solarized_light.R Просмотреть файл

@@ -91,6 +91,7 @@ solarized_light <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R

+ 11
- 0
R/write_extra_css.R Просмотреть файл

@@ -63,3 +63,14 @@ list2css <- function(css) {
)
})
}

list2fonts <- function(fonts) {
fonts <- purrr::map_chr(fonts, function(f) {
if (inherits(f, "google_font")) {
f$url
} else if (inherits(f, "character")) {
f
} else NA_character_
})
paste0("@import url(", fonts[!is.na(fonts)], ");")
}

+ 3
- 0
R/write_theme.R Просмотреть файл

@@ -90,6 +90,7 @@ write_xaringan_theme <- function(
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco",
extra_css = NULL,
extra_fonts = NULL,
outfile = "xaringan-themer.css"
) {
# Make sure font names are wrapped in quotes if they have spaces
@@ -122,6 +123,8 @@ write_xaringan_theme <- function(
}
}
extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts)
tf <- system.file("resources", "template.css", package = "xaringanthemer")
template <- readLines(tf, warn = FALSE)
template <- paste(template, collapse = "\n")

+ 9
- 0
README.Rmd Просмотреть файл

@@ -257,6 +257,15 @@ solarized_dark(
)
```

If you need to import additional fonts for use in [custom CSS definitions](#adding-custom-css), you can use the `extra_fonts` argument to pass a list of URLs or `google_font()`s.

```r
mono_light(
extra_fonts = list(google_font("Sofia")),
extra_css = list(".title-slide h2" = list("font-family" = "Sofia"))
)
```

***

**xaringanthemer** was built by [Garrick Aden-Buie](https://www.garrickadenbuie.com) ([&commat;grrrck](https://twitter.com/grrrck)).

+ 12
- 1
README.md Просмотреть файл

@@ -170,7 +170,7 @@ Here are some of the `text_` theme options:
- `text_bold_color`
- `text_slide_number_color`
- `text_size`
- `text_size_h1`
- `text_slide_number_font_size`
- *and more …*

And here are the title slide theme options:
@@ -264,6 +264,17 @@ solarized_dark(
)
```

If you need to import additional fonts for use in [custom CSS
definitions](#adding-custom-css), you can use the `extra_fonts` argument
to pass a list of URLs or `google_font()`s.

``` r
mono_light(
extra_fonts = list(google_font("Sofia")),
extra_css = list(".title-slide h2" = list("font-family" = "Sofia"))
)
```

-----

**xaringanthemer** was built by [Garrick

+ 1
- 0
inst/resources/template.css Просмотреть файл

@@ -1,6 +1,7 @@
@import url({{text_font_url}});
@import url({{header_font_url}});
@import url({{code_font_url}});
{{extra_font_imports}}

body {
font-family: {{paste(text_font_family, text_font_family_fallback, text_font_base, sep = ", ")}};

+ 1
- 0
inst/scripts/generate_theme_functions.R Просмотреть файл

@@ -23,6 +23,7 @@ setup_theme_function <- function(
as.character(glue::glue_data(
tv, " {variable} = {ifelse(!stringr::str_detect(default, '^[{].+[}]$'), paste0('\"', default, '\"'), stringr::str_replace_all(default, '[{}]', ''))},")) %,%
" extra_css = NULL," %,%
" extra_fonts = NULL," %,%
" outfile = \"xaringan-themer.css\"" %,%
") {"
if (!is.null(body)) x <- c(x, body, "}")

+ 2
- 0
inst/scripts/write_xaringan_theme_body.R Просмотреть файл

@@ -28,6 +28,8 @@ for (var in f_args[grepl("font_google$", f_args)]) {
}
}

extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts)

tf <- system.file("resources", "template.css", package = "xaringanthemer")
template <- readLines(tf, warn = FALSE)
template <- paste(template, collapse = "\n")

+ 3
- 0
man-roxygen/extra_css.R Просмотреть файл

@@ -1,3 +1,6 @@
#' @param extra_css A named list of CSS definitions each containing a named list
#' of CSS property-value pairs, i.e.
#' \code{list(".class-id" = list("css-property" = "value"))}
#' @param extra_fonts A list of additional fonts to import, each list element
#' can be either a URL as a character string or a call to
#' \code{\link{google_fonts}()}

+ 5
- 1
man/duo.Rd Просмотреть файл

@@ -35,7 +35,7 @@ duo(primary_color = "#1F4257", secondary_color = "#F97B64",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{primary_color}{Duotone Primary Color, defaults to #1F4257}
@@ -132,6 +132,10 @@ duo(primary_color = "#1F4257", secondary_color = "#F97B64",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/duo_accent.Rd Просмотреть файл

@@ -39,7 +39,7 @@ duo_accent(primary_color = "#006747", secondary_color = "#CFC493",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{primary_color}{Duotone Primary Color, defaults to #006747}
@@ -140,6 +140,10 @@ duo_accent(primary_color = "#006747", secondary_color = "#CFC493",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/duo_accent_inverse.Rd Просмотреть файл

@@ -40,7 +40,7 @@ duo_accent_inverse(primary_color = "#006747", secondary_color = "#CFC493",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{primary_color}{Duotone Primary Color, defaults to #006747}
@@ -141,6 +141,10 @@ duo_accent_inverse(primary_color = "#006747", secondary_color = "#CFC493",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/mono_accent.Rd Просмотреть файл

@@ -34,7 +34,7 @@ mono_accent(base_color = "#43418A", white_color = "#FFFFFF",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{base_color}{Monotone Base Color, works best with a strong color., defaults to #43418A}
@@ -133,6 +133,10 @@ mono_accent(base_color = "#43418A", white_color = "#FFFFFF",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/mono_accent_inverse.Rd Просмотреть файл

@@ -34,7 +34,7 @@ mono_accent_inverse(base_color = "#3C989E", white_color = "#FFFFFF",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{base_color}{Monotone Base Color, works best with a light color., defaults to #3C989E}
@@ -133,6 +133,10 @@ mono_accent_inverse(base_color = "#3C989E", white_color = "#FFFFFF",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/mono_dark.Rd Просмотреть файл

@@ -34,7 +34,7 @@ mono_dark(base_color = "#cbf7ed", white_color = lighten_color(base_color,
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{base_color}{Monotone Base Color, works best with a light color., defaults to #cbf7ed}
@@ -133,6 +133,10 @@ mono_dark(base_color = "#cbf7ed", white_color = lighten_color(base_color,
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/mono_light.Rd Просмотреть файл

@@ -34,7 +34,7 @@ mono_light(base_color = "#23395b", white_color = lighten_color(base_color,
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{base_color}{Monotone base color, works best with a strong color, defaults to #23395b}
@@ -133,6 +133,10 @@ mono_light(base_color = "#23395b", white_color = lighten_color(base_color,
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/solarized_dark.Rd Просмотреть файл

@@ -30,7 +30,7 @@ solarized_dark(text_color = "#839496", header_color = "#dc322f",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{text_color}{Text Color, defaults to #839496}
@@ -123,6 +123,10 @@ solarized_dark(text_color = "#839496", header_color = "#dc322f",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/solarized_light.Rd Просмотреть файл

@@ -30,7 +30,7 @@ solarized_light(text_color = "#657b83", header_color = "#dc322f",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{text_color}{Text Color, defaults to #657b83}
@@ -123,6 +123,10 @@ solarized_light(text_color = "#657b83", header_color = "#dc322f",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

+ 5
- 1
man/write_xaringan_theme.Rd Просмотреть файл

@@ -30,7 +30,7 @@ write_xaringan_theme(text_color = "#000", header_color = "#000",
code_font_google = NULL, code_font_family = "'Source Code Pro'",
code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700",
code_font_family_fallback = "'Lucida Console', Monaco", extra_css = NULL,
outfile = "xaringan-themer.css")
extra_fonts = NULL, outfile = "xaringan-themer.css")
}
\arguments{
\item{text_color}{Text Color, defaults to #000}
@@ -123,6 +123,10 @@ write_xaringan_theme(text_color = "#000", header_color = "#000",
of CSS property-value pairs, i.e.
\code{list(".class-id" = list("css-property" = "value"))}}

\item{extra_fonts}{A list of additional fonts to import, each list element
can be either a URL as a character string or a call to
\code{\link{google_fonts}()}}

\item{outfile}{Customized xaringan CSS output file name, default is "xaringan-themer.css"}
}
\description{

Загрузка…
Отмена
Сохранить