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

shinyWidgets::switchInput under bs_theme(version="3") vs NULL #528

Closed
Polkas opened this issue Sep 6, 2022 · 3 comments
Closed

shinyWidgets::switchInput under bs_theme(version="3") vs NULL #528

Polkas opened this issue Sep 6, 2022 · 3 comments

Comments

@Polkas
Copy link

Polkas commented Sep 6, 2022

Not sure who is responsible so I create a similar issue in the bslib.

So bs_theme(version="3") should work the same as NULL for the theme argument in the shiny::fluidPage.
Unfortunately shinyWidgets::switchInput is crashing the shiny app when bs_theme(version="3") is used, and not when NULL is used.

minimal example:

library(shiny)

ui <- fluidPage(
  theme = bslib::bs_theme(version = "3"), # when NULL it is ok
  shinyWidgets::switchInput("sth", "sth")
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)

Error message:

Listening on http://127.0.0.1:3630
Warning: Error in compile_data: Error: Undefined variable: "$secondary".
        on line 69:16 of ../../../../Library/Frameworks/R.framework/Versions/4.2/Resources/library/shinyWidgets/assets/bootstrap-switch/bootstrap-switch-3.4/bootstrap-switch.scss
        from line 11:9 of stdin
>> 			background: $secondary;

   ---------------^

  3: runApp
  2: print.shiny.appobj
  1: <Anonymous>

sessionInfo:

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] shiny_1.7.2          ...            

loaded via a namespace (and not attached):
 [1] bslib_0.4.0     ...
[81] shinyWidgets_0.7.3 
@Polkas
Copy link
Author

Polkas commented Sep 7, 2022

This assumption does not seem to be correct

// Unnecessary in shinyWidgets
// @import "../bootstrap-4.2.1/functions";
// @import "../bootstrap-4.2.1/variables";

as for bslib::bs_theme(version="3") it will be not inherited with proper sass color variables.

@pvictor
Copy link
Member

pvictor commented Sep 7, 2022

Thanks for rreporting. It seems related to SCSS variable secondary that doesn't exist in BS 3, only in BS >= 4, but it's used here in Bootstrap Switch SCSS code :


I think it will be sufficient to create the variable here with the other
"danger" = "$brand-danger"
to make it work, for example with "secondary" = "$gray-base" (default to gray).

@pvictor pvictor closed this as completed in d82d8ad Sep 7, 2022
@pvictor
Copy link
Member

pvictor commented Sep 7, 2022

That's fixed, re-install from GitHub :

remotes::install_github("dreamRs/shinyWidgets")

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