feat: add toolbar_badge() and update_toolbar_badge() (#1316)#1318
Draft
elnelson575 wants to merge 22 commits into
Draft
feat: add toolbar_badge() and update_toolbar_badge() (#1316)#1318elnelson575 wants to merge 22 commits into
elnelson575 wants to merge 22 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toolbar_badge()— a pure display element for showing status text and icons inside atoolbar(), using Bootstrap's badge component (text-bg-{color}, optionalrounded-pill, optionalborderfor outline-only style)update_toolbar_badge()— server-side update function usingsendCustomMessage(not an input binding) to update label, icon, color, border, pill, and show_labeltoolbarBadge.tsJS handler and.bslib-toolbar-badgeSCSS rule; updates the toolbar example app with live badge demosDesign decisions
input$badge_idside effects or bookmarking noisetoolbar_input_button()aria pattern — randomly generatedlabel_id,hiddenattribute +aria-labelledbyso screen readers read the label even in icon-only mode!show_label— icon-only badges get a tooltip by default, matching the button familyborder = TRUEfor outline style — uses Bootstrap'sborder border-{color} text-{color}utilities instead oftext-bg-{color};data-bslib-coloranddata-bslib-borderattributes track state soupdate_toolbar_badge()can toggle either independentlySample images
Toolbar badge showing record numbers

Toolbar badge showing "Live"

Toolbar badge in text input showing number of messages

Test plan
devtools::test(filter = "toolbar"))toolbar_badge("Active")renders withtext-bg-secondary badgeclassestoolbar_badge("Active", border = TRUE)renders withborder border-secondary text-secondaryclasses (notext-bg-*)bslib-tooltipwith{id}_tooltipidupdate_toolbar_badge()sendsbslib.update-toolbar-badgecustom message with only provided fieldsshiny::runExample("toolbar", package = "bslib")and verify: record count badge (outline pill) shows in footer, activity status badge cycles with icon+color on refresh, chat message count updates reactivelyCloses #1316