Skip to content

Commit 5611851

Browse files
vedhavgogonzo
andauthored
Implement bslib and use Bootstrap 5 (#869)
Part of insightsengineering/coredev-tasks#587 Closes #841 --------- Co-authored-by: Dawid Kaledkowski <[email protected]>
1 parent df7d1a7 commit 5611851

30 files changed

+330
-276
lines changed

DESCRIPTION

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ Depends:
2727
ggplot2 (>= 3.4.0),
2828
R (>= 4.1),
2929
shiny (>= 1.6.0),
30-
teal (>= 0.16.0),
30+
teal (>= 0.16.0.9002),
3131
teal.transform (>= 0.6.0)
3232
Imports:
33+
bslib (>= 0.8.0),
3334
checkmate (>= 2.1.0),
3435
colourpicker (>= 1.3.0),
3536
dplyr (>= 1.0.5),
@@ -60,8 +61,8 @@ Imports:
6061
teal.code (>= 0.6.1),
6162
teal.data (>= 0.7.0),
6263
teal.logger (>= 0.3.2),
63-
teal.reporter (>= 0.4.0),
64-
teal.widgets (>= 0.4.3),
64+
teal.reporter (>= 0.4.0.9004),
65+
teal.widgets (>= 0.4.3.9001),
6566
tern (>= 0.9.7),
6667
tibble (>= 2.0.0),
6768
tidyr (>= 0.8.3),
@@ -105,3 +106,7 @@ Language: en-US
105106
LazyData: true
106107
Roxygen: list(markdown = TRUE, packages = c("roxy.shinylive"))
107108
RoxygenNote: 7.3.2
109+
Remotes:
110+
insightsengineering/teal.widgets@main,
111+
insightsengineering/teal.reporter@main,
112+
insightsengineering/teal@main

R/tm_a_pca.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ ui_a_pca <- function(id, ...) {
246246
data_extract_spec = args$dat,
247247
is_single_dataset = is_single_dataset_value
248248
),
249-
teal.widgets::panel_group(
250-
teal.widgets::panel_item(
249+
bslib::accordion(
250+
open = TRUE,
251+
bslib::accordion_panel(
251252
title = "Display",
252-
collapsed = FALSE,
253253
checkboxGroupInput(
254254
ns("tables_display"),
255255
"Tables display",
@@ -291,7 +291,7 @@ ui_a_pca <- function(id, ...) {
291291
)
292292
)
293293
),
294-
teal.widgets::panel_item(
294+
bslib::accordion_panel(
295295
title = "Pre-processing",
296296
radioButtons(
297297
ns("standardization"), "Standardization",
@@ -304,9 +304,8 @@ ui_a_pca <- function(id, ...) {
304304
selected = "none"
305305
)
306306
),
307-
teal.widgets::panel_item(
307+
bslib::accordion_panel(
308308
title = "Selected plot specific settings",
309-
collapsed = FALSE,
310309
uiOutput(ns("plot_settings")),
311310
conditionalPanel(
312311
condition = sprintf("input['%s'] == 'Biplot'", ns("plot_type")),
@@ -322,7 +321,7 @@ ui_a_pca <- function(id, ...) {
322321
)
323322
)
324323
),
325-
teal.widgets::panel_item(
324+
bslib::accordion_panel(
326325
title = "Plot settings",
327326
collapsed = TRUE,
328327
conditionalPanel(

R/tm_a_regression.R

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ui_a_regression <- function(id, ...) {
288288
### Reporter
289289
teal.reporter::simple_reporter_ui(ns("simple_reporter")),
290290
###
291-
tags$label("Encodings", class = "text-primary"),
291+
tags$label("Encodings", class = "text-primary"), tags$br(),
292292
teal.transform::datanames_input(args[c("response", "regressor")]),
293293
teal.transform::data_extract_ui(
294294
id = ns("response"),
@@ -315,12 +315,10 @@ ui_a_regression <- function(id, ...) {
315315
teal.widgets::optionalSliderInput(
316316
ns("outlier"),
317317
tags$div(
318-
class = "teal-tooltip",
319318
tagList(
320319
"Outlier definition:",
321-
icon("circle-info"),
322-
tags$span(
323-
class = "tooltiptext",
320+
bslib::tooltip(
321+
icon("fas fa-circle-info"),
324322
paste(
325323
"Use the slider to choose the cut-off value to define outliers.",
326324
"Points with a Cook's distance greater than",
@@ -338,24 +336,25 @@ ui_a_regression <- function(id, ...) {
338336
)
339337
),
340338
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
341-
teal.widgets::panel_group(
342-
teal.widgets::panel_item(
339+
bslib::accordion(
340+
open = TRUE,
341+
bslib::accordion_panel(
343342
title = "Plot settings",
344343
teal.widgets::optionalSliderInputValMinMax(ns("alpha"), "Opacity:", args$alpha, ticks = FALSE),
345344
teal.widgets::optionalSliderInputValMinMax(ns("size"), "Points size:", args$size, ticks = FALSE),
346345
teal.widgets::optionalSliderInputValMinMax(
347346
inputId = ns("label_min_segment"),
348347
label = tags$div(
349-
class = "teal-tooltip",
350348
tagList(
351349
"Label min. segment:",
352-
icon("circle-info"),
353-
tags$span(
354-
class = "tooltiptext",
355-
paste(
356-
"Use the slider to choose the cut-off value to define minimum distance between label and point",
357-
"that generates a line segment.",
358-
"It's only valid when 'Display outlier labels' is checked."
350+
bslib::tooltip(
351+
icon("circle-info"),
352+
tags$span(
353+
paste(
354+
"Use the slider to choose the cut-off value to define minimum distance between label and point",
355+
"that generates a line segment.",
356+
"It's only valid when 'Display outlier labels' is checked."
357+
)
359358
)
360359
)
361360
)

R/tm_data_table.R

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,15 @@ ui_page_data_table <- function(id, pre_output = NULL, post_output = NULL) {
161161
include_css_files("custom"),
162162
teal.widgets::standard_layout(
163163
output = teal.widgets::white_small_well(
164-
fluidRow(
165-
column(
166-
width = 12,
167-
checkboxInput(
168-
ns("if_distinct"),
169-
"Show only distinct rows:",
170-
value = FALSE
171-
)
164+
bslib::page_fluid(
165+
checkboxInput(
166+
ns("if_distinct"),
167+
"Show only distinct rows:",
168+
value = FALSE
172169
)
173170
),
174-
fluidRow(
175-
class = "mb-8",
176-
column(
177-
width = 12,
178-
uiOutput(ns("dataset_table"))
179-
)
171+
bslib::page_fluid(
172+
uiOutput(ns("dataset_table"))
180173
)
181174
),
182175
pre_output = pre_output,
@@ -233,15 +226,12 @@ srv_page_data_table <- function(id,
233226
}
234227
tabPanel(
235228
title = x,
236-
column(
237-
width = 12,
238-
div(
239-
class = "mt-4",
240-
ui_data_table(
241-
id = session$ns(x),
242-
choices = choices,
243-
selected = variables_selected
244-
)
229+
bslib::layout_columns(
230+
col_widths = 12,
231+
ui_data_table(
232+
id = session$ns(x),
233+
choices = choices,
234+
selected = variables_selected
245235
)
246236
)
247237
)
@@ -281,7 +271,7 @@ ui_data_table <- function(id, choices, selected) {
281271

282272
tagList(
283273
teal.widgets::get_dt_rows(ns("data_table"), ns("dt_rows")),
284-
fluidRow(
274+
bslib::page_fluid(
285275
teal.widgets::optionalSelectInput(
286276
ns("variables"),
287277
"Select variables:",
@@ -291,7 +281,7 @@ ui_data_table <- function(id, choices, selected) {
291281
width = "100%"
292282
)
293283
),
294-
fluidRow(
284+
bslib::page_fluid(
295285
DT::dataTableOutput(ns("data_table"), width = "100%")
296286
)
297287
)

R/tm_g_association.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,9 @@ ui_tm_g_association <- function(id, ...) {
265265
value = FALSE
266266
),
267267
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
268-
teal.widgets::panel_group(
269-
teal.widgets::panel_item(
268+
bslib::accordion(
269+
open = TRUE,
270+
bslib::accordion_panel(
270271
title = "Plot settings",
271272
teal.widgets::optionalSliderInputValMinMax(ns("alpha"), "Scatterplot opacity:", c(0.5, 0, 1), ticks = FALSE),
272273
teal.widgets::optionalSliderInputValMinMax(ns("size"), "Scatterplot points size:", c(2, 1, 8), ticks = FALSE),

R/tm_g_bivariate.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,12 @@ ui_g_bivariate <- function(id, ...) {
372372
if (!is.null(args$row_facet) || !is.null(args$col_facet)) {
373373
tags$div(
374374
class = "data-extract-box",
375-
tags$label("Facetting"),
376-
shinyWidgets::switchInput(inputId = ns("facetting"), value = args$facet, size = "mini"),
375+
tags$br(),
376+
bslib::input_switch(
377+
id = ns("facetting"),
378+
label = "Facetting",
379+
value = args$facet
380+
),
377381
conditionalPanel(
378382
condition = paste0("input['", ns("facetting"), "']"),
379383
tags$div(
@@ -404,7 +408,11 @@ ui_g_bivariate <- function(id, ...) {
404408
tags$div(
405409
class = "data-extract-box",
406410
tags$label("Color settings"),
407-
shinyWidgets::switchInput(inputId = ns("coloring"), value = TRUE, size = "mini"),
411+
bslib::input_switch(
412+
id = ns("coloring"),
413+
label = "Color settings",
414+
value = TRUE
415+
),
408416
conditionalPanel(
409417
condition = paste0("input['", ns("coloring"), "']"),
410418
tags$div(
@@ -433,8 +441,9 @@ ui_g_bivariate <- function(id, ...) {
433441
)
434442
)
435443
},
436-
teal.widgets::panel_group(
437-
teal.widgets::panel_item(
444+
bslib::accordion(
445+
open = TRUE,
446+
bslib::accordion_panel(
438447
title = "Plot settings",
439448
checkboxInput(ns("rotate_xaxis_labels"), "Rotate X axis labels", value = args$rotate_xaxis_labels),
440449
checkboxInput(ns("swap_axes"), "Swap axes", value = args$swap_axes),

R/tm_g_distribution.R

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ ui_distribution <- function(id, ...) {
288288
is_single_dataset = is_single_dataset_value
289289
)
290290
},
291-
teal.widgets::panel_group(
291+
bslib::accordion(
292292
conditionalPanel(
293293
condition = paste0("input['", ns("tabs"), "'] == 'Histogram'"),
294-
teal.widgets::panel_item(
294+
bslib::accordion_panel(
295295
"Histogram",
296296
teal.widgets::optionalSliderInputValMinMax(ns("bins"), "Bins", args$bins, ticks = FALSE, step = 1),
297297
shinyWidgets::prettyRadioButtons(
@@ -306,13 +306,12 @@ ui_distribution <- function(id, ...) {
306306
ui_decorate_teal_data(
307307
ns("d_density"),
308308
decorators = select_decorators(args$decorators, "histogram_plot")
309-
),
310-
collapsed = FALSE
309+
)
311310
)
312311
),
313312
conditionalPanel(
314313
condition = paste0("input['", ns("tabs"), "'] == 'QQplot'"),
315-
teal.widgets::panel_item(
314+
bslib::accordion_panel(
316315
"QQ Plot",
317316
checkboxInput(ns("qq_line"), label = "Add diagonal line(s)", TRUE),
318317
ui_decorate_teal_data(
@@ -332,18 +331,18 @@ ui_distribution <- function(id, ...) {
332331
),
333332
conditionalPanel(
334333
condition = paste0("input['", ns("main_type"), "'] == 'Density'"),
335-
teal.widgets::panel_item(
334+
bslib::accordion_panel(
336335
"Theoretical Distribution",
337336
teal.widgets::optionalSelectInput(
338337
ns("t_dist"),
339338
tags$div(
340-
class = "teal-tooltip",
341339
tagList(
342340
"Distribution:",
343-
icon("circle-info"),
344-
tags$span(
345-
class = "tooltiptext",
346-
"Default parameters are optimized with MASS::fitdistr function."
341+
bslib::tooltip(
342+
icon("circle-info"),
343+
tags$span(
344+
"Default parameters are optimized with MASS::fitdistr function."
345+
)
347346
)
348347
)
349348
),
@@ -356,39 +355,39 @@ ui_distribution <- function(id, ...) {
356355
tags$span(actionButton(ns("params_reset"), "Default params")),
357356
collapsed = FALSE
358357
)
359-
)
360-
),
361-
teal.widgets::panel_item(
362-
"Tests",
363-
teal.widgets::optionalSelectInput(
364-
ns("dist_tests"),
365-
"Tests:",
366-
choices = c(
367-
"Shapiro-Wilk",
368-
if (!is.null(args$strata_var)) "t-test (two-samples, not paired)",
369-
if (!is.null(args$strata_var)) "one-way ANOVA",
370-
if (!is.null(args$strata_var)) "Fligner-Killeen",
371-
if (!is.null(args$strata_var)) "F-test",
372-
"Kolmogorov-Smirnov (one-sample)",
373-
"Anderson-Darling (one-sample)",
374-
"Cramer-von Mises (one-sample)",
375-
if (!is.null(args$strata_var)) "Kolmogorov-Smirnov (two-samples)"
376-
),
377-
selected = NULL
378-
)
379-
),
380-
teal.widgets::panel_item(
381-
"Statistics Table",
382-
sliderInput(ns("roundn"), "Round to n digits", min = 0, max = 10, value = 2)
383-
),
384-
teal.widgets::panel_item(
385-
title = "Plot settings",
386-
selectInput(
387-
inputId = ns("ggtheme"),
388-
label = "Theme (by ggplot):",
389-
choices = ggplot_themes,
390-
selected = args$ggtheme,
391-
multiple = FALSE
358+
),
359+
bslib::accordion_panel(
360+
title = "Tests",
361+
teal.widgets::optionalSelectInput(
362+
ns("dist_tests"),
363+
"Tests:",
364+
choices = c(
365+
"Shapiro-Wilk",
366+
if (!is.null(args$strata_var)) "t-test (two-samples, not paired)",
367+
if (!is.null(args$strata_var)) "one-way ANOVA",
368+
if (!is.null(args$strata_var)) "Fligner-Killeen",
369+
if (!is.null(args$strata_var)) "F-test",
370+
"Kolmogorov-Smirnov (one-sample)",
371+
"Anderson-Darling (one-sample)",
372+
"Cramer-von Mises (one-sample)",
373+
if (!is.null(args$strata_var)) "Kolmogorov-Smirnov (two-samples)"
374+
),
375+
selected = NULL
376+
)
377+
),
378+
bslib::accordion_panel(
379+
title = "Statistics Table",
380+
sliderInput(ns("roundn"), "Round to n digits", min = 0, max = 10, value = 2)
381+
),
382+
bslib::accordion_panel(
383+
title = "Plot settings",
384+
selectInput(
385+
inputId = ns("ggtheme"),
386+
label = "Theme (by ggplot):",
387+
choices = ggplot_themes,
388+
selected = args$ggtheme,
389+
multiple = FALSE
390+
)
392391
)
393392
)
394393
),

R/tm_g_response.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ ui_g_response <- function(id, ...) {
304304
justified = TRUE
305305
),
306306
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
307-
teal.widgets::panel_group(
308-
teal.widgets::panel_item(
307+
bslib::accordion(
308+
open = TRUE,
309+
bslib::accordion_panel(
309310
title = "Plot settings",
310311
checkboxInput(ns("count_labels"), "Add count labels", value = args$count_labels),
311312
checkboxInput(ns("coord_flip"), "Swap axes", value = args$coord_flip),

0 commit comments

Comments
 (0)