-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.qmd
More file actions
90 lines (74 loc) · 2.17 KB
/
Copy pathindex.qmd
File metadata and controls
90 lines (74 loc) · 2.17 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
format:
html:
echo: false
message: false
error: false
warning: false
backgroundcolor: transparent
---
```{r message=FALSE}
library(reactable)
library(tidyverse)
library(sf)
library(glue)
base <- "https://cityforwardcollective.github.io/school_profiles/compiled_reports"
leges_sf <- read_rds("data/electeds_with_sf_2024.rda")
this_theme <- function() {
reactableTheme(
searchInputStyle = list(
width = "100%"
),
style = list(
padding = "10px",
minHeight = "650"
)
)
}
vacants <- function(value) {
if (value == "Vacant") {
args <- list(value, style = glue("color: {'grey90'}; font-weight: 700"))
}
do.call(span, args)
}
col2hex <- function(x, alpha = FALSE) {
args <- as.data.frame(t(col2rgb(x, alpha = alpha)))
args <- c(args, list(names = x, maxColorValue = 255))
do.call(rgb, args)
}
leges_sf |>
as_tibble() |>
# select(house, district:party_aff) |>
mutate("Report Link" = case_when(
title == "Mayor" ~ glue("<a href='{base}/{house}/{house}.pdf'",
"target='_blank'>{house}</a>"),
title == "County Executive" ~ glue("<a href='{base}/{house}/{house}.pdf'",
"target='_blank'>{house}</a>"),
TRUE ~ glue("<a href='{base}/{house}/{house} District {district}.pdf'",
"target='_blank'>{house} District {district}</a>"))) |>
select("Elected Body" = house,
District = district,
Incumbent = name,
`Report Link`) |>
reactable(elementId = "myTable", columns = list(
District = colDef(minWidth = 50),
Incumbent = colDef(
style = function(value) {
if (value == "Vacant") {
list(color = glue("{col2hex('grey60')}"), fontStyle = "italic")
}
}
),
`Report Link` = colDef(html = TRUE,
style = list(fontSize = ".75rem"),
minWidth = 125)
),
searchable = TRUE,
highlight = TRUE,
showPageSizeOptions = TRUE,
language = reactableLang(
searchPlaceholder = "Search incumbent, elected body, or district"
),
defaultColDef = colDef(align = "center"),
theme = this_theme())
```