@@ -171,35 +171,57 @@ render_as_ihtml <- function(data, id) {
171
171
172
172
table_width <- opt_val(data = data , option = " table_width" )
173
173
table_background_color <- opt_val(data = data , option = " table_background_color" )
174
+ table_font_size <- opt_val(data = data , " table_font_size" )
174
175
table_font_names <- opt_val(data = data , option = " table_font_names" )
175
176
table_font_color <- opt_val(data = data , option = " table_font_color" )
177
+ table_border_right_style <- opt_val(data , " table_border_right_style" )
178
+ table_border_right_color <- opt_val(data , " table_border_right_color" )
179
+ table_border_left_style <- opt_val(data , " table_border_left_style" )
180
+ table_border_left_color <- opt_val(data , " table_border_left_color" )
181
+ table_border_top_color <- opt_val(data , " table_border_top_color" )
182
+
183
+ heading_border_bottom_color <- opt_val(data , " heading_border_bottom_color" )
176
184
177
185
column_labels_border_top_style <- opt_val(data = data , option = " column_labels_border_top_style" )
178
186
column_labels_border_top_width <- opt_val(data = data , option = " column_labels_border_top_width" )
179
187
column_labels_border_top_color <- opt_val(data = data , option = " column_labels_border_top_color" )
180
188
column_labels_border_bottom_style <- opt_val(data = data , option = " column_labels_border_bottom_style" )
181
189
column_labels_border_bottom_width <- opt_val(data = data , option = " column_labels_border_bottom_width" )
182
190
column_labels_border_bottom_color <- opt_val(data = data , option = " column_labels_border_bottom_color" )
191
+
183
192
# Don't allow NA
184
193
column_labels_background_color <- opt_val(data = data , option = " column_labels_background_color" )
185
- # Apply stub font weight to
186
- stub_font_weight <- opt_val(data = data , option = " stub_font_weight" )
187
-
188
194
if (is.na(column_labels_background_color )) {
189
195
# apply all column labels formatting to both heading + groupCol styling (nothing specific for spanners styling in gt?)
190
196
column_labels_background_color <- " transparent"
191
197
}
192
- # Part of #1307
193
- borderless_borders <- opt_val(data = data , option = " table_body_hlines_style" ) == " none"
194
198
195
199
column_labels_font_weight <- opt_val(data = data , option = " column_labels_font_weight" )
200
+ # Apply stub font weight to
201
+ stub_font_weight <- opt_val(data = data , option = " stub_font_weight" )
196
202
# Apply font weight to groupname_col title
197
- row_group_font_weight <- opt_val(data = data , " row_group_font_weight" )
198
- table_body_font_weight <- opt_val(data = data , " table_font_weight" )
203
+ row_group_font_weight <- opt_val(data = data , " row_group_font_weight" )
204
+ row_group_background_color <- opt_val(data = data , " row_group_background_color" )
205
+
206
+ table_body_font_weight <- opt_val(data = data , " table_font_weight" )
207
+ table_body_hlines_style <- opt_val(data = data , " table_body_hlines_style" )
208
+ table_body_hlines_color <- opt_val(data = data , " table_body_hlines_color" )
209
+ table_body_hlines_width <- opt_val(data = data , " table_body_hlines_width" )
210
+ table_body_vlines_style <- opt_val(data = data , " table_body_vlines_style" )
211
+ table_body_vlines_color <- opt_val(data = data , " table_body_vlines_color" )
212
+ table_body_vlines_width <- opt_val(data = data , " table_body_vlines_width" )
213
+
214
+ horizontal_borders <- opt_val(data = data , option = " table_body_hlines_style" )
215
+ veritcal_borders <- opt_val(data = data , option = " table_body_vlines_style" )
216
+ borderless_borders <- horizontal_borders == " none" && veritcal_borders == " none"
217
+ all_borders <- horizontal_borders != " none" && veritcal_borders != " none"
218
+
199
219
# for row names + summary label
200
- stub_font_weight <- opt_val(data = data , " stub_font_weight" )
201
- # #1693 table font size
202
- table_font_size <- opt_val(data = data , " table_font_size" )
220
+ stub_border_color <- opt_val(data , " stub_border_color" )
221
+ stub_border_style <- opt_val(data , " stub_border_style" )
222
+ # Apply stub font weight to
223
+ stub_font_weight <- opt_val(data = data , option = " stub_font_weight" )
224
+ stub_background_color <- opt_val(data = data , option = " stub_background_color" )
203
225
204
226
emoji_symbol_fonts <-
205
227
c(
@@ -222,7 +244,13 @@ render_as_ihtml <- function(data, id) {
222
244
row_name_col_def <- list (reactable :: colDef(
223
245
name = rowname_label ,
224
246
style = list (
225
- fontWeight = stub_font_weight
247
+ fontWeight = stub_font_weight ,
248
+ color = if (! is.na(stub_background_color )) unname(ideal_fgnd_color(stub_background_color )) else NULL ,
249
+ borderRight = stub_border_color ,
250
+ borderRightStyle = stub_border_style ,
251
+ backgroundColor = stub_background_color # ,
252
+
253
+ # borderLeft, borderRight are possible
226
254
)
227
255
# TODO pass on other attributes of row names column if necessary.
228
256
))
@@ -347,7 +375,13 @@ render_as_ihtml <- function(data, id) {
347
375
reactable :: colDef(
348
376
name = group_label ,
349
377
style = list (
350
- `font-weight` = row_group_font_weight
378
+ `font-weight` = row_group_font_weight ,
379
+ color = if (is.na(row_group_background_color )) NULL else unname(ideal_fgnd_color(row_group_background_colorfgggee )),
380
+ backgroundColor = row_group_background_color ,
381
+ borderStyle = " none" ,
382
+ borderColor = " transparent" ,
383
+ borderTopColor = " transparent" ,
384
+ borderBottomColor = " gray38"
351
385
),
352
386
# The total number of rows is wrong in colGroup, possibly due to the JS fn
353
387
grouped = grp_fn ,
@@ -382,7 +416,7 @@ render_as_ihtml <- function(data, id) {
382
416
styles_tbl <- dt_styles_get(data = data )
383
417
body_styles_tbl <- dplyr :: filter(styles_tbl , locname %in% c(" data" , " stub" ))
384
418
body_styles_tbl <- dplyr :: arrange(body_styles_tbl , colnum , rownum )
385
- body_styles_tbl <- dplyr :: select(body_styles_tbl , colname , rownum , html_style )
419
+ body_styles_tbl <- dplyr :: select(body_styles_tbl , " colname" , " rownum" , " html_style" )
386
420
387
421
# Generate styling rule per combination of `colname` and
388
422
# `rownum` in `body_styles_tbl`
@@ -431,28 +465,40 @@ render_as_ihtml <- function(data, id) {
431
465
432
466
# Generate the table header if there are any heading components
433
467
if (has_header_section ) {
468
+ # These don't work in non-interactive context.
469
+ heading_title_font_weight <- opt_val(data , " heading_title_font_weight" )
470
+ heading_subtitle_font_weight <- opt_val(data , " heading_subtitle_font_weight" )
471
+ heading_background_color <- opt_val(data , " heading_background_color" )
434
472
435
473
tbl_heading <- dt_heading_get(data = data )
436
-
437
474
heading_component <-
438
475
htmltools :: div(
439
476
style = htmltools :: css(
440
477
`font-family` = font_family_str ,
478
+ `background-color` = heading_background_color ,
441
479
`border-top-style` = " solid" ,
442
480
`border-top-width` = " 2px" ,
443
481
`border-top-color` = " #D3D3D3" ,
482
+ `border-bottom-color` = " #D3D3D3" ,
444
483
`padding-bottom` = if (use_search ) " 8px" else NULL
445
484
),
446
485
htmltools :: div(
447
486
class = " gt_heading gt_title gt_font_normal" ,
448
- style = htmltools :: css(`text-size` = " bigger" ),
487
+ style = htmltools :: css(
488
+ `text-size` = " bigger" ,
489
+ `font-weight` = heading_title_font_weight
490
+ ),
449
491
htmltools :: HTML(tbl_heading $ title )
450
492
),
451
493
htmltools :: div(
452
494
class = paste(
453
495
" gt_heading" , " gt_subtitle" ,
454
496
if (use_search ) " gt_bottom_border" else NULL
455
497
),
498
+ style = htmltools :: css(
499
+ `font-weight` = heading_subtitle_font_weight ,
500
+ `border-bottom-color` = " #D3D3D3"
501
+ ),
456
502
htmltools :: HTML(tbl_heading $ subtitle )
457
503
)
458
504
)
@@ -476,14 +522,16 @@ render_as_ihtml <- function(data, id) {
476
522
footnotes_component <- NULL
477
523
}
478
524
525
+ table_border_bottom_style <- opt_val(data , " table_border_bottom_style" )
526
+
479
527
footer_component <-
480
528
htmltools :: div(
481
529
style = htmltools :: css(
482
530
`font-family` = font_family_str ,
483
531
`border-top-style` = " solid" ,
484
532
`border-top-width` = " 2px" ,
485
533
`border-top-color` = " #D3D3D3" ,
486
- `border-bottom-style` = " solid " ,
534
+ `border-bottom-style` = table_border_bottom_style ,
487
535
`border-bottom-width` = " 2px" ,
488
536
`border-bottom-color` = " #D3D3D3" ,
489
537
`padding-top` = " 6px" ,
@@ -542,6 +590,7 @@ render_as_ihtml <- function(data, id) {
542
590
headerClass = NULL ,
543
591
headerStyle = list (
544
592
fontWeight = " normal" ,
593
+ color = if (is.na(column_labels_background_color )) NULL else unname(ideal_fgnd_color(column_labels_background_color )),
545
594
backgroundColor = column_labels_background_color ,
546
595
borderBottomStyle = column_labels_border_bottom_style ,
547
596
borderBottomWidth = column_labels_border_bottom_width ,
@@ -573,18 +622,25 @@ render_as_ihtml <- function(data, id) {
573
622
# 1693
574
623
fontSize = table_font_size
575
624
),
576
- tableStyle = list (
577
- borderTopStyle = column_labels_border_top_style ,
578
- borderTopWidth = column_labels_border_top_width ,
579
- borderTopColor = column_labels_border_top_color
625
+ # borders in the body
626
+ rowStyle = list (
627
+ fontWeight = table_body_font_weight ,
628
+ borderTopStyle = table_body_hlines_style ,
629
+ borderTopColor = table_body_hlines_color ,
630
+ borderTopWidth = table_body_hlines_width ,
631
+ BorderRightStyle = table_body_vlines_style ,
632
+ BorderRightColor = table_body_vlines_color ,
633
+ BorderRightWidth = table_body_vlines_width
580
634
),
581
635
# cells_column_labels()
582
636
headerStyle = list (
583
637
fontWeight = column_labels_font_weight ,
584
638
backgroundColor = column_labels_background_color ,
585
639
borderBottomStyle = column_labels_border_bottom_style ,
586
640
borderBottomWidth = column_labels_border_bottom_width ,
587
- borderBottomColor = column_labels_border_bottom_color
641
+ borderBottomColor = column_labels_border_bottom_color ,
642
+ borderTopColor = " transparent" ,
643
+ borderTopStyle = " none"
588
644
),
589
645
# individually defined for the margins left+right
590
646
# cells_spanner_labels() styling
@@ -595,19 +651,30 @@ render_as_ihtml <- function(data, id) {
595
651
borderBottomWidth = column_labels_border_bottom_width ,
596
652
borderBottomColor = column_labels_border_bottom_color
597
653
),
598
- tableBodyStyle = NULL ,
654
+ # body = table
655
+ tableStyle = list (
656
+ borderRightStyle = table_border_right_style ,
657
+ borderRightColor = table_border_right_color ,
658
+ borderLeftStyle = table_border_left_style ,
659
+ borderLeftColor = table_border_right_style ,
660
+ borderBttomColor = heading_border_bottom_color
661
+ ),
599
662
# stub styling?
600
663
# rowGroupStyle = list(
664
+ # backgroundColor = row_group_background_color,
601
665
# fontWeight = row_group_font_weight
602
666
# ),
603
- rowStyle = NULL ,
667
+ # exclude pagination and search
668
+ tableBodyStyle = NULL ,
604
669
rowStripedStyle = NULL ,
605
670
rowHighlightStyle = NULL ,
606
671
rowSelectedStyle = NULL ,
607
672
# cells_body styling
608
- cellStyle = list (
609
- fontWeight = table_body_font_weight
610
- ),
673
+ # cellStyle = list(
674
+ # fontWeight = table_body_font_weight,
675
+ # backgroundColor = table_background_color
676
+ # ),
677
+ # grand_summary style
611
678
footerStyle = NULL ,
612
679
inputStyle = NULL ,
613
680
filterInputStyle = NULL ,
@@ -645,7 +712,7 @@ render_as_ihtml <- function(data, id) {
645
712
showPagination = use_pagination ,
646
713
showPageInfo = use_pagination_info ,
647
714
minRows = 1 ,
648
- paginateSubRows = FALSE ,
715
+ paginateSubRows = TRUE ,
649
716
details = NULL ,
650
717
defaultExpanded = expand_groupname_col ,
651
718
selection = NULL ,
@@ -654,7 +721,8 @@ render_as_ihtml <- function(data, id) {
654
721
onClick = NULL ,
655
722
highlight = use_highlight ,
656
723
outlined = FALSE ,
657
- bordered = FALSE ,
724
+ # equivalent to opt_table_lines(extent = "all")
725
+ bordered = all_borders ,
658
726
# equivalent to opt_table_lines(extent = "none")
659
727
borderless = borderless_borders ,
660
728
striped = use_row_striping ,
0 commit comments