-
Notifications
You must be signed in to change notification settings - Fork 65
feat(build-a-box): Add example value box builder app #790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
8c4e1b9
feat(build-a-box): Add example value box builder app
gadenbuie fd38020
Update website deps (GitHub Action)
gadenbuie 193a286
feat(build-a-box): Add copy to clipboard button
gadenbuie 4d3c2c3
chore: Remove debug code
gadenbuie 6e52864
refactor: `code_modal()`
gadenbuie 4e3d688
feat: Remove `extra` args from `value_box()` call if `NULL`
gadenbuie 79be900
refactor: Only value box foreground color is reported back to server
gadenbuie 7af830d
chore: use monospace for extra info
gadenbuie 805146b
TEMP: deploy shiny apps (REVERT BEFORE MERGING)
gadenbuie 5d4e54c
Resave data (GitHub Action)
gadenbuie cae48a3
ci: Deploy anything with a `deploy.R`
gadenbuie de99f41
chore: remove unused js file
gadenbuie 0ada949
fix: clipboard fallback behavior
gadenbuie 8dd8603
feat: global controls
gadenbuie da3723f
chore: Enable themer on the demo site
gadenbuie e692d9d
refactor: Move global settings into module
gadenbuie c7c60bf
ci: shinyapps.io doesn't support `envVars`
gadenbuie 91b5da3
cI: Register additional public shinyapps.io account
gadenbuie 9e34a32
ci: use latest {rsconnect}
gadenbuie 079bcd7
ci: Don't need to make account name secret
gadenbuie f1fa393
ci: Deploy build-a-box to bslib.shinyapps.io
gadenbuie f8908ed
Merged origin/main into feat/box-builder
gadenbuie e258656
feat: Add dark mode switcher
gadenbuie 17f6a0b
fix: incomplete reset of file
gadenbuie 492b691
chore: Don't need clipboard.min.js at all
gadenbuie 8d77f40
fix: prefix call to `css()`
gadenbuie 6f6b818
fix: order of value boxes in the code
gadenbuie 3a24f15
refactor: Move code-modal.js to new file
gadenbuie edd19d1
chore: remove unneeded gap
gadenbuie 4b0a99a
chore: use `bs_theme() |> bs_add_rules()`
gadenbuie 9af4808
feat: Add footer
gadenbuie 1e22827
feat: Add a tooltip with info about value_box()
gadenbuie 7048996
Resave distributed files (GitHub Action)
gadenbuie 892502a
chore: add title to button
gadenbuie 672a5b0
Resave distributed files (GitHub Action)
gadenbuie e1c27a7
feat: random theme when changing the global theme style
gadenbuie 67c642a
chore: tweak wording of "Use custom colors" and "Include showcase"
gadenbuie 6ba9d2a
chore: Use radioButtons in global settings too
gadenbuie c58dc4e
Resave distributed files (GitHub Action)
gadenbuie d327273
chore: Add {commonmark} to deploy dependencies
gadenbuie 9b431d3
Resave distributed files (GitHub Action)
gadenbuie 5ba05f1
Update website deps (GitHub Action)
gadenbuie c904328
chore: use {commonmark} instead of includeMarkdown
gadenbuie 42c10c8
Resave distributed files (GitHub Action)
gadenbuie 1204793
feat: Add get started popover help box
gadenbuie 8c0fb87
chore: tweak wording
gadenbuie 55a06cf
chore: Add default to theme styles, remove default button
gadenbuie 485f593
Resave distributed files (GitHub Action)
gadenbuie a4d88d9
feat: Add loading value box placeholders
gadenbuie 87f00a1
Resave distributed files (GitHub Action)
gadenbuie 81379a7
feat: improve placeholder location/appearance
gadenbuie e448474
Resave distributed files (GitHub Action)
gadenbuie 4198fba
feat: another approach to the loading state
gadenbuie b122b8a
Resave distributed files (GitHub Action)
gadenbuie c196319
Add note about expandable sparklines
gadenbuie 474bccb
ci: don't prefix scss files in inst/examples
gadenbuie 139e63c
docs(value_box): Add note linking to build-a-box app
gadenbuie a0f0035
docs(pkgdown): Add link ot build a box app in article
gadenbuie 19b3a59
Merged origin/main into feat/box-builder
gadenbuie e84e12e
Revert "TEMP: deploy shiny apps (REVERT BEFORE MERGING)"
gadenbuie 9a64df9
feat: make "navbar" like icon action area
gadenbuie 1984536
feat: update plot colors when dark mode changes
gadenbuie 809688d
chore: add rstudio/shiny to deploy dependencies
gadenbuie f6288b3
docs: add news item
gadenbuie 5dbd884
Merge branch 'main' into feat/box-builder
gadenbuie 62dc060
Resave data (GitHub Action)
gadenbuie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| code_modal <- function(code) { | ||
| if (rlang::is_call(code)) { | ||
| code <- rlang::expr_text(code) | ||
| } | ||
|
|
||
| if (requireNamespace("styler", quietly = TRUE)) { | ||
| code <- styler::style_text(code) | ||
| } | ||
|
|
||
| code <- paste(code, collapse = "\n") | ||
|
|
||
| showModal( | ||
| modalDialog( | ||
| HTML(sprintf( | ||
| '<pre><code id="value-box-code">%s</code></pre>', | ||
| code | ||
| )), | ||
| p( | ||
| id = "copy-clipboard-not-supported", | ||
| class = "text-muted d-none", | ||
| HTML("Press <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>C</kbd> to copy the value box example code.") | ||
| ), | ||
| tags$button( | ||
| id = "copy-code-to-clipboard", | ||
| class = "btn btn-outline-primary", | ||
| onclick = "copyValueBoxCode()", | ||
| "Copy to clipboard" | ||
| ), | ||
| singleton(tags$script(src = "code-modal.js")), | ||
| footer = modalButton("Done"), | ||
| easyClose = TRUE | ||
| ) | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| theme_colors <- list( | ||
| "primary", | ||
| "secondary", | ||
| "success", | ||
| "danger", | ||
| "warning", | ||
| "info", | ||
| "light", | ||
| "dark" | ||
| ) | ||
|
|
||
| named_colors <- c( | ||
| "blue", | ||
| "indigo", | ||
| "purple", | ||
| "pink", | ||
| "red", | ||
| "orange", | ||
| "yellow", | ||
| "green", | ||
| "teal", | ||
| "cyan" | ||
| ) | ||
|
|
||
| gc <- expand.grid(named_colors, named_colors) | ||
| gc <- gc[gc$Var1 != gc$Var2,] | ||
| gradient_classes <- sprintf("bg-gradient-%s-%s", gc$Var1, gc$Var2) | ||
|
|
||
|
|
||
| all_themes <- c( | ||
| "Default" = "", | ||
| theme_colors, | ||
| named_colors, | ||
| paste0("text-", theme_colors), | ||
| paste0("text-", named_colors), | ||
| sort(gradient_classes) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| ui_global_controls <- function(id) { | ||
| ns <- shiny::NS(id) | ||
|
|
||
| tagList( | ||
| layout_columns( | ||
| class = "align-items-end", | ||
| selectizeInput( | ||
| ns("theme_style"), | ||
| "Theme style", | ||
| list( | ||
| "Default" = "default", | ||
| "All" = "all", | ||
| "Semantic Colors" = list( | ||
| "Semantic Background" = "semantic-bg", | ||
| "Semantic Text" = "semantic-fg" | ||
| ), | ||
| "Theme Colors" = list( | ||
| "Colored Background" = "colors-bg", | ||
| "Colored Text" = "colors-fg" | ||
| ), | ||
| "Vibrant" = list( | ||
| "Gradient Background" = "gradient" | ||
| ) | ||
| ) | ||
| ), | ||
| shuffleButton(ns("random_theme"), "Theme"), | ||
| shuffleButton(ns("random_stat"), "Stats") | ||
| ), | ||
| layout_columns( | ||
| class = "align-items-start", | ||
| div( | ||
| radioButtons( | ||
| ns("showcase_item"), | ||
| "Showcase Item", | ||
| choices = c("Plot", "Icon"), | ||
| inline = TRUE | ||
| ), | ||
| conditionalPanel( | ||
| "input.showcase_item == 'Plot'", | ||
| ns = ns, | ||
| p( | ||
| class = "text-muted", | ||
| "See", | ||
| tags$a(href = "https://rstudio.github.io/bslib/articles/value-boxes/index.html#expandable-sparklines", "Expandable Sparklines"), | ||
| "for example plot code." | ||
| ) | ||
| ), | ||
| conditionalPanel( | ||
| "input.showcase_item == 'Icon'", | ||
| ns = ns, | ||
| shuffleButton(ns("random_icon"), "Icons") | ||
| ) | ||
| ), | ||
| radioButtons( | ||
| ns("showcase_layout"), | ||
| "Showcase Layout", | ||
| choices = c("Left center", "Top right", "Bottom"), | ||
| inline = TRUE | ||
| ) | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| server_global_controls <- function(input, output, sessions, one, two, three) { | ||
| observeEvent(c(input$random_theme, input$theme_style), { | ||
| new_values <- switch( | ||
| input$theme_style, | ||
| all = { | ||
| one$theme$shuffle() | ||
| two$theme$shuffle() | ||
| three$theme$shuffle() | ||
| NULL | ||
| }, | ||
| default = { | ||
| one$theme$set("Default") | ||
| two$theme$set("Default") | ||
| three$theme$set("Default") | ||
| NULL | ||
| }, | ||
| "semantic-bg" = sample(setdiff(theme_colors, c("light", "dark")), 3), | ||
| "semantic-fg" = paste0("text-", sample(setdiff(theme_colors, c("light", "dark")), 3)), | ||
| "colors-bg" = sample(named_colors, 3, replace = TRUE), | ||
| "colors-fg" = paste0("text-", sample(named_colors, 3, replace = TRUE)), | ||
| gradient = sample(gradient_classes, 3) | ||
| ) | ||
|
|
||
| if (is.null(new_values)) return() | ||
|
|
||
| one$theme$set(new_values[[1]]) | ||
| two$theme$set(new_values[[2]]) | ||
| three$theme$set(new_values[[3]]) | ||
| }, ignoreInit = TRUE) | ||
|
|
||
| observeEvent(input$random_stat, { | ||
| one$random_stat() | ||
| two$random_stat() | ||
| three$random_stat() | ||
| }) | ||
|
|
||
| observeEvent(input$random_icon, { | ||
| one$showcase_icon$shuffle() | ||
| two$showcase_icon$shuffle() | ||
| three$showcase_icon$shuffle() | ||
| }) | ||
|
|
||
| observeEvent(input$showcase_item, { | ||
| item <- tolower(input$showcase_item) | ||
| one$set_showcase_item(item) | ||
| two$set_showcase_item(item) | ||
| three$set_showcase_item(item) | ||
| }, ignoreInit = TRUE) | ||
|
|
||
| observeEvent(input$showcase_layout, { | ||
| layout <- tolower(input$showcase_layout) | ||
| one$set_showcase_layout(layout) | ||
| two$set_showcase_layout(layout) | ||
| three$set_showcase_layout(layout) | ||
| }, ignoreInit = TRUE) | ||
| } | ||
|
|
||
| module_global_controls <- function(id, one, two, three) { | ||
| callModule(server_global_controls, id, one = one, two = two, three = three) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.