Skip to content

Commit a646b7a

Browse files
authored
Final UI/UX changes (#366)
Companion of insightsengineering/teal#1571 Additionally, it improves the preview button's position in the vignette.
1 parent 1a5c567 commit a646b7a

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

R/utils.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,16 @@ global_knitr_details <- function() {
167167
shiny::tagList(
168168
shinyjs::useShinyjs(),
169169
.custom_css_dependency(),
170-
shiny::tags$a(
170+
htmltools::htmlDependency(
171+
name = "teal-reporter-busy-disable",
172+
version = utils::packageVersion("teal.reporter"),
173+
package = "teal.reporter",
174+
src = "js",
175+
script = "busy-disable.js"
176+
),
177+
shiny::tags$button(
171178
id = id,
172-
class = sprintf("teal-reporter action-button outline-button %s", class),
179+
class = sprintf("teal-reporter action-button teal-reporter-busy-disable outline-button %s", class),
173180
role = "button",
174181
style = "text-decoration: none;",
175182
if (!is.null(icon)) {

inst/css/custom.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
.teal-reporter.outline-button {
2323
padding: 0.3em;
2424
border-radius: 5px;
25+
background: transparent;
2526
}
2627

27-
.teal-reporter.outline-button.disabled {
28+
.teal-reporter.outline-button.disabled,
29+
.teal-reporter.outline-button:disabled {
2830
pointer-events: none;
2931
opacity: 0.65;
3032
}
@@ -34,7 +36,7 @@
3436
border: solid 1px var(--bs-primary);
3537
}
3638

37-
.teal-reporter.outline-button.primary:hover {
39+
.teal-reporter.outline-button.primary:hover:not(:disabled) {
3840
background: var(--bs-primary-bg-subtle);
3941
}
4042

@@ -43,13 +45,12 @@
4345
border: solid 1px var(--bs-danger);
4446
}
4547

46-
.teal-reporter.outline-button.danger:hover {
48+
.teal-reporter.outline-button.danger:hover:not(:disabled) {
4749
background: var(--bs-danger-bg-subtle);
4850
}
4951

5052
.teal-reporter.outline-button .badge {
5153
margin-top: -1em;
52-
margin-left: -0.3em;
5354
}
5455

5556
.teal-reporter.report-previewer-accordion .accordion-header {

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-reporter-busy-disable").prop("disabled", true);
5+
});
6+
$(document).on("shiny:idle", function () {
7+
$(".teal-reporter-busy-disable").prop("disabled", false);
8+
});

vignettes/previewerReporter.Rmd

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,8 @@ library(bslib)
4242

4343
A basic `shiny` app with the previewer module:
4444

45-
```{r, eval=requireNamespace("ggplot2")}
45+
```{r, eval=requireNamespace("ggplot2") && interactive()}
4646
ui <- bslib::page_fluid(
47-
# please, specify specific bootstrap version and theme
48-
tags$br(),
49-
tags$span(
50-
### REPORTER
51-
teal.reporter::preview_report_button_ui("previewer")
52-
###
53-
),
54-
tags$br(),
55-
tags$br(),
5647
sidebarLayout(
5748
sidebarPanel(
5849
uiOutput("encoding")
@@ -73,6 +64,7 @@ server <- function(input, output, session) {
7364
shiny::tagList(
7465
### REPORTER
7566
teal.reporter::add_card_button_ui("add_reporter", label = "Add Report Card"),
67+
teal.reporter::preview_report_button_ui("previewer"),
7668
###
7769
if (input$tabs == "Plot") {
7870
sliderInput(
@@ -193,5 +185,5 @@ server <- function(input, output, session) {
193185
###
194186
}
195187
196-
if (interactive()) shinyApp(ui = ui, server = server)
188+
shinyApp(ui = ui, server = server)
197189
```

vignettes/simpleReporter.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ library(rtables)
5151

5252
Simple reporter `shiny` app with separate modules for each button:
5353

54-
```{r, eval=requireNamespace("ggplot2")}
54+
```{r, eval=requireNamespace("ggplot2") && interactive()}
5555
ui <- bslib::page_fluid(
5656
titlePanel(""),
5757
sidebarLayout(
@@ -143,12 +143,12 @@ server <- function(input, output, session) {
143143
###
144144
}
145145
146-
if (interactive()) shinyApp(ui = ui, server = server)
146+
shinyApp(ui = ui, server = server)
147147
```
148148

149149
Simple reporter `shiny` app with combined buttons modules:
150150

151-
```{r, eval=requireNamespace("ggplot2")}
151+
```{r, eval=requireNamespace("ggplot2") && interactive()}
152152
ui <- bslib::page_fluid(
153153
titlePanel(""),
154154
sidebarLayout(
@@ -238,5 +238,5 @@ server <- function(input, output, session) {
238238
###
239239
}
240240
241-
if (interactive()) shinyApp(ui = ui, server = server)
241+
shinyApp(ui = ui, server = server)
242242
```

vignettes/teal-reporter.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This eliminates the need for manual copy-pasting or writing in markdown.
1818

1919
And it can be done as easy as adding one of the reporting tools to your module:
2020

21-
```{r}
21+
```{r eval=interactive()}
2222
library(teal.reporter)
2323
library(shiny)
2424
@@ -32,7 +32,7 @@ server <- function(input, output, session) {
3232
simple_reporter_srv("simple", Reporter$new(), create_module_card)
3333
}
3434
35-
if (interactive()) shinyApp(ui, server)
35+
shinyApp(ui, server)
3636
```
3737

3838
## Where to next

0 commit comments

Comments
 (0)