feat(viewer): show color swatches next to hex color codes in plans#562
Merged
backnotprop merged 1 commit intobacknotprop:mainfrom Apr 14, 2026
Merged
Conversation
f3160c4 to
b60e8d1
Compare
Owner
|
Nice feature |
backnotprop
reviewed
Apr 14, 2026
b60e8d1 to
619de1c
Compare
Contributor
Author
|
Add the change @backnotprop applied the more accurate regex. The 3- and 4-digit alternatives now require at least one |
When a plan contains hex color values (#rgb, #rrggbb, #rgba, #rrggbbaa), the InlineMarkdown renderer now shows a small filled swatch inline to the left of the code so the actual color is immediately visible.
619de1c to
237c8c6
Compare
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
When a plan contains a hex color value (
#rgb,#rrggbb,#rgba,#rrggbbaa), theInlineMarkdownrenderer now displays a small filled swatch inline — immediately to the left of the monospace hex code — so the actual color is visible at a glance without leaving the document.This is especially useful for frontend development plans where colours are frequently referenced (design tokens, Tailwind overrides, CSS variables, component palette decisions). Without this, reviewers have to mentally decode hex strings or open a colour picker just to follow the author's intent.
Before:
use #ff6600 for the CTA buttonAfter:
use 🟧 #ff6600 for the CTA button(small inline swatch, not an emoji)What changed
packages/ui/components/Viewer.tsx— two edits, ~20 lines total:New pattern block in the
InlineMarkdownloop (after inline-code, before wikilinks):#rgb,#rgba,#rrggbb,#rrggbbaawith a negative lookahead that prevents false-positives on URL anchors (#section), CSS id selectors (#sidebar), and any identifier that continues with word characters.14×14rounded swatch (<span style={{ backgroundColor: hex }}>) followed by the hex code in a<code>tag.nextSpecialregex now includes#so the scanner stops at a#mid-sentence rather than swallowing it as plain text.Security notes
style={{ backgroundColor: hex }}uses React's JS-object style prop, not rawcssText. React sets individual CSS properties, so it is not possible to break out into arbitrary CSS via this value.backgroundColoris#followed by exactly 3, 4, 6, or 8 hex digits ([0-9a-fA-F]). Payloads likeexpression(),url(), or;color:redsuffixes are structurally impossible to inject.innerHTMLordangerouslySetInnerHTML. All rendering is via React JSX — standard XSS protections apply.Tests
packages/ui/components/hexColorSwatch.test.ts— 19 tests, all passing (bun test):#, URL anchors, CSS id names, 9+ digit stringsbackgroundColor; captured value always passes strict/^#[0-9a-fA-F]{3,8}$/check