RinteRface / shinybulma

🌐 Bulma.io for Shiny
https://rinterface.github.io/shinybulma/
Other
111 stars 15 forks source link

Pricing Table Reactivity non-existent #18

Open xbrl-data opened 4 years ago

xbrl-data commented 4 years ago

I love the look of this package, but when I try to use the pricing table defaults from the documentation, there is no reactivity at all. Clicking a button in the bulmaPricingPlanItem seems to do absolutely nothing. Am I missing something here?

bulmaPricingPlan( active = TRUE, color = NULL, plan_title = "Growing Team", plan_price = 60, plan_currency = "$", plan_period = "/month", button_status = NULL, button_name = "Choose", bulmaPricingPlanItem(name = "200GB Storage"), bulmaPricingPlanItem(name = "50 domains"), bulmaPricingPlanItem(name = "1TB Bandwidth"), bulmaPricingPlanItem(name = "100 Email Boxes") )

DivadNojnarg commented 4 years ago

Hi,

thanks for your interest in shinybulma. For now, the pricing table is not interactive. What you could to is to add an id to the given button as well as add the action-button class to make it react like a classic shiny action button. On the server side, you may detect any click on that button using the corresponding inputId in an observeEvent.

In a future release, this will be included by default. For now, the reason it was not done is mainly a lack of free time to maintain the package.

Best

David

fmmattioni commented 4 years ago

Hey @DivadNojnarg!

Would you be able to provide a very quick example of what you described above?

I am currently working with shinybulma and I find it fantastic! I am actually adapting the pricing plan table for something else. It would be great if I could add this reactivity.

Thanks in advance! Felipe

fmmattioni commented 4 years ago

Actually, nevermind.. I am going to use bs4Dash 😁

DivadNojnarg commented 4 years ago

You would have to modify the bulmaPricingPlan to add an id to the button as well as add the action-button class to inherit from the shiny action button behavior. Alternatively, you could replace the button by bulmaActionButton and feed it with the id:

bulmaPricingPlan <- function(..., active = FALSE, color = NULL, plan_title = NULL,
                             plan_price = NULL, plan_currency = NULL,
                             plan_period = NULL, button_status = NULL,
                             button_name = NULL, id = NULL) {

  cl <- "pricing-plan"
  if (!is.null(color)) cl <- paste0(cl, " is-", color)
  if (active == TRUE) cl <- paste0(cl, " is-active")

  # main tag
  pricingPlanTag <- shiny::tags$div(
    class = cl
  )

  # header
  headerTag <- shiny::tags$div(class = "plan-header", plan_title)

  # price
  priceTag <- shiny::tags$div(
    class = "plan-price",
    shiny::tags$span(
      class = "plan-price-amount",
      shiny::tags$span(class = "plan-price-currency", plan_currency),
      plan_price
    ),
    plan_period
  )

  # items
  itemsTag <- shiny::tags$div(
    class = "plan-items",
    # items
    ...
  )
  # footer
  footerTag <- shiny::tags$div(
    class = "plan-footer"
  )

  # footer button
  footerButtonTag <- shiny::tags$button(
    id = id,
    class = "button action-button is-fullwidth",
    button_name
  )

  if (!is.null(button_status)) footerButtonTag$attribs$disabled <- button_status

  footerTag <- shiny::tagAppendChild(footerTag, footerButtonTag)

  pricingPlanTag <- shiny::tagAppendChildren(
    pricingPlanTag,
      headerTag,
      priceTag,
      itemsTag,
      footerTag
  )

  pricingPlanTag

}
fmmattioni commented 4 years ago

Hi @DivadNojnarg, this is perfect! I am going to give it a try again, really like shinybulma!