remove_card: Remove a card in a Shuffle grid

Description Usage Arguments Examples

View source: R/adding.R

Description

Use in a Shiny app to remove a card from layout.

Usage

1
remove_card(shuffleId, cardId, session = shiny::getDefaultReactiveDomain())

Arguments

shuffleId

The id of the shuffle container.

cardId

The id of the card to remove.

session

The session object passed to function given to shinyServer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
if (interactive()) {
  library(shiny)
  library(shufflecards)

  ui <- fluidPage(
    tags$h2("Remove a card"),
    selectInput(
      inputId = "select",
      label = "Select card to remove",
      choices = paste0("card", 1:4)
    ),
    actionButton("remove", "Remove it!"),
    shuffle_container(
      shuffleId = "grid",
      shuffle_card(
        id = "card1",
        tags$div("My first card", style = "text-align: center; line-height: 200px"),
        style = "border: 2px solid red; border-radius: 5px;",
        width = "300px", # better with fixed width/height
        height = "200px"
      ),
      shuffle_card(
        id = "card2",
        tags$div("Second one", style = "text-align: center; line-height: 200px"),
        style = "border: 2px solid red; border-radius: 5px;",
        width = "300px", # better with fixed width/height
        height = "200px"
      ),
      shuffle_card(
        id = "card3",
        tags$div("Third one", style = "text-align: center; line-height: 200px"),
        style = "border: 2px solid red; border-radius: 5px;",
        width = "300px", # better with fixed width/height
        height = "200px"
      ),
      shuffle_card(
        id = "card4",
        tags$div("Fourth one", style = "text-align: center; line-height: 200px"),
        style = "border: 2px solid red; border-radius: 5px;",
        width = "300px", # better with fixed width/height
        height = "200px"
      )
    )
  )

  server <- function(input, output, session) {
    observeEvent(input$remove, {
      remove_card("grid", input$select)
    }, ignoreInit = TRUE)
  }

  shinyApp(ui, server)
}

dreamRs/shufflecards documentation built on Dec. 4, 2019, 4:44 a.m.