Repository navigation
feat: show hex colors as swatches - #1064
Merged
Merged
Conversation
A hex color written like a hashtag, such as #ff8a4c or #fff, shows with a small swatch of the color. It needs at least one letter, so dev-null-sh#123 stays an issue reference, and colors in code are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closed
#000 and #000000 are black, and #333333 is gray, but they showed as plain text because a color needed a letter. Issue numbers never start with a zero and aren't 6 or 8 digits long, so those count as colors now, while dev-null-sh#123 and dev-null-sh#333 still stay plain. The pattern also spells its zero-width characters as escapes instead of the invisible characters themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrismessina
marked this pull request as ready for review
October 23, 2026 20:25
Member
|
Please fix the conflicts. |
Production's withWordmarks now wraps plain text in a Fragment keyed by index, which repeats across the runs withColors joins; key it by offset too, like the wordmarks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The composer offered "#333333" and "#99999999" as issue references and looked them up, although they render as colors. Skip a reference that the color rule recognizes, with code blanked out as when rendering. Co-Authored-By: Claude Opus 5.5 <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.
Summary
Developers paste colors into posts all the time (
#ff8a4c,#fff), and today they read as plain text. This shows a hex color with a small swatch of the color beside it, on the web. Nothing is stored and nothing changes on the server or in the API.This started as the color part of #1059 (hashtags, now closed) and stands on its own: it doesn't depend on hashtags.
Changes
resources/js/lib/colors.ts(colorsIn):#or#, then 3, 4, 6 or 8 hex digits. A 3- or 4-digit value also needs a letter or a leading zero, so#123and#333stay issue references while#000is black; issue numbers never start with a zero or run to 6 digits here, so#000000and#333333are colors too. It's a whole word, like a hashtag would be: it starts at the start, after whitespace, or after a quoted line's>, and only punctuation may follow it before the next space. So#fff.is a color, while#fff-x,#ff8a4c.comand(#fff)aren't.LinkifiedTextfinds colors in the prose (code is blanked out first, with the newwithoutCodeincode.ts) and draws them in awithColorsstep between mentions and wordmarks. Wordmark keys now include their offset, so several runs of text in one line don't share React keys.startsTextprop tellsLinkifiedTextthat its text is a whole body, so a>#fffthat starts it counts as a quoted line. The Following page's suggestions pass it, since they render the raw body.#333333or#99999999as an issue reference or looks it up:issueReferenceBeforeCaretskips a reference thatcolorsInrecognizes, with code blanked out as when rendering.#123and(#333333stay issue references.KNOWLEDGE_BASE.mdhas a sentence about colors.Validation
Local, macOS, PHP 8.5.12, PostgreSQL 18 with pgvector, in a worktree with
productionmerged in at4ff5b70:pest --parallel --ci: 4,115 passed.bun run test:unit: 159 passed (includestests/Unit/Colors.test.ts).vp test run: 497 passed, and 469 withtests/draft-images.config.ts(includesLinkifiedTextandIssueReference).pint --test,rector --dry-run,vp fmt --check,vp lint, andtsc(app and tests): pass.vp lintreports warnings, all from lines this branch doesn't change.Visual evidence
The swatch is an inline
0.75emsquare inside awhitespace-nowrapspan, so it can't push the color onto its own line. Layout shift was measured with the same markup on #1059's build: 0 at 1440×900, 1366×650 and 390×844, light and dark. It wasn't measured separately on this branch.Device verification
Not tested on hardware or a simulator. The change is inline text rendering with no input, focus or scrolling behavior, so the on-screen keyboard, safe areas and touch don't apply.
Independent review
gpt-6.1-sol, high effort), read-only, source and diff only.bb1acc1(production), head96a0b8de9566acfa3a819545df0d94a1be6b68c7.>#fffgot no swatch on Following suggestions. It's fixed with thestartsTextprop above and confirmed fixed in the second review. The reviewer verified the color rule against issue references, precedence with URLs, mentions and wordmarks, offsets across slices, React keys, and the commit, chat and Following callers.36c2cc7(digit-only colors, escaped pattern): CODE: PASS. The reviewer confirmed#000and#000000trigger no issue lookup, and that the escaped zero-width class matches the same characters as before.production(14bce0b):production's newFragmentaround plain text was keyed by index, which repeated across the runswithColorsjoins; it's now keyed by offset, with a test that failed before. The reviewer confirmed the keys,CertificateTextand fix: expand issue references only when selected #1098's issue expansion all hold, and found one P2 that predated the merge: the composer still looked up#333333as an issue.4f80e51(no issue lookup for colors): CODE: PASS. The first version missed a color right before inline code; the reviewer found it, and the fix now checks the whole draft with code blanked out. The final review confirmed both cases fixed and that only 6- and 8-digit candidates change.Limitations
#333and#999stay plain text, since they read the same as issue numbers.(#fff), isn't recognized, matching how a hashtag would start.