improve lightable's look on add_header_above/group_rows
improve documentation
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 1dde0ec..f3f3b8b 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -148,7 +148,8 @@
new_header_row <- htmlTable_new_header_generator(
header, bold, italic, monospace, underline, strikeout, align,
- color, background, font_size, angle, line, line_sep, extra_css, include_empty
+ color, background, font_size, angle, line, line_sep, extra_css,
+ include_empty, attr(kable_input, 'lightable_class')
)
xml_add_child(kable_xml_thead, new_header_row, .where = 0)
out <- as_kable_xml(kable_xml)
@@ -181,7 +182,7 @@
underline, strikeout, align,
color, background, font_size,
angle, line, line_sep, extra_css,
- include_empty) {
+ include_empty, lightable_class) {
align <- vapply(align, switch_align, 'x', USE.NAMES = FALSE)
row_style <- paste0(
@@ -229,8 +230,34 @@
}
}
- line <- ifelse(ez_rep(line, nrow(header_df)),
- "border-bottom: 1px solid #ddd; padding-bottom: 5px; ", "")
+ if (is.null(lightable_class)) {
+ border_hidden <- 'border-bottom:hidden;'
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 1px solid #ddd; padding-bottom: 5px; ", "")
+ } else {
+ border_hidden <- ''
+ if (lightable_class %in% c("lightable-classic", "lightable-classic-2")) {
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 1px solid #111111; margin-bottom: -1px; ", "")
+ }
+ if (lightable_class %in% c("lightable-minimal")) {
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 2px solid #00000050; ", "")
+ }
+ if (lightable_class %in% c("lightable-paper")) {
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 1px solid #00000020; padding-bottom: 5px; ", "")
+ }
+ if (lightable_class %in% c("lightable-material")) {
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 1px solid #eee; padding-bottom: 16px; padding-top: 16px; height: 56px;", "")
+ }
+ if (lightable_class %in% c("lightable-material-dark")) {
+ line <- ifelse(ez_rep(line, nrow(header_df)),
+ "border-bottom: 1px solid #FFFFFF12; padding-bottom: 16px; padding-top: 16px; height: 56px;", "")
+ }
+ }
+
line_sep <- ez_rep(line_sep, nrow(header_df))
line_sep <- glue::glue('padding-left:{line_sep}px;padding-right:{line_sep}px;')
@@ -238,10 +265,10 @@
header_items <- ifelse(
trimws(header_df$header) == "",
- paste0('<th style="border-bottom:hidden" colspan="', header_df$colspan,
+ paste0('<th style="empty-cells: hide;', border_hidden, '" colspan="', header_df$colspan,
'"></th>'),
paste0(
- '<th style="border-bottom:hidden; padding-bottom:0; ',
+ '<th style="', border_hidden, 'padding-bottom:0; ',
line_sep, row_style, '" colspan="',
header_df$colspan, '"><div style="', line, '">', header_df$header,
'</div></th>')
diff --git a/R/group_rows.R b/R/group_rows.R
index ecfdc12..f5b4864 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -145,6 +145,25 @@
if (bold) group_label <- paste0("<strong>", group_label, "</strong>")
if (italic) group_label <- paste0("<em>", group_label, "</em>")
+ if (label_row_css == "border-bottom: 1px solid;") {
+ if (!is.null(attr(kable_input, "lightable_class"))) {
+ lightable_class <- attr(kable_input, "lightable_class")
+ if (lightable_class %in% c(
+ "lightable-classic", "lightable-classic-2", "lightable-minimal")) {
+ label_row_css <- "border-bottom: 0;"
+ }
+ if (lightable_class %in% c("lightable-paper")) {
+ label_row_css <- "border-bottom: 1px solid #00000020;"
+ }
+ if (lightable_class %in% c("lightable-material")) {
+ label_row_css <- "border-bottom: 1px solid #eee; "
+ }
+ if (lightable_class %in% c("lightable-material-dark")) {
+ label_row_css <- "border-bottom: 1px solid #FFFFFF12; color: #FFFFFF60;"
+ }
+ }
+ }
+
group_header_row_text <- paste0(
'<tr groupLength="', length(group_seq), '"><td colspan="', kable_ncol,
'" style="', label_row_css, '">', group_label, "</td></tr>")
diff --git a/R/light_themes.R b/R/light_themes.R
index 4200dac..5718d75 100644
--- a/R/light_themes.R
+++ b/R/light_themes.R
@@ -33,7 +33,7 @@
#' @export
kable_minimal <- function(
kable_input, lightable_options = "basic",
- html_font = 'calibri, cambria, "Source Sans Pro", sans-serif', ...) {
+ html_font = '"Trebuchet MS", verdana, calibri, sans-serif', ...) {
kable_light(kable_input, "lightable-minimal",
lightable_options, html_font, ...)
}