Skip to content

Commit 0382cdb

Browse files
authored
Final UI/UX changes (#1571)
Part of fixes that will close insightsengineering/teal.gallery#216 and insightsengineering/teal.gallery#217 Please review this along with its companion PRs: - [ ] insightsengineering/teal.widgets#310 - [ ] insightsengineering/teal.reporter#366 - [ ] insightsengineering/teal.modules.general#905 - [ ] insightsengineering/teal.modules.clinical#1405 Changes: 1. Improved the header/footer and breadcrum spacing <img width="1714" height="843" alt="Screenshot 2025-07-30 192020" src="https://github.com/user-attachments/assets/de31cfbc-f755-48d0-9b33-6e2f65555036" /> 2. The popup buttons: `🔖Bookmark`, `📷Snapshot Manager`, `▼ Filter Manager`, `📅Load Data` will be disabled when shiny is busy. Note that the `teal.reporter` and `teal.widgets` modal buttons are handled in different PRs, the solution is the same, but they are name-spaced so they don't clash each other. <details> <summary> Example app for testing </summary> ``` devtools::load_all("../teal.widgets") devtools::load_all("../teal.reporter") devtools::load_all("../teal") devtools::load_all("../teal.modules.general") make_data <- function(datanames = c("ADSL", "ADTTE")) { data_obj <- teal.data::teal_data() if ("ADSL" %in% datanames) { data_obj <- within(data_obj, ADSL <- teal.data::rADSL) } if ("ADTTE" %in% datanames) { data_obj <- within(data_obj, ADTTE <- teal.data::rADTTE) } join_keys(data_obj) <- default_cdisc_join_keys[datanames] data_obj } error_data <- teal_data_module( once = FALSE, ui = function(id) { ns <- NS(id) tagList( selectizeInput( ns("errortype"), label = "Error Type", choices = c( "ok", "insufficient datasets", "no data", "qenv.error", "error in reactive", "validate error", "silent.shiny.error", "not a reactive" ) ), actionButton(ns("submit"), "Submit") ) }, server = function(id, ...) { moduleServer(id, function(input, output, session) { logger::log_trace("example_module_transform2 initializing.") eventReactive(input$submit, { switch(req(input$errortype), ok = make_data(), `insufficient datasets` = make_data(datanames = "ADSL"), `no data` = teal_data(), qenv.error = within(teal_data(), stop("this is qenv.error in teal_data_module (from inside within())")), `error in reactive` = stop("error in a reactive in teal_data_module (manual stop call)"), `validate error` = validate(need(FALSE, "validate error in teal_data_module (with newline )")), `silent.shiny.error` = req(FALSE) ) }) }) } ) modules <- modules( module( "test wait", server = function(id, data) { moduleServer(id, function(input, output, session) { observeEvent(input$wait, { Sys.sleep(2) }) }) }, ui = function(id) { ns <- NS(id) actionButton(ns("wait"), "Wait for 2 seconds `Sys.sleep(2)`") } ), example_module("One"), teal.modules.general::tm_g_distribution( "Distribution", dist_var = teal.transform::data_extract_spec( dataname = "iris", select = teal.transform::select_spec(teal.transform::variable_choices("iris"), "Petal.Length") ) ), example_module("One"), example_module("Two"), example_module("Two"), teal.modules.general::tm_variable_browser("Variable Browser"), teal.modules.general::tm_variable_browser("Variable Browser"), modules( label = "Nest level 1", example_module("Two"), example_module("Double Nested module"), modules( label = "Nest level 2", example_module("Inception two"), modules( label = "Nest level 3", example_module("Double Inception") ) ) ), modules( label = "Nested", example_module("Nested one"), example_module("Nested two") ), example_module("Three") ) app <- init( data = error_data, modules = modules ) |> modify_title(title = "Custom title") |> modify_header( element = tags$div("Custom header") ) |> modify_footer( element = tags$div(h3("Custom footer")) ) shinyApp(app$ui, app$server, enableBookmarking = "server") ``` </details>
1 parent d68be88 commit 0382cdb

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

R/init.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ init <- function(data,
219219
),
220220
tags$header(
221221
id = "teal-header",
222-
style = "margin: 0.5em",
222+
style = "margin: 1em 1em 0 1em;",
223223
tags$div(id = "teal-header-content")
224224
),
225225
ui_teal(
@@ -228,7 +228,7 @@ init <- function(data,
228228
),
229229
tags$footer(
230230
id = "teal-footer",
231-
style = "margin: 0.5em",
231+
style = "margin: 0.5em 1em;",
232232
tags$div(id = "teal-footer-content"),
233233
ui_session_info("teal-footer-session_info")
234234
)

R/module_nested_tabs.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ srv_teal_module <- function(id,
586586
}
587587

588588
.modules_breadcrumb <- function(module) {
589-
tags$span(
590-
style = "color: var(--bs-secondary); font-size: medium;opacity: 0.6; margin-left: 0.5em;",
589+
tags$div(
590+
style = "color: var(--bs-secondary); font-size: large; opacity: 0.6; margin: 0 0.5em 0.5em 0.5em;",
591591
paste("Home", module$path, sep = " / ")
592592
)
593593
}

R/utils.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,17 @@ pluralize <- function(x, singular, plural = NULL) {
514514
.expand_button <- function(id, label, icon) {
515515
tags$span(
516516
class = "teal expand-button",
517-
tags$a(
517+
htmltools::htmlDependency(
518+
name = "teal-busy-disable",
519+
version = utils::packageVersion("teal"),
520+
package = "teal",
521+
src = "js",
522+
script = "busy-disable.js"
523+
),
524+
shinyjs::useShinyjs(),
525+
tags$button(
518526
id = id,
519-
class = "action-button",
527+
class = "action-button teal-busy-disable",
520528
role = "button",
521529
style = "text-decoration: none;",
522530
tags$span(class = "icon", bsicons::bs_icon(icon, class = "text-primary")),

inst/css/custom.css

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,21 @@ body > div:has(~ #shiny-modal-wrapper .blur_background) {
8686
transition: max-width 0.3s ease;
8787
}
8888

89-
.teal.expand-button a {
89+
.teal.expand-button button {
90+
color: var(--bs-primary);
91+
background-color: transparent;
9092
border: 2px solid transparent;
9193
padding: 0.5rem;
9294
}
9395

96+
.teal.expand-button button:disabled {
97+
color: var(--bs-dark-text-emphasis);
98+
}
99+
100+
.teal.expand-button:hover button:disabled {
101+
border-bottom: 2px solid var(--bs-dark-bg-subtle);
102+
}
103+
94104
.teal.expand-button .label {
95105
opacity: 0;
96106
transition: opacity 0.2s ease;
@@ -100,7 +110,7 @@ body > div:has(~ #shiny-modal-wrapper .blur_background) {
100110
max-width: 200px;
101111
}
102112

103-
.teal.expand-button:hover a {
113+
.teal.expand-button:hover button {
104114
border-bottom: 2px solid var(--bs-primary-border-subtle);
105115
}
106116

inst/js/busy-disable.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Primarily added to make sure the user does not open multiple modals when shiny is busy.
2+
// https://github.com/rstudio/shiny/issues/4261
3+
$(document).on("shiny:busy", function () {
4+
$(".teal-busy-disable").prop("disabled", true);
5+
});
6+
$(document).on("shiny:idle", function () {
7+
$(".teal-busy-disable").prop("disabled", false);
8+
});

inst/module-navigation/module-navigation.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@
6161
position: relative;
6262
}
6363

64-
.dropdown.nav-item-custom .teal-reporter.outline-button .badge {
65-
margin-left: 1em;
66-
}
67-
6864
.teal.dropdown-button {
6965
border: 2px solid transparent;
7066
margin: 0.25em;

0 commit comments

Comments
 (0)