fix(Badge): render a dot-only badge as a standalone circle - #419
Merged
Conversation
`<Badge dot />` with no children put a 4px dot inside a padded, bordered pill that collapsed to a sliver and read as broken. When there are no children, drop the pill chrome and let the dot stand on its own, keeping the variant colour, live region, className, and prop forwarding intact. Resolves Sorokit#309
|
@KayProject Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Resolves #309
Scope note
Two of the three items have already landed on
mainsince the issue was filed:primaryvsteal—primaryalready usesbg-brand-dim text-brandwith a brand-purple border, and there's already a test asserting its classes contain noteal.sizeprop —size?: "sm" | "md"already exists,mdalready renders attext-[11px], and both sizes are covered by tests.That leaves the dot-only case, which this PR implements.
The fix
<Badge dot />with no children put a 4px dot inside a padded, bordered pill. With no text to give it width, the pill collapsed to a sliver and read as broken.When
dotis set and there are no children, the pill chrome is dropped and the dot stands on its own. Everything else is preserved: the variant's dot colour, theliveregion attributes,className, and prop forwarding."No children" covers
undefined,null,false, and""— an empty-string child is the case the issue actually describes, and it's tested.A note on dot sizing
I kept the dot at
w-1 h-1rather than scaling it up for standalone use. The existing test"renders a standalone indicator dot when no children provided"assertsw-1/h-1explicitly, so enlarging it would have meant rewriting an existing assertion. If you'd prefer the standalone dot to be visually larger (sayw-2 h-2, optionally keyed offsize), say so and I'll adjust both the component and that test.Verification
npx vitest run src/components/ui/Badge.test.tsx— 15 passed, including 6 new cases: pill chrome dropped when standalone, chrome retained when children are present, empty-string child treated as empty, variant dot colour applied, live region still exposed, andclassName/prop forwarding.Full-suite regression check (several components render
<Badge dot>with children, so the padded path matters):main(5bc3678)No regressions.
ESLint clean on both changed files.
Heads-up on the build AC
npm run builddoesn't pass onmainfor unrelated reasons — unclosed blocks inFeeEstimator.tsxandSorobanPanel.tsxfrom a merge, which is also what the 61 pre-existing failures are. Happy to send a separate repair PR.