Skip to content

Commit

Permalink
Merge pull request #264 from royfrancis/specky
Browse files Browse the repository at this point in the history
Fix schedule table issues
  • Loading branch information
fasterius authored Oct 7, 2024
2 parents 01a5c70 + 2ad975e commit ee7aff3
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 34 deletions.
42 changes: 42 additions & 0 deletions assets/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,45 @@ div.callout-caution .callout-icon::before {
div.callout-important .callout-icon::before {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiIgZmlsbD0iIzFjMjgzMyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjwhLS0hRm9udCBBd2Vzb21lIEZyZWUgNi41LjEgYnkgQGZvbnRhd2Vzb21lIC0gaHR0cHM6Ly9mb250YXdlc29tZS5jb20gTGljZW5zZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tL2xpY2Vuc2UvZnJlZSBDb3B5cmlnaHQgMjAyMyBGb250aWNvbnMsIEluYy4tLT48cGF0aCBkPSJNNDE2IDM5OC45YzU4LjUtNDEuMSA5Ni0xMDQuMSA5Ni0xNzQuOUM1MTIgMTAwLjMgMzk3LjQgMCAyNTYgMFMwIDEwMC4zIDAgMjI0YzAgNzAuNyAzNy41IDEzMy44IDk2IDE3NC45YzAgLjQgMCAuNyAwIDEuMXY2NGMwIDI2LjUgMjEuNSA0OCA0OCA0OGg0OFY0NjRjMC04LjggNy4yLTE2IDE2LTE2czE2IDcuMiAxNiAxNnY0OGg2NFY0NjRjMC04LjggNy4yLTE2IDE2LTE2czE2IDcuMiAxNiAxNnY0OGg0OGMyNi41IDAgNDgtMjEuNSA0OC00OFY0MDBjMC0uNCAwLS43IDAtMS4xek05NiAyNTZhNjQgNjQgMCAxIDEgMTI4IDBBNjQgNjQgMCAxIDEgOTYgMjU2em0yNTYtNjRhNjQgNjQgMCAxIDEgMCAxMjggNjQgNjQgMCAxIDEgMC0xMjh6Ii8+PC9zdmc+') !important;
}

/* table schedule */

.table-schedule {
font-size: 0.85em;
line-height: 1.8;
}

.table-schedule tr:hover {
background-color: whitesmoke;
}

.table-schedule table {
margin: 1em auto;
}

.table-schedule .topic {
color: white;
font-weight: bold;
border-radius: 4px;
padding: 1px 4px;
background: #BDBDBD;
}

.table-schedule .topic-dinner {
color: white;
font-weight: bold;
border-radius: 4px;
padding: 1px 4px;
background: #95b540;
}

.table-schedule .marker {
color: $primary;
margin-left: 2px;
margin-right: 3px;
}

.table-schedule td p {
margin-bottom: 0;
padding: 5px 0px;
}
62 changes: 28 additions & 34 deletions home_schedule.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ library(readxl)
library(here)
schedule_message <- yaml::read_yaml(here("_quarto.yml"))$schedule_message
color_primary <- yaml::read_yaml(here("_quarto.yml"))$colors$primary
asst <- yaml::read_yaml("_quarto.yml")$assistant
#' @description Add hover classes to assistants
Expand Down Expand Up @@ -58,41 +56,37 @@ create_tooltip <- function(a, asst) {
#| eval: true
s <- readxl::read_xlsx("schedule.xlsx") %>%
# remove rows that are all NA
filter(if_any(everything(), ~ !is.na(.))) %>%
# missing values in date and room are filled
tidyr::fill(date, room, link_room, .direction = "down") %>%
# convert date characters to date objects
dplyr::mutate(date = format(as_datetime(date, format = "%d/%m/%Y"), "%d-%b-%Y")) %>%
dplyr::mutate(day = format(as_datetime(date, format = "%d-%b-%Y"), "%a")) %>%
dplyr::group_by(date) %>%
dplyr::mutate(
start_time = format(start_time, "%H:%M"),
# end_time = format(end_time, "%H:%M")
) %>%
as.data.frame() %>%
dplyr::mutate(room = ifelse(is.na(link_room), room, paste0("<a href='", link_room, "'>", room, "</a>"))) %>%
# create day label (with date, day, room)
dplyr::mutate(date = paste0("<p style='font-size:110%;padding-top:10px;padding-bottom:5px;'><span style='font-weight:bold;'><span class='marker'>",fa("fas fa-calendar"),"</span>", date, "</span>", "<span style='color:white;border-radius:4px;padding-right:4px;padding-left:4px;background:", color_primary, ";margin-left:9px;margin-right:7px;'>", day, "</span>", "<span class='marker'>", fa("fas fa-location-dot"),"</span>", room, "</p>")) %>%
# style topic
dplyr::mutate(topic = ifelse(tolower(topic) == "break" | tolower(topic) == "lunch", paste0("<span class='topic'>", topic, "</span>"), topic)) %>%
dplyr::mutate(topic = ifelse(grepl("dinner",tolower(topic)), paste0("<span class='topic-dinner'>", topic, "</span>"), topic)) %>%
dplyr::mutate(topic = ifelse(!startsWith(topic, "<span"), paste0("<span style='margin-right:5px;'>", topic, "</span>"), topic)) %>%
# add links to topic
dplyr::mutate(topic = ifelse(is.na(link_slide), topic, paste0("<span>", topic, "<a class='marker' href='", link_slide, "'>", fa("fas fa-file-powerpoint"), "</a></span>"))) %>%
dplyr::mutate(topic = ifelse(is.na(link_lab), topic, paste0("<span>", topic, "<a class='marker' href='", link_lab, "'>", fa("fas fa-file-lines"), "</a></span>"))) %>%
dplyr::mutate(topic = ifelse(is.na(link_youtube), topic, paste0("<span>", topic, "<a class='marker' href='", link_youtube, "' target=”_blank”>", fa("fab fa-youtube"),"</a></span>"))) %>%
dplyr::mutate(time = paste0(start_time, " - ", end_time)) %>%
dplyr::mutate(instructor = ifelse(is.na(instructor), "", instructor)) %>%
dplyr::mutate(assistant = ifelse(is.na(assistant), "", assistant)) %>%
dplyr::select(date, room, time, topic, instructor, assistant)
# remove rows that are all NA
filter(if_any(everything(), ~ !is.na(.))) %>%
# missing values in date and room are filled
tidyr::fill(date, room, link_room, .direction = "down") %>%
# convert date characters to date objects
dplyr::mutate(date = format(as_datetime(date, format = "%d/%m/%Y"), "%d-%b-%Y")) %>%
dplyr::mutate(day = format(as_datetime(date, format = "%d-%b-%Y"), "%a")) %>%
dplyr::group_by(date) %>%
dplyr::mutate(time = format(time, "%H:%M")) %>%
as.data.frame() %>%
dplyr::mutate(room = ifelse(is.na(link_room), room, paste0("<a href='", link_room, "'>", room, "</a>"))) %>%
# create day label (with date, day, room)
dplyr::mutate(date = paste0("<p style='font-size:110%;padding-top:10px;padding-bottom:5px;'><span style='font-weight:bold;'><span class='marker'>", fa("fas fa-calendar"), "</span>", date, "</span>", "<span style='color:white;border-radius:4px;padding-right:4px;padding-left:4px;background:#95b540;margin-left:9px;margin-right:7px;'>", day, "</span>", "<span class='marker'>", fa("fas fa-location-dot"), "</span>", room, "</p>")) %>%
# style topic
dplyr::mutate(topic = ifelse(tolower(topic) == "break" | tolower(topic) == "lunch", paste0("<span class='topic'>", topic, "</span>"), topic)) %>%
dplyr::mutate(topic = ifelse(grepl("dinner", tolower(topic)), paste0("<span class='topic-dinner'>", topic, "</span>"), topic)) %>%
dplyr::mutate(topic = ifelse(!startsWith(topic, "<span"), paste0("<span style='margin-right:5px;'>", topic, "</span>"), topic)) %>%
# add links to topic
dplyr::mutate(topic = ifelse(is.na(link_slide), topic, paste0("<span>", topic, "<a class='marker' href='", link_slide, "'>", fa("fas fa-file-powerpoint"), "</a></span>"))) %>%
dplyr::mutate(topic = ifelse(is.na(link_lab), topic, paste0("<span>", topic, "<a class='marker' href='", link_lab, "'>", fa("fas fa-file-lines"), "</a></span>"))) %>%
dplyr::mutate(topic = ifelse(is.na(link_youtube), topic, paste0("<span>", topic, "<a class='marker' href='", link_youtube, "' target=”_blank”>", fa("fab fa-youtube"), "</a></span>"))) %>%
dplyr::mutate(instructor = ifelse(is.na(instructor), "", instructor)) %>%
dplyr::mutate(assistant = ifelse(is.na(assistant), "", assistant)) %>%
dplyr::select(date, room, time, topic, instructor, assistant)
if (all(is.na(s$assistant)) | all(s$assistant == "")) {
s$assistant <- NULL
cnames <- c("Time", "Topic", "Instructor")
s$assistant <- NULL
cnames <- c("Time", "Topic", "Instructor")
} else {
s$assistant <- create_tooltip(s$assistant, asst)
cnames <- c("Time", "Topic", "Instructor", "Assistant")
s$assistant <- create_tooltip(s$assistant, asst)
cnames <- c("Time", "Topic", "Instructor", "Assistant")
}
```

Expand Down
Binary file modified schedule.xlsx
Binary file not shown.

0 comments on commit ee7aff3

Please sign in to comment.