Skip to content

Commit

Permalink
add gt_theme_savant w/ new dev version numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Weatherman authored and Andrew Weatherman committed May 10, 2024
1 parent eebfbe4 commit b99c3f8
Show file tree
Hide file tree
Showing 34 changed files with 651 additions and 540 deletions.
1,022 changes: 511 additions & 511 deletions .Rhistory

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/pcs/files-pane.pper
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ascending": true
}
],
"path": "~/cbbplotR/data-raw"
"path": "~/cbbplotR"
}
2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab": 3
"activeTab": 2
}
2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"windowheight": 772
},
"right": {
"splitterpos": 479,
"splitterpos": 366,
"topwindowstate": "NORMAL",
"panelheight": 734,
"windowheight": 772
Expand Down
2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TabSet1": 0,
"TabSet2": 0,
"TabSet2": 4,
"TabZoom": {}
}
2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/sources/prop/262F9DD4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "2,12",
"cursorPosition": "2,9",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/F7318DF6/sources/prop/297CAAA6
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "49,25",
"cursorPosition": "51,16",
"scrollLine": "38"
}
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cbbplotR
Title: CBB Logo Plots in 'ggplot2'
Version: 0.3.0
Version: 0.3.0.9000
Authors@R:
person("Andrew", "Weatherman", , "[email protected]", role = c("aut", "cre"))
Description: A set of functions to visualize college basketball team and conference
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export(gt_color_results)
export(gt_set_font)
export(gt_theme_athletic)
export(gt_theme_pl)
export(gt_theme_savant)
export(scale_color_cbb_conferences)
export(scale_color_cbb_teams)
export(scale_colour_cbb_conferences)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cbbplotR 0.3.0.9000 (in progress)
- Added [`gt_theme_savant`](https://cbbplotr.aweatherman.com/reference/gt_theme_savant.html)

# cbbplotR 0.3.0
- Added [`gt_theme_pl`](https://cbbplotr.aweatherman.com/reference/gt_theme_pl.html)
- Added ability to customize the amount of vertical alignment in `gt_cbb_teams` and `gt_cbb_conferences`.
Expand Down
74 changes: 74 additions & 0 deletions R/gt-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,80 @@ gt_theme_athletic <- function(gt_object, ...) {

}

#' Baseball Savant `gt` Table Theme
#'
#' A theme for styling `gt` tables similar to Baseball Savant.
#'
#' @returns Returns data with an appended HTML column.
#' @param gt_object An existing gt table object of class `gt_tbl`
#' @param ... Optional additional arguments to `gt::table_options()`
#' @import gt
#' @importFrom magrittr %>%
#'
#' @export
gt_theme_savant <- function(gt_object, ...) {

stopifnot(`'gt_object' must be a 'gt_tbl', have you accidentally passed raw data?` = "gt_tbl" %in%
class(gt_object))

table_id <- subset(gt_object[['_options']], parameter == 'table_id')$value[[1]]

if (is.na(table_id)) {
table_id <- gt::random_id()
opt_position <- which("table_id" %in% gt_object[["_options"]][["parameter"]])[[1]]
gt_object[["_options"]][["value"]][[opt_position]] <- table_id
}

gt_object %>%
# cell body
gt::tab_style(locations = gt::cells_body(),
style = gt::cell_text(font = gt::google_font('Roboto Condensed'), size = px(14))) %>%
# col. headers
gt::tab_style(locations = gt::cells_column_labels(),
style = gt::cell_text(weight = 'bold', font = gt::google_font('Roboto Condensed'), size = px(14))) %>%
# group rows
gt::tab_style(locations = gt::cells_row_groups(),
style = gt::cell_text(weight = 'bold', font = gt::google_font('Roboto Condensed'), size = px(14))) %>%
# footnote
gt::tab_style(locations = gt::cells_footnotes(),
style = gt::cell_text(font = gt::google_font('Roboto Condensed'), size = px(12))) %>%
# title
gt::tab_style(locations = gt::cells_title('title'),
style = gt::cell_text(weight = 'bold', font = gt::google_font('Roboto Condensed'), size = px(18))) %>%
# subtitle
gt::tab_style(locations = gt::cells_title('subtitle'),
style = gt::cell_text(font = gt::google_font('Roboto Condensed'), size = px(14))) %>%
# caption
gt::tab_style(locations = gt::cells_source_notes(),
style = gt::cell_text(font = gt::google_font('Roboto Condensed'), size = px(10))) %>%
gt::tab_options(
data_row.padding = 1,
table_body.hlines.color = "transparent",
column_labels.border.top.color = 'black',
column_labels.border.top.width = px(1),
column_labels.border.bottom.style = 'none',
row_group.border.top.style = "none",
row_group.border.top.color = "black",
row_group.border.bottom.width = px(1),
row_group.border.bottom.color = "black",
row_group.border.bottom.style = 'solid',
row_group.padding = px(1.5),
heading.align = 'center',
heading.border.bottom.style = "none",
table_body.border.top.style = "none",
table_body.border.bottom.color = "white",
table.border.bottom.style = 'none',
table.border.top.style = 'none',
source_notes.border.lr.style = "none",
...
) %>%
gt::opt_row_striping() %>%
gt::opt_css(c(paste0("#", table_id, " tbody tr:last-child {border-bottom: 2px solid #ffffff00;}"),
paste0("#", table_id, " .gt_col_heading {padding-bottom: 2px; padding-top: 2px;}"),
paste0("#", table_id, " .gt_subtitle {padding-top:0px !important; padding-bottom: 4px !important;}"),
paste0("#", table_id, " .gt_heading {padding-bottom: 0px; padding-top: 6px;}")))

}

#' Premier League `gt` Table Theme
#'
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ reference:
- gt_bold_rows
- gt_theme_athletic
- gt_theme_pl
- gt_theme_savant
- title: Other Functions
desc: Miscellaneous functions
contents:
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
getting_started: getting_started.html
last_built: 2024-04-12T16:59Z
last_built: 2024-05-10T18:15Z
urls:
reference: https://andreweatherman.github.io/cbbplotR/reference
article: https://andreweatherman.github.io/cbbplotR/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cbbplotR-package.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/cbbplotR_clear_cache.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/geom_cbb_conferences.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/geom_cbb_headshots.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/geom_cbb_teams.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/geom_lines.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/ggplot_cbb_logo_title.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/ggpreview.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/gt_cbb_logo_title.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pipe.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/scale_cbb.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<url>
<loc>https://andreweatherman.github.io/cbbplotR/reference/gt_theme_pl.html</loc>
</url>
<url>
<loc>https://andreweatherman.github.io/cbbplotR/reference/gt_theme_savant.html</loc>
</url>
<url>
<loc>https://andreweatherman.github.io/cbbplotR/reference/index.html</loc>
</url>
Expand Down
Loading

0 comments on commit b99c3f8

Please sign in to comment.