Skip to content
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

The diffrOutput() width parameter is not able to use 100% of the available width #6

Open
nhward opened this issue May 28, 2024 · 2 comments

Comments

@nhward
Copy link

nhward commented May 28, 2024

The shiny widget that wraps the diffr comparator is excellent. A fine piece of work that is much appreciated. :)

Sadly the width parameter (of diffrOutput) does not allow the widget to be drawn within more than 50% of the available width. Using larger values does bring a horizontal slider into play which suggests that the widget is indeed the size it is asked to be. However the widget is always drawn on the first 50% of available width.

Changing the font size of the browser does improve things. However, it should do as it claims at 100% zoom.

Reprex below:

library(shiny)
library(diffr)
library(dplyr)

ui <- fluidPage(
   diffr::diffrOutput(outputId = "Iris", width = "400%") ## here I am using 400% but only 50% is used for the widget display
)

server <- function(input, output) {

  output$Iris <- diffr::renderDiffr({
    data(iris)
    f1 <- tempfile()
    f2 <- tempfile()
    capture.output(
      dplyr::glimpse(iris, width = 120),
      file = f1
    )
    capture.output(
      dplyr::glimpse(rev(iris), width = 120),
      file = f2
    )
    diffr::diffr(f1, f2, wordWrap = TRUE)
  })
}

# Run the application
shinyApp(ui = ui, server = server)

While this Reprex is using the browser size, my actual use-case involves bslib::cards that switch between card and full screen. The lack of genuine full screen sizing (at 100%) is problematic.

@muschellij2
Copy link
Owner

Can you try with the new version:

remotes::install_github("muschellij2/diffr")

(Reboot R)

library(shiny)
library(diffr)
library(dplyr)

ui <- fluidPage(
   diffr::diffrOutput(outputId = "Iris", width = "400%") ## here I am using 400% but only 50% is used for the widget display
)

server <- function(input, output) {

  output$Iris <- diffr::renderDiffr({
    data(iris)
    f1 <- tempfile()
    f2 <- tempfile()
    capture.output(
      dplyr::glimpse(iris, width = 120),
      file = f1
    )
    capture.output(
      dplyr::glimpse(rev(iris), width = 120),
      file = f2
    )
    diffr::diffr(f1, f2, wordWrap = TRUE)
  })
}

# Run the application
shinyApp(ui = ui, server = server)

@nhward
Copy link
Author

nhward commented Jun 2, 2024

That was a quick reply.
The shiny control does now occupy the full width available. See my app's screenshot below.

There is quite a bit of wasted space (grey coloured) either side of the main box. I hoped that the actual box might go from edge to edge. I am using width = "100%" for both the diffr() and the diffrOutput() calls. The position of the "original" label is curious.

Screenshot from 2024-06-02 13-18-11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants