【发布时间】:2020-09-06 01:02:08
【问题描述】:
我希望有一个使用 reactable 表的 blogdown 帖子,该表的列仅包含阴影方块。
以下是演示此问题的 .Rmd 和 css 文件。 在 RStudio 中,如果我点击“Knit”,表格会出现带有阴影的绿色方块。
再次在 RStudio 中运行,如果我运行
blogdown::build_site(local = FALSE, method = c("html", "custom"), run_hugo = TRUE)
网站已建立,但带有表格的帖子有一个空白的“状态”列。没有阴影方块。
如何构建网站并显示阴影方块?
.Rmd
---
title: Test Colored Squares
author: ''
date: '2020-09-05'
slug: test-colored-squares
categories: []
tags: []
output:
html_document:
css: "~/R/whatbank_hugo/src/square-highlight.css"
---
```{r, echo=FALSE, message=FALSE, warning=FALSE}
# From: https://glin.github.io/reactable/articles/cookbook/cookbook.html
library("tidyverse")
library("reactable")
orders <- data.frame(
Order = 2300:2304,
Created = seq(as.Date("2019-04-01"), by = "day", length.out = 5),
Customer = sample(rownames(MASS::painters), 5),
Status = c("", "", "", "", "")
)
reactable(orders, columns = list(
Status = colDef(cell = function(value) {
class <- paste0("tag box green", tolower(value))
htmltools::div(class = class, value)
})
))
```
square-highlight.css
.row {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.box {
height: 20px;
width: 20px;
border: 1px solid black;
margin-right: 5px;
}
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
【问题讨论】: