File size: 1,243 Bytes
f888423 |
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 |
box::use(
shiny[moduleServer, observeEvent, reactive, NS, div, uiOutput, renderUI],
bslib[card, card_header, card_body],
shinyWidgets[virtualSelectInput],
)
#' @export
ui <- function(id) {
ns <- NS(id)
uiOutput(ns("select_books_ui_output"))
}
#' @export
server <- function(id, book_titles, book_url_images, book_ids) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
output$select_books_ui_output <- renderUI({
res <- div(
class = "select_books_input_container",
virtualSelectInput(
ns("select_books_input"),
"",
choices = list(label=sprintf("<div class=\"booksearch\" >
<img class=\"booksearch__img\" src=\"%s\"/>
<span class=\"booksearch__title\">%s</span>
</div>", book_url_images, book_titles),
value = book_ids) |> purrr::transpose(),
multiple = TRUE,
optionsCount = 6,
search = TRUE,
width = "70vw",
showValueAsTags = TRUE,
html = TRUE
)
)
res
})
return(reactive({input$select_books_input}))
})
}
|