feat(:segmented_button_group): add count prop per segment (closes unified_ui #187)#140
Draft
ty13r wants to merge 1 commit into
Draft
feat(:segmented_button_group): add count prop per segment (closes unified_ui #187)#140ty13r wants to merge 1 commit into
ty13r wants to merge 1 commit into
Conversation
…lass C extension) Adds optional count badge per segment to the canonical :segmented_button_group widget, addressing comp-fidelity gap EX-6 (segments like "ADRs (12)"). - IUR constructor: count (optional non-negative integer, default nil) on segment options via normalize_options/1; raises ArgumentError for negative or non-integer values - Renderer: passes count through segmented_button_group_options/2 helper - Stage-4 Phoenix.Component: renders <span class="live-ui-segmented-button-group-option-count" aria-hidden="true"> inline when count is non-nil; zero renders "0"; nil omits the span - Tests: 6 IUR (positive: count pass-through, zero, nil-omit; negative: negative int, non-integer, float) + 6 Stage-4 widget (positive: badge present, aria-hidden, zero; negative: nil, absent-key, mixed options) Closes The-Metagraph/unified_ui#187. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Wave 3.7 Class C extension: segmented_button_group count badge
Adds
countprop per segment to canonical:segmented_button_group. DRAFT for Pascal review per substrate-gap co-maintain convention; standing auto-merge does NOT apply.Issue reference
unified_ui #187 -- segmented_button_group count badge proposal
Substrate dependency satisfied
PR #115 (SegmentedButtonGroup Stage-4) merged 2026-05-18 via Pascal review. Existing integration plumbing intact (verified during pre-flight audit per the updated widget skill).
Extension scope
count(optional non-negative integer, default nil) on segment options vianormalize_options/1; raisesArgumentErrorfor negative or non-integer valuessegmented_button_group_options/2): passescountthrough from IUR element attributes to the per-option map<span class="live-ui-segmented-button-group-option-count" aria-hidden="true">{count}</span>inside the button whencountis non-nil;count: 0renders "0";count: nilor absent key renders no spanARIA design decision
Per Issue #187 open question Q7: badge gets
aria-hidden="true". The label text alone provides accessible context for screen readers; the count badge is a visual supplement. If Pascal prefers an explicitaria-labelon the span, that is a trivial follow-up.Zero-count behavior (Issue #187 Q3)
Adopted: show badge with "0" for explicit zero-count (e.g., "Plans (0)"); hide for
nil. This matches theunread_badgeconstructor guard pattern and makes the caller intent explicit.Pascal-review open questions (from Issue #187)
:unread_badge: implemented inline (smallest delta). Composition with:unread_badgewould be a separate refactor if Pascal prefers it.aria-hidden="true"-- confirm or preferaria-label.Closest pattern reference
ash_ui PR #132 (tabs count badge) -- companion Class C extension with same count-badge shape. Both pending Pascal review. The current
tabs.exin main does not yet have count (PR #132 is DRAFT), so implementation aligns with Issue #187 own ARIA proposal directly.Integration footprint audit (per widget skill Validation Checklist)
packages/live_ui/lib/live_ui/widgets/segmented_button_group.ex-- extended with count badge renderingpackages/live_ui/lib/live_ui/renderer.ex--segmented_button_group_options/2passes count through; no structural change to dispatch clausepackages/live_ui/lib/live_ui/widgets/form_control_and_composer.ex-- unchanged; existing family aggregation already includes SegmentedButtonGrouppackages/live_ui/lib/live_ui/widgets.ex-- unchanged; existing aggregation includes:form_control_and_composerlib/ash_ui/rendering/iur_adapter.ex-- unchanged;:segmented_button_grouprouting already present (verified grep)lib/ash_ui/rendering/live_ui_adapter.ex-- unchanged; dispatch already present (verified grep)packages/unified_iur/lib/unified_iur/widgets/components.ex--normalize_options/1extended to pass throughcountwith validation; IUR registry entry unchanged (kind already registered at line 36)Test results
cd packages/live_ui && mix test-- 582 tests, 0 failurescd packages/live_ui && mix test test/live_ui/widgets/segmented_button_group_test.exs-- 21 tests, 0 failures (+6 new count badge tests)cd packages/unified_iur && mix test test/unified_iur/widgets/components_test.exs-- 12 tests, 0 failures (+6 new IUR count prop tests)Generated with Claude Code