-
Notifications
You must be signed in to change notification settings - Fork 64
feat: Add toolbar buttons #1256
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 14 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
374f757
Initial toolbar container
elnelson575 ed1a07e
Updates
elnelson575 04bd68b
Minor updates
elnelson575 8f6d6f1
Added tests
elnelson575 6389307
Updated news
elnelson575 c7d70e6
Removing example:
elnelson575 3f8b630
Adding snaps
elnelson575 1abed04
Adding a few comments
elnelson575 5fd9254
Update to toolbar testing
elnelson575 c2289a3
Fix dots in toolbar function
elnelson575 b23fc17
updates to dots
elnelson575 d2eb240
Merge branch 'feat/toolbar-container' of https://github.com/rstudio/b…
elnelson575 0836374
Update R/toolbar.R
elnelson575 a55d03f
Update inst/components/scss/toolbar.scss
elnelson575 0afabf4
Update inst/components/scss/toolbar.scss
elnelson575 e6e9d88
Update inst/components/scss/toolbar.scss
elnelson575 626af55
Adding input buttons
elnelson575 180319a
Added disabled option
elnelson575 478f5e1
Merge remote-tracking branch 'origin/main' into feat/toolbar-container
elnelson575 0340d21
Merge remote-tracking branch 'origin/main' into feat/toolbar-container
elnelson575 f898670
Updated code
elnelson575 899b644
minor formatting changes
elnelson575 6a3ccfe
Adding footer back
elnelson575 88f00d8
Docs changes
elnelson575 df309bf
Updating footer, updating tests
elnelson575 d69e3e8
Merge branch 'feat/toolbar-container' into feature/add-buttons
elnelson575 ef468d1
Updating button spacing
elnelson575 78372c1
Reformat spacing
elnelson575 652a061
Merging in toolbar/epic
elnelson575 0c0f895
Fixed button sizing, changing to also incorperate label+icon
elnelson575 3ce0b20
Updated card header and font sizing
elnelson575 cf585de
Updated footer, updated gap
elnelson575 a6250a6
Updating tests
elnelson575 8f3ab2d
Updating tests
elnelson575 fa866ba
Update headings in bs-theme-preset.md
elnelson575 06177d6
Update header format in bs-theme-preset-builtin.md
elnelson575 b49322b
Add back deleted file
elnelson575 c5f3dd6
Merge branch 'feature/add-buttons' of https://github.com/rstudio/bsli…
elnelson575 cd2a746
removing comment
elnelson575 cc601fb
Fix tests
elnelson575 25c6027
Update card.scss
elnelson575 e6fac9a
Fixing diff
elnelson575 c5d9e38
Slim down icon button formatting
elnelson575 37b9855
Clean up scss
elnelson575 16acb76
Fixing diff
elnelson575 5ed4321
Removing accidental legacy addition
elnelson575 85bad5e
Merge branch 'feature/add-buttons' of https://github.com/rstudio/bsli…
elnelson575 5531572
Apply suggestions from code review
elnelson575 b8d66d5
Updating with edits based on comments
elnelson575 8159db8
Update DESCRIPTION
elnelson575 e40b9e7
Updated function signature for buttons, updated scss for showing/hidi…
elnelson575 270262b
Update padding
elnelson575 5caa62d
Make the buttons just a little bit smaller
elnelson575 ebdade5
Update based on comments
elnelson575 e69b102
Update R/toolbar.R
elnelson575 704bfad
Update toolbar.R
elnelson575 7db177c
Merge branch 'feature/add-buttons' of https://github.com/rstudio/bsli…
elnelson575 f85fb88
Updated button type determination
elnelson575 a00ca8c
Update tooltip wording
elnelson575 f902a26
Updates - pending final validation
elnelson575 691edba
Remove aria labels from icons when they're in labels
elnelson575 b074585
Updated label
elnelson575 d0320ee
Updates to labels
elnelson575 a56c081
Update btn type logic
elnelson575 5a17493
Update scss and minor polish
elnelson575 7da07ad
Merge branch 'feature/add-buttons' of https://github.com/rstudio/bsli…
elnelson575 75c308a
Fixing private seed
elnelson575 6fc2aff
Update comments
elnelson575 edd40c5
Syntax change to reflect this is helpful regardless of if show_label …
elnelson575 06ede8a
Update comment
elnelson575 c5cf139
Update R/toolbar.R
elnelson575 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
Some comments aren't visible on the classic Files Changed page.
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
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,77 @@ | ||
| #' Add a toolbar to a UI element | ||
| #' | ||
| #' @description | ||
| #' A toolbar which can contain buttons, inputs, and other UI elements | ||
| #' in a small form suitable for inclusion in card headers, | ||
| #' footers, and other small places. | ||
| #' | ||
| #' @param ... UI elements for the toolbar. | ||
| #' @param align Determines if toolbar should be aligned to the right or left. | ||
| #' Must be one of "right" or "left". | ||
| #' @param size The size of the toolbar. Must be one of "sm", "md", or "lg". | ||
| #' | ||
| #' @return Returns a toolbar. | ||
| #' | ||
| #' @export | ||
| toolbar <- function( | ||
| ..., | ||
| align = c("right", "left"), | ||
| size = c("sm", "md", "lg") | ||
| ) { | ||
| align <- rlang::arg_match(align) | ||
| size <- rlang::arg_match(size) | ||
|
|
||
| tag <- div( | ||
| class = "bslib-toolbar", | ||
| "data-align" = align, | ||
| "data-size" = size, | ||
| ..., | ||
| component_dependencies() | ||
| ) | ||
|
|
||
| tag_require(tag, version = 5, caller = "toolbar()") | ||
| as_fragment(tag) | ||
| } | ||
|
|
||
| #' Add toolbar button input | ||
| #' | ||
| #' @description | ||
| #' A button designed to fit well in small places such as toolbars. | ||
| #' | ||
| #' @param id The `input` slot that will be used to access the value. | ||
elnelson575 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #' @param ... UI elements for the button. | ||
| #' @param icon An icon to display in the button. | ||
| #' (One of icon or label must be supplied.) | ||
elnelson575 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #' @param label The label to display in the button. | ||
| #' (One of icon or label must be supplied.) | ||
| #' @param border Whether to show a border around the button. | ||
| #' @param disabled If `TRUE`, the button will not be clickable. Use `updateActionButton()` to dynamically enable/disable the button. | ||
| #' | ||
| #' @return Returns a button suitable for use in a toolbar. | ||
elnelson575 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #' | ||
elnelson575 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #' @export | ||
| toolbar_input_button <- function( | ||
| id, | ||
| ..., | ||
| icon = NULL, | ||
| label = NULL, | ||
| border = FALSE, | ||
| disabled = FALSE | ||
| ) { | ||
| if (is.null(icon) && is.null(label)) { | ||
| stop( | ||
| "At least one of 'icon' or 'label' must be provided.", | ||
| call. = TRUE | ||
| ) | ||
| } | ||
|
|
||
elnelson575 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| shiny::actionButton( | ||
| id, | ||
| label = label, | ||
| icon = icon, | ||
| disabled = disabled, | ||
| class = "bslib-toolbar-input-button btn-sm", | ||
| class = if (!border) "border-0" else NULL, | ||
elnelson575 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ... | ||
| ) | ||
| } | ||
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,67 @@ | ||
| /* Toolbar */ | ||
| .bslib-toolbar { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 0.5rem; | ||
|
|
||
| /* Toolbar options */ | ||
|
|
||
| &[data-align="left"] { | ||
| margin-right: auto; | ||
| align-items: flex-start; | ||
| } | ||
|
|
||
| &[data-align="right"] { | ||
| margin-left: auto; | ||
| align-items: flex-end; | ||
| } | ||
|
|
||
elnelson575 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| &[data-size="sm"] { | ||
| font-size: 0.8rem; | ||
|
|
||
| & > * { | ||
| font-size: 0.8rem; | ||
| } | ||
| } | ||
|
|
||
| &[data-size="md"] { | ||
| font-size: 1rem; | ||
|
|
||
| & > * { | ||
| font-size: 1rem; | ||
| } | ||
| } | ||
|
|
||
| &[data-size="lg"] { | ||
| font-size: 1.25rem; | ||
|
|
||
| & > * { | ||
| font-size: 1.25rem; | ||
| } | ||
| } | ||
|
|
||
| /* Adjustments to other elements */ | ||
|
|
||
| &, | ||
| &>* { | ||
| margin-bottom: 0 !important; | ||
| width: auto; | ||
| } | ||
|
|
||
| /* Ensures that inputs inherit the formatting of the toolbar and align correctly */ | ||
| >.form-group.shiny-input-container, .form-group.shiny-input-container>* { | ||
| width: auto; | ||
| margin-bottom: 0; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| /* Ensure card headers with toolbars use flexbox for alignment */ | ||
| .card-header:has(> &) { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| .card-footer:has(> &) { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
| # toolbar() markup snapshots | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2")) | ||
| Output | ||
| <div class="bslib-toolbar" data-align="right" data-size="sm"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2", align = "left")) | ||
| Output | ||
| <div class="bslib-toolbar" data-align="left" data-size="sm"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2", size = "md")) | ||
| Output | ||
| <div class="bslib-toolbar" data-align="right" data-size="md"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
||
| # toolbar_input_button() markup snapshots | ||
|
|
||
| Code | ||
| show_raw_html(toolbar_input_button(id = "btn1", label = "Click me")) | ||
| Output | ||
| <button class="btn btn-default action-button bslib-toolbar-input-button btn-sm border-0" id="btn1" type="button">Click me</button> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar_input_button(id = "btn2", icon = shiny::icon("star"))) | ||
| Output | ||
| <button class="btn btn-default action-button bslib-toolbar-input-button btn-sm border-0" id="btn2" type="button"> | ||
| <i class="far fa-star" role="presentation" aria-label="star icon"></i> | ||
| </button> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar_input_button(id = "btn3", label = "Save", icon = shiny::icon( | ||
| "save"))) | ||
| Output | ||
| <button class="btn btn-default action-button bslib-toolbar-input-button btn-sm border-0" id="btn3" type="button"> | ||
| <i class="far fa-floppy-disk" role="presentation" aria-label="floppy-disk icon"></i> | ||
| Save | ||
| </button> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar_input_button(id = "btn4", label = "Delete", class = "btn-danger")) | ||
| Output | ||
| <button class="btn btn-default action-button bslib-toolbar-input-button btn-sm border-0 btn-danger" id="btn4" type="button">Delete</button> | ||
|
|
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.