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

fix(shiny.scss): Constrain notification panel to max-width: 100% #3949

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Nov 30, 2023

For posit-dev/py-shiny#832 by placing max-width: 100% on the #shiny-notification-panel.

Example/test app
library(shiny)
library(bslib)

ui <- #fixedPage(
  page_fixed(
  theme = bs_theme(5, preset = "shiny"),
  input_dark_mode(mode = "dark"),
  layout_column_wrap(
    width = 1/4,
    style = htmltools::css(margin_top = "1em"),
    !!!lapply(
      c("Default", "Message", "Warning", "Error"),
      \(x) actionButton(
        inputId = tolower(x),
        label = paste("New", x),
        width = "100%",
        class = switch(
          x,
          Default = NULL,
          Message = "btn-info",
          Warning = "btn-warning",
          Error = "btn-danger"
        ),
        class = "btn-sm"
      )
    )
  )
)

server <- function(input, output, session) {
  types <- c("default", "message", "warning", "error")
  lapply(types, \(type) {
    observeEvent(input[[type]], {
      showNotification(
        paste(
          "This is a", type, "notification.",
          paste(lorem::ipsum(1, 1, 4))
        ),
        type = type,
        duration = NULL
      )
    })
  })
}

shinyApp(ui, server)

@gadenbuie gadenbuie requested a review from cpsievert November 30, 2023 20:41
@gadenbuie gadenbuie changed the title fix(shiny.scss): Constrain notification panel to max_width: 100% fix(shiny.scss): Constrain notification panel to max-width: 100% Nov 30, 2023
Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@gadenbuie gadenbuie merged commit 01705c1 into main Nov 30, 2023
11 checks passed
@gadenbuie gadenbuie deleted the fix/shiny-notifications-max-width branch November 30, 2023 21: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

Successfully merging this pull request may close these issues.

2 participants