Skip to content

Tippy#40

Merged
andyquinterom merged 7 commits intomainfrom
tippy
Sep 14, 2023
Merged

Tippy#40
andyquinterom merged 7 commits intomainfrom
tippy

Conversation

@andyquinterom
Copy link
Copy Markdown
Contributor

@andyquinterom andyquinterom commented Sep 13, 2023

Issue #29

Changes description

  • Adds tooltips to headers with Tippy JS!

Example:

library(shiny)
library(reactable)
library(reactable.extras)
string_list <- function(values) {
  paste0(
    "{", paste0(names(values), " : ", unlist(values), collapse = ", "), "}"
  )
}

df <- MASS::Cars93[, 1:4]
df$Date <- sample(seq(as.Date("2020/01/01"),
                      as.Date("2023/01/01"),
                      by = "day"),
                  nrow(df))
df$Check <- sample(c(TRUE, FALSE), nrow(df), TRUE)

shinyApp(
  ui = fluidPage(
    reactable.extras::reactable_extras_dependency(),
    reactable_extras_ui("table"),
    hr(),
    textOutput("date_text"),
    textOutput("button_text"),
    textOutput("check_text"),
    textOutput("dropdown_text"),
    textOutput("text")
  ),
  server = function(input, output) {
    reactable_extras_server(
      "table",
      data = df,
      columns = list(
        Manufacturer = colDef(
          header = tooltip_extra("tooltip", theme = "material"),
          cell = button_extra("button", class = "button-extra")
        ),
        Check = colDef(
          cell = checkbox_extra("check", class = "checkbox-extra"),
          align = "left"
        ),
        Date = colDef(
          cell = date_extra("date", class = "date-extra")
        ),
        Type = colDef(
          cell = dropdown_extra(
            "dropdown",
            unique(df$Type),
            class = "dropdown-extra"
          )
        ),
        Model = colDef(
          cell = text_extra(
            "text"
          )
        )
      )
    )
    output$date_text <- renderText({
      req(input$date)
      values <- input$date
      paste0(
        "Date: ",
        string_list(values)
      )
    })
    output$check_text <- renderText({
      req(input$check)
      values <- input$check
      paste0(
        "Check: ",
        string_list(values)
      )
    })
    output$button_text <- renderText({
      req(input$button)
      values <- input$button
      paste0(
        "Button: ",
        string_list(values)
      )
    })

    output$dropdown_text <- renderText({
      req(input$dropdown)
      values <- input$dropdown
      paste0(
        "Dropdown: ",
        string_list(values)
      )
    })

    output$text <- renderText({
      req(input$text)
      values <- input$text
      paste0(
        "Dropdown: ",
        string_list(values)
      )
    })
  }
)

@andyquinterom
Copy link
Copy Markdown
Contributor Author

The diff should be much smaller once #38 is merged

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