-
Notifications
You must be signed in to change notification settings - Fork 8
Add 312-bslib-sidebar-resize #166
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
Open
gadenbuie
wants to merge
29
commits into
main
Choose a base branch
from
312-bslib-sidebar-resize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
dca0e3c
Add 312-bslib-sidebar-resize (manual app)
gadenbuie eac7185
Use `page_navbar()` for shared sidebar
gadenbuie daf5438
Programmatically test sidebar transition
gadenbuie db7723f
Generate apps deps (GitHub Actions)
gadenbuie ff5c45b
Update tests to use `diff()` and to include labels on all expectations
gadenbuie 620c85c
Merge 'origin/main' into '312-bslib-sidebar-resize'
gadenbuie 3673e29
Generate apps deps (GitHub Actions)
gadenbuie 844bf7f
Refactor test code to avoid duplication
gadenbuie 6164d43
Another small refactor for better failure backtraces
gadenbuie 9eaee9a
Add client-size htmlwidget resizing test
gadenbuie 0f8ef3c
Remove call to `browser()`
gadenbuie 247df09
Merged origin/main into 312-bslib-sidebar-resize
gadenbuie 50767b2
add debugging for windows and limit to just windows
gadenbuie 2e443c3
debug: try again
gadenbuie b78e103
debug: more output printing
gadenbuie e7ad0ed
Revert debugging changes
gadenbuie 6e42aea
Use `nav_panel()`
gadenbuie 93831c8
Rename test file
gadenbuie d0f224d
Skip transition animation tests on windows
gadenbuie eb49d67
Split out helper code, split tests into blocks
gadenbuie 09ecf09
Add README for 312
gadenbuie 38fa35c
skip on windows without help from {shinycoreci}
gadenbuie 509aca1
Merge 'origin/main' into '312-bslib-sidebar-resize'
gadenbuie 610e93c
Generate apps deps (GitHub Actions)
gadenbuie c11a494
test again after routine file changes
gadenbuie 52612da
bring back some debugging output
gadenbuie bee1c57
slow down transition to see if that helps
gadenbuie 452178b
Hide debug messages behind envvar
gadenbuie 8671d17
Add a `$wait_for_js()` to keep test in sync with browser
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
library(shiny) | ||
library(bslib) | ||
library(ggplot2) | ||
library(plotly) | ||
|
||
lorem1 <- p( | ||
"Dolor cursus quis sociis, tempus laoreet integer vel,", | ||
"nam suscipit sodales curabitur tristique. Hac massa", | ||
"fames auctor ac posuere, non: primis semper egestas!", | ||
"Porttitor interdum lobortis elementum arcu." | ||
) | ||
|
||
lorem2 <- p( | ||
"Elit aptent vivamus, eu habitasse fringilla venenatis", | ||
"viverra tellus metus. Maecenas ultrices fermentum", | ||
"nunc turpis libero nascetur!" | ||
) | ||
|
||
ui <- page_navbar( | ||
title = "312 | bslib-sidebar-resize", | ||
theme = bs_theme( | ||
"bslib-sidebar-transition-duration" = Sys.getenv("SIDEBAR_TRANSITION_TIME", "0.5s") | ||
), | ||
sidebar = sidebar( | ||
title = "Shared Sidebar", | ||
id = "sidebar-shared", | ||
open = "open", | ||
p("The plots should resize smoothly when this sidebar or the local sidebar are toggled.") | ||
), | ||
nav( | ||
"Static", | ||
h2("Static plot resizing"), | ||
p( | ||
"The plot in the layout below should stretch while the sidebar is", | ||
"opening or closing. After the transition is complete, the server will", | ||
"update the plot with the final dimensions." | ||
), | ||
layout_sidebar( | ||
sidebar = sidebar( | ||
title = "Toggle me", | ||
id = "sidebar-local-static", | ||
lorem1, lorem2, lorem1 | ||
), | ||
lorem1, | ||
plotOutput("plot_static_local"), | ||
lorem2 | ||
), | ||
h2("Shared only", class = "my-3"), | ||
p( | ||
"The next plot should resize smoothly only when the shared sidebar is transitioning." | ||
), | ||
div( | ||
class = "row", | ||
div(class = "col-6", plotOutput("plot_static_shared")), | ||
div(class = "col-6", lorem2, lorem1) | ||
) | ||
), | ||
nav( | ||
"Widget", | ||
h2("Widget plot resizing"), | ||
p( | ||
"The plot in the layout below should stretch while the sidebar is opening", | ||
"or closing. There should be no layout shift after the transition is", | ||
"complete." | ||
), | ||
layout_sidebar( | ||
sidebar = sidebar( | ||
title = "Toggle me", | ||
id = "sidebar-local-widget", | ||
lorem1, lorem2, lorem1 | ||
), | ||
lorem1, | ||
plotlyOutput("plot_widget_local"), | ||
lorem2 | ||
), | ||
h2("Shared only", class = "my-3"), | ||
p( | ||
"The next plot should resize smoothly only when the shared sidebar is transitioning." | ||
), | ||
div( | ||
class = "row", | ||
div(class = "col-6", plotlyOutput("plot_widget_shared")), | ||
div(class = "col-6", lorem2, lorem1) | ||
) | ||
), | ||
nav( | ||
"Client", | ||
h2("Client-side htmlwidget resizing"), | ||
p( | ||
"The plot in the layout below should stretch while the sidebar is opening", | ||
"or closing. There should be no layout shift after the transition is", | ||
"complete." | ||
), | ||
layout_sidebar( | ||
sidebar = sidebar( | ||
title = "Toggle me", | ||
id = "sidebar-local-client", | ||
lorem1, lorem2, lorem1 | ||
), | ||
lorem1, | ||
div(id = "plot_client_local", plot_ly(x = rnorm(100))), | ||
lorem2 | ||
), | ||
h2("Shared only", class = "my-3"), | ||
p( | ||
"The next plot should resize smoothly only when the shared sidebar is transitioning." | ||
), | ||
div( | ||
class = "row", | ||
div( | ||
class = "col-6", | ||
div(id = "plot_client_shared", plot_ly(x = rnorm(100))) | ||
), | ||
div(class = "col-6", lorem2, lorem1) | ||
) | ||
), | ||
footer = div(style = "min-height: 100vh") | ||
) | ||
|
||
server <- function(input, output, session) { | ||
plot <- reactive({ | ||
ggplot(mtcars, aes(mpg, wt)) + | ||
geom_point(aes(color = factor(cyl))) + | ||
labs( | ||
title = "Cars go brrrrr", | ||
x = "Miles per gallon", | ||
y = "Weight (tons)", | ||
color = "Cylinders" | ||
) + | ||
theme_gray(base_size = 16) | ||
}) | ||
|
||
output$plot_static_local <- renderPlot(plot()) | ||
output$plot_static_shared <- renderPlot(plot()) | ||
|
||
output$plot_widget_local <- renderPlotly(ggplotly(plot())) | ||
output$plot_widget_shared <- renderPlotly(ggplotly(plot())) | ||
} | ||
|
||
shinyApp(ui, server) |
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 @@ | ||
shinytest2::test_app() |
2 changes: 2 additions & 0 deletions
2
inst/apps/312-bslib-sidebar-resize/tests/testthat/setup-shinytest2.R
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,2 @@ | ||
# Load application support files into testing environment | ||
shinytest2::load_app_env() |
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.