BennettForville / Bshiny2

0 stars 3 forks source link

Add hover bar code, tiny code clean up #4

Closed leeyap closed 2 years ago

leeyap commented 2 years ago

Hi @BennettForville (and @bpbond):

This PR adds code for hover bars over your SSP buttons.

The reason this was tricky is because radioButtons() has one inputId, which is what gets referenced in our reactive server call. The function we were going to use, shinybs::bsPopover, linked the hover bar output to an inputId. So, we would have had one large text box when you moused over any SSP choice. Which works, but is quite clunky. We wanted to have explanations of each individual SSP, not one large explanation of all five of them.

The internet is our friend here. Here is a solution to our problem. This user created a function that essentially redefined another hover bar type function to accomplish the results we wanted - one inputId, but multiple hover bars over each selection option. (Just for the record, they submitted this as an official PR to Shiny as a feature suggestion, but the PR is six years old. This would have been really useful!)

So, the code here defines such a function (thank you, Stack Overflow) that allows us to maintain one consistent inputId such that our server code can still interpret an SSP input, but each choice has its own hoverbar.

Tasks for you to complete when you have the time (for ease, switch over to this branch and make changes here):

Let me know if any of this is unclear, if you have questions, or want to go through anything together. We also might need to make some design tweaks to the hover bars once your descriptions are in - whatever looks best to you.

Thank you!