-
Notifications
You must be signed in to change notification settings - Fork 65
feat: Add Toolbar #1250
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
feat: Add Toolbar #1250
Changes from all commits
Commits
Show all changes
39 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 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 68b7006
chore: air format tests/testthat/test-toolbar.R
gadenbuie 3a9b59e
Merge 'origin/main' into branch feat/toolbar-container
gadenbuie 12db810
Spacing
elnelson575 10ba431
Merge branch 'feat/toolbar-container' of https://github.com/rstudio/b…
elnelson575 87cbf1d
Updating comments
elnelson575 6be96cb
Removed select formatting to be addressed in select input PR
elnelson575 d16f727
Update tests/testthat/test-toolbar.R
elnelson575 3d7d9f0
Update tests/testthat/test-toolbar.R
elnelson575 3cc95fe
Updated tests
elnelson575 d9a5bf0
Updating formatting
elnelson575 9357091
Update tests/testthat/test-toolbar.R
elnelson575 e147457
Updated blocking
elnelson575 7b81e5d
Updated tests
elnelson575 1aaa67b
Dealing with merge conflicts
elnelson575 d03af3d
Update markdown headers in bs-theme-preset.md
elnelson575 6a79efe
Update header format in bs-theme-preset-builtin.md
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,28 @@ | ||
| #' Toolbar component | ||
| #' | ||
| #' @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"`. | ||
| #' @return Returns a toolbar element. | ||
| #' | ||
| #' @export | ||
| toolbar <- function( | ||
| ..., | ||
| align = c("right", "left") | ||
| ) { | ||
| align <- rlang::arg_match(align) | ||
|
|
||
| tag <- div( | ||
| class = "bslib-toolbar bslib-gap-spacing", | ||
| "data-align" = align, | ||
| ..., | ||
| component_dependencies() | ||
| ) | ||
|
|
||
| tag_require(tag, version = 5, caller = "toolbar()") | ||
| as_fragment(tag) | ||
| } |
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,36 @@ | ||
| /* Toolbar */ | ||
| .bslib-toolbar { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
| /* ---- Toolbar options ---- */ | ||
|
|
||
| &[data-align="left"] { | ||
| margin-right: auto; | ||
| } | ||
|
|
||
| &[data-align="right"] { | ||
| margin-left: auto; | ||
| } | ||
|
|
||
| /* ---- Adjustments to other elements ---- */ | ||
|
|
||
| // Ensures uniformity of font sizing in elements and sub-elements (e.g., input select) | ||
| &, | ||
| & * { | ||
| font-size: 0.8rem; | ||
| } | ||
|
|
||
| &>* { | ||
| margin-bottom: 0 !important; | ||
| width: auto; | ||
| align-self: center; | ||
| } | ||
|
|
||
| // Card header is flex by default, but card footer is not and must be in order for | ||
| // toolbar alignment to work | ||
| .card-footer:has(> &) { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
gadenbuie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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,30 @@ | ||
| # toolbar() basic attributes and defaults | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2")) | ||
| Output | ||
| <div class="bslib-toolbar bslib-gap-spacing" data-align="right"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
||
| # toolbar() aligns correctly | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2", align = "left")) | ||
| Output | ||
| <div class="bslib-toolbar bslib-gap-spacing" data-align="left"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
||
| --- | ||
|
|
||
| Code | ||
| show_raw_html(toolbar("Item 1", "Item 2", align = "right")) | ||
| Output | ||
| <div class="bslib-toolbar bslib-gap-spacing" data-align="right"> | ||
| Item 1 | ||
| Item 2 | ||
| </div> | ||
|
|
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,9 @@ | ||
| show_raw_html <- function(x) { | ||
| cat(format(x)) | ||
| } | ||
|
|
||
| expect_snapshot_html <- function(x, .envir = parent.frame()) { | ||
| x_str <- deparse(substitute(x)) | ||
| code <- parse(text = sprintf("expect_snapshot(show_raw_html(%s))", x_str)) | ||
| eval(code, envir = .envir) | ||
| } |
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,20 @@ | ||
| test_that("toolbar() basic attributes and defaults", { | ||
| tb <- as.tags(toolbar(htmltools::span("Test"))) | ||
| expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") | ||
| expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") | ||
| expect_snapshot_html( | ||
| toolbar("Item 1", "Item 2") | ||
| ) | ||
| }) | ||
|
|
||
| test_that("toolbar() aligns correctly", { | ||
| tb <- as.tags(toolbar(align = "left")) | ||
| expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") | ||
| expect_snapshot_html( | ||
| toolbar("Item 1", "Item 2", align = "left") | ||
| ) | ||
| expect_snapshot_html( | ||
| toolbar("Item 1", "Item 2", align = "right") | ||
| ) | ||
| expect_error(toolbar("x", align = "center")) | ||
| }) |
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.