gadenbuie / xaringanthemer

😎 Give your xaringan slides some style
https://pkg.garrickadenbuie.com/xaringanthemer/
Other
445 stars 28 forks source link

change regex pattern to match valid css class names #69

Closed jdlom closed 2 years ago

jdlom commented 2 years ago

Hi thanks for your great package.

Problem

I run into problems when I want to pass some css class name with number to the color parameter.

library(xaringanthemer)
style_duo_accent(
  primary_color = "#1381B0",
  secondary_color = "#FF961C",
  inverse_header_color = "#FFFFFF",
  colors = c("blue-100" = "#9A9AFF")
)

# returns Colors names in `colors`must be valid CSS classes

blue-100 does not seem to be a valid CSS class name.

Solution

I change the pattern to accept number in class name. I'm not a great CSS guy, so I took the expression on stackoverflow.

https://stackoverflow.com/questions/448981/which-characters-are-valid-in-css-class-names-selectors

Example

---
title: "Presentation Ninja"
subtitle: "&#x2694;&#xFE0F; xaringan +<br/>&#x1F60E; xaringanthemer"  
author: 
  - "Yihui Xie"
  - "Garrick Aden-Buie"
date: '`r Sys.Date()`'
output:
  xaringan::moon_reader:
    css: xaringan-themer.css
    nature:
      slideNumberFormat: "%current%"
      highlightStyle: github
      highlightLines: true
      ratio: 16:9
      countIncrementalSlides: true
---
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(
  fig.width=9, fig.height=3.5, fig.retina=3,
  out.width = "100%",
  cache = FALSE,
  echo = TRUE,
  message = FALSE, 
  warning = FALSE,
  hiline = TRUE
)
library(xaringanthemer)
style_duo_accent(
  primary_color = "#1381B0",
  secondary_color = "#FF961C",
  inverse_header_color = "#FFFFFF",
  colors = c("blue-100" = "#9A9AFF")
)
## Typography

My text is .blue-100[color]
jdlom commented 2 years ago

I use a warning as you suggest. Because I'm not an english speaker, I would prefer let you do the warning message.

I add the slash to the regex pattern to pass the check tests and add some other tests.

Don't know if I have done well because I'm pretty new to R and the R package development.

codecov-commenter commented 2 years ago

Codecov Report

Merging #69 (4bc27f2) into master (046187a) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #69   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files          17       17           
  Lines         743      743           
=======================================
  Hits          695      695           
  Misses         48       48           
Impacted Files Coverage Δ
R/color.R 94.23% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 046187a...4bc27f2. Read the comment docs.

jdlom commented 2 years ago

@gadenbuie Are we done or do you still need my help for something ?