simplify code
diff --git a/R/light_themes.R b/R/light_themes.R
index a91152d..63e578d 100644
--- a/R/light_themes.R
+++ b/R/light_themes.R
@@ -14,39 +14,22 @@
#'
#' @export
kable_classic <- function(kable_input, lightable_options = "basic", ...) {
- light_class <- "lightable-classic"
- lightable_options <- match.arg(lightable_options,
- choices = c("basic", "striped", "hover"),
- several.ok = TRUE)
- if ("striped" %in% lightable_options) {
- light_class <- paste(light_class, "lightable-striped")
- }
- if ("hover" %in% lightable_options) {
- light_class <- paste(light_class, "lightable-hover")
- }
- kable_styling(kable_input, "none", lightable_class = light_class, ...)
+ kable_light(kable_input, "lightable-classic", lightable_options, ...)
}
#' @rdname kable_classic
#' @export
kable_minimal <- function(kable_input, lightable_options = "basic", ...) {
- light_class <- "lightable-minimal"
- lightable_options <- match.arg(lightable_options,
- choices = c("basic", "striped", "hover"),
- several.ok = TRUE)
- if ("striped" %in% lightable_options) {
- light_class <- paste(light_class, "lightable-striped")
- }
- if ("hover" %in% lightable_options) {
- light_class <- paste(light_class, "lightable-hover")
- }
- kable_styling(kable_input, "none", lightable_class = light_class, ...)
+ kable_light(kable_input, "lightable-minimal", lightable_options, ...)
}
#' @rdname kable_classic
#' @export
kable_material <- function(kable_input, lightable_options = "basic", ...) {
- light_class <- "lightable-material"
+ kable_light(kable_input, "lightable-material", lightable_options, ...)
+}
+
+kable_light <- function(kable_input, light_class, lightable_options, ...) {
lightable_options <- match.arg(lightable_options,
choices = c("basic", "striped", "hover"),
several.ok = TRUE)
@@ -56,5 +39,8 @@
if ("hover" %in% lightable_options) {
light_class <- paste(light_class, "lightable-hover")
}
- kable_styling(kable_input, "none", lightable_class = light_class, ...)
+ out <- kable_styling(kable_input, "none", lightable_class = light_class, ...)
+ attr(out, "lightable") <- TRUE
+ attr(out, "lightable_class") <- light_class
+ return(out)
}
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index efbd879..21c67f0 100644
--- a/docs/awesome_table_in_html.html
+++ b/docs/awesome_table_in_html.html
@@ -1331,7 +1331,7 @@
.lightable-minimal tbody tr:first-child td {
padding-top: 0.5em;
}
-.lightable-minimal.lightable-hover tr:hover {
+.lightable-minimal.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
.lightable-minimal.lightable-striped tr:nth-child(even) {
@@ -1346,7 +1346,7 @@
.lightable-classic thead tr:last-child th {
border-bottom: 1px solid #111111;
}
-.lightable-classic.lightable-hover tr:hover {
+.lightable-classic.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
.lightable-classic.lightable-striped tr:nth-child(even) {
@@ -1369,7 +1369,7 @@
padding: 0.8em;
border-top: 1px solid #eeeeee;
}
-.lightable-material.lightable-hover tr:hover {
+.lightable-material.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
.lightable-material.lightable-striped tr:nth-child(even) {
@@ -5624,7 +5624,7 @@
1
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5640,7 +5640,7 @@
3
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5656,7 +5656,7 @@
5
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5664,7 +5664,7 @@
6
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -5672,7 +5672,7 @@
7
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -5691,7 +5691,7 @@
9
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -5699,7 +5699,7 @@
10
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5713,7 +5713,7 @@
11
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5721,7 +5721,7 @@
12
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -5740,7 +5740,7 @@
14
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
diff --git a/inst/lightable-0.0.1/lightable.css b/inst/lightable-0.0.1/lightable.css
index cfe2b13..c1b7e9b 100644
--- a/inst/lightable-0.0.1/lightable.css
+++ b/inst/lightable-0.0.1/lightable.css
@@ -20,7 +20,7 @@
padding-top: 0.5em;
}
-.lightable-minimal.lightable-hover tr:hover {
+.lightable-minimal.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
@@ -39,7 +39,7 @@
border-bottom: 1px solid #111111;
}
-.lightable-classic.lightable-hover tr:hover {
+.lightable-classic.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
@@ -67,7 +67,7 @@
border-top: 1px solid #eeeeee;
}
-.lightable-material.lightable-hover tr:hover {
+.lightable-material.lightable-hover tbody tr:hover {
background-color: #f5f5f5;
}
@@ -76,7 +76,7 @@
}
.lightable-material.lightable-striped td {
- border: 0px;
+ border: 0;
}
.lightable-material.lightable-striped thead tr:last-child th {