Skip to content

Commit

Permalink
feat: add tick when copy text
Browse files Browse the repository at this point in the history
  • Loading branch information
ESCRI11 committed Jul 8, 2024
1 parent 73dc05f commit 2244ba3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/app/R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ app_ui <- function(x) {
## gtag2, ## Google Tag Manager???
shiny::tags$head(shiny::tags$script(src = "custom/temp.js")),
shiny::tags$head(shiny::tags$script(src = "static/copy-info-helper.js")),
shiny::tags$head(shiny::tags$script(src = "static/add-tick-helper.js")),
shiny::tags$head(shiny::tags$script(src = "custom/dropdown-helper.js")),
shiny::tags$head(shiny::tags$link(rel = "stylesheet", href = "custom/styles.min.css")),
shiny::tags$head(shiny::tags$link(rel = "shortcut icon", href = "custom/favicon.ico")),
Expand Down
12 changes: 12 additions & 0 deletions components/app/R/www/add-tick-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function addTick(buttonId) {
var button = document.getElementById(buttonId);
var originalText = button.innerHTML;
button.innerHTML = originalText + '<span class=\"tick\"> ✓</span>';
button.classList.add('show-tick');
setTimeout(function() {
button.classList.remove('show-tick');
setTimeout(function() {
button.innerHTML = originalText;
}, 500); // Match this duration with CSS transition duration
}, 1000);
}
9 changes: 9 additions & 0 deletions components/ui/ui-PlotModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,15 @@ PlotModuleServer <- function(id,
)]] <- render2
}

shiny::observeEvent(input$copy_info, {
shinyjs::runjs(
paste0(
"addTick('",
ns("copy_info"),
"')"
)
)
})


## --------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions dev/board.launch/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ app_ui <- function() {
shiny::tags$head(shiny::tags$script(src = "static/test_trigger.js")),
shiny::tags$head(shiny::tags$script(src = "static/dropdown-extra.js")),
shiny::tags$head(shiny::tags$script(src = "static/copy-info-helper.js")),
shiny::tags$head(shiny::tags$script(src = "static/add-tick-helper.js")),
shiny::tags$head(shiny::tags$link(rel = "stylesheet", href = "static/styles.min.css")),
shiny::tags$head(shiny::tags$link(rel = "shortcut icon", href = "static/favicon.ico")),
shinyjs::useShinyjs(),
Expand Down

0 comments on commit 2244ba3

Please sign in to comment.