-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.qmd
More file actions
56 lines (53 loc) · 1.51 KB
/
Copy pathtable.qmd
File metadata and controls
56 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: Data
execute:
echo: FALSE
message: FALSE
warning: FALSE
---
```{r}
processed <- readRDS("data/processed_paddles.rds") |>
dplyr::select(name, start_date, distance, club, filename) |>
dplyr::mutate(filename = stringr::str_replace(filename, "\\.md", "\\.html"))
library(reactable)
library(htmltools)
reactable(
processed,
highlight = TRUE,
bordered = TRUE,
striped = TRUE,
filterable = TRUE,
compact = TRUE,
defaultPageSize = 25,
defaultSorted = list(start_date = "desc"),
onClick = JS("function(rowInfo, column) {
window.open(rowInfo.values['filename'], '_blank')
}"),
rowStyle = list(cursor = "pointer"),
columns = list(
name = colDef(name = "Paddle"),
start_date = colDef(name = "Date"),
distance = colDef(
name = "Distance",
align = "left",
html = TRUE,
cell = JS("function(cellInfo) {
const value = cellInfo.value.toFixed(1)
const maxVal = 32.3
const pct = (cellInfo.value / maxVal * 100) + '%'
return `
<div style='display:flex; align-items:center; gap:6px;'>
<span style='min-width:38px;'>
${value}<span style='font-size:0.8em; color:#999; margin-left:2px;'>km</span>
</span>
<div style='flex-grow:1; background:#e1e1e1; border-radius:3px; height:0.75rem;'>
<div style='width:${pct}; background:#00bfc4; height:100%; border-radius:3px;'></div>
</div>
</div>
`
}")
),
filename = colDef(show = FALSE)
)
)
```