| stop(msg, call. = FALSE) | stop(msg, call. = FALSE) | ||||
| } | } | ||||
| purrr::map_chr(names(css), function(el) { | |||||
| x <- purrr::imap_chr(css, function(rules, selector) { | |||||
| paste( | paste( | ||||
| sep = "\n", | sep = "\n", | ||||
| el %.% " {", | |||||
| selector %.% " {", | |||||
| paste( | paste( | ||||
| purrr::map_chr(names(css[[el]]), function(prop) { | |||||
| " " %.% prop %.% ": " %.% css[[el]][[prop]] %.% ";" | |||||
| purrr::imap_chr(rules, function(value, prop) { | |||||
| " " %.% prop %.% ": " %.% value %.% ";" | |||||
| }), | }), | ||||
| collapse = "\n" | collapse = "\n" | ||||
| ), | ), | ||||
| "}" | "}" | ||||
| ) | ) | ||||
| }) | }) | ||||
| unname(x) | |||||
| } | } | ||||
| list2fonts <- function(fonts) { | list2fonts <- function(fonts) { |
| "elements.+must be named.+body, thing.+have" | "elements.+must be named.+body, thing.+have" | ||||
| ) | ) | ||||
| }) | }) | ||||
| it("is okay for multiple entries with the same name", { | |||||
| expect_equal( | |||||
| list2css(list("a" = list(color = "red"), a = list(color = "blue"))), | |||||
| c("a {\n color: red;\n}", "a {\n color: blue;\n}") | |||||
| ) | |||||
| expect_equal( | |||||
| list2css(list("a" = list(color = "red", color = "blue"))), | |||||
| c("a {\n color: red;\n color: blue;\n}") | |||||
| ) | |||||
| }) | |||||
| }) | }) | ||||