Skip to content

feat(badge): let users define their own badge style - #468

Merged
vite-hub[bot] merged 2 commits into
mainfrom
feat/badge-custom-style
Nov 18, 2026
Merged

vite-hub[bot] merged 2 commits into
mainfrom
feat/badge-custom-style

Conversation

@onmax

@onmax onmax commented Nov 18, 2026

Copy link
Copy Markdown
Owner

An image badge can only take one of three looks in the default preset: shadcn, subtle, or solid. A designer who wants square corners, a thin grey border, or mono text has to hand-draw the SVG, and the badge builder has no way to make it.

This PR adds style="custom". It reads six new fields, radius (0 to 13), padding (4 to 16), border (a color or none), font (sans or mono), labelText and valueText, and keeps using labelColor and color for the two halves. Text left without a color turns black or white for contrast, as solid does. Setting any of the fields picks custom on its own, so :badge[ready]{radius="0"} is enough. The fields go in the image URL like every other option, so a hosted /badge.svg link and a builder link bring the same look back. The other presets ignore them, as they already ignore style. A bad value, or a custom field next to another style, is reported under comark/badge/invalid-image with its fix. In the builder, choosing Style → Custom shows a field for each.

Before and after of the builder at 1440px and 390px: https://drop.vitehub.dev/d/a360d38x2trs/before-after

Validation:

  • vp test run test/ in packages/badge: 58 passed. New cases cover the drawn SVG, the URL round trip through badgeParams and readBadge, each bad value's error, and markup in an unchecked value that badgeSvg() must not pass through.
  • playwright test e2e/badge.e2e.ts: 2 passed. The new test sets a custom style in the builder, opens the builder link in a new page, and gets the same fields, export, and a 26px preview.
  • vp lint and the root typecheck: nothing in the changed files. I didn't run pnpm ready, since the typecheck needs every package built.

Not checked: a full docs build. The screenshots run the branch's builder markup, styles, and script inside the live docs page, not a local docs build.

🤖 Generated with Claude Code

style="custom" in the default preset reads radius, padding, border, font,
labelText and valueText, keeps them in the image URL, and the badge builder
gets a control for each.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-18T15:06:36.300662Z
We couldn’t complete this review. Comment @codex review to try again.
4f00911 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Existing BadgeSpec objects can now generate badge URLs that the hosted endpoint rejects, even when they don’t use the new style.

Approach: Extending the shared badge parser and SVG renderer is the right way to keep Markdown, builder exports, and the hosted endpoint in sync, but the new options need to stay optional for existing callers.

Reviewed changes across comark-badge, the docs builder, and the public documentation.

  • Badge options and rendering: Checked style selection, validation, SVG layout and contrast, and query serialization for local and hosted badges.
  • Builder and documentation: Checked field visibility, link restoration, exports, and the component metadata, docs, and skill reference.
  • Verification: The badge package built successfully, all 58 package tests and both Chromium tests passed, and focused checks reproduced the failures noted inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/badge/src/svg.ts Resolved
Comment thread packages/badge/src/svg.ts Resolved
Comment thread packages/badge/src/svg.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/comark-annotate@468

comark-badge

pnpm add https://pkg.pr.new/comark-badge@468

comark-bundle

pnpm add https://pkg.pr.new/comark-bundle@468

comark-cards

pnpm add https://pkg.pr.new/comark-cards@468

comark-carousel

pnpm add https://pkg.pr.new/comark-carousel@468

comark-cast

pnpm add https://pkg.pr.new/comark-cast@468

comark-charts

pnpm add https://pkg.pr.new/comark-charts@468

comark-chat

pnpm add https://pkg.pr.new/comark-chat@468

comark-chips

pnpm add https://pkg.pr.new/comark-chips@468

comark-cjk

pnpm add https://pkg.pr.new/comark-cjk@468

comark-code

pnpm add https://pkg.pr.new/comark-code@468

comark-code-notes

pnpm add https://pkg.pr.new/comark-code-notes@468

comark-colors

pnpm add https://pkg.pr.new/comark-colors@468

comark-comments

pnpm add https://pkg.pr.new/comark-comments@468

comark-critic

pnpm add https://pkg.pr.new/comark-critic@468

comark-deflist

pnpm add https://pkg.pr.new/comark-deflist@468

comark-details

pnpm add https://pkg.pr.new/comark-details@468

comark-diagrams

pnpm add https://pkg.pr.new/comark-diagrams@468

comark-diff

pnpm add https://pkg.pr.new/comark-diff@468

comark-embed

pnpm add https://pkg.pr.new/comark-embed@468

comark-fields

pnpm add https://pkg.pr.new/comark-fields@468

comark-figure

pnpm add https://pkg.pr.new/comark-figure@468

comark-file-tree

pnpm add https://pkg.pr.new/comark-file-tree@468

comark-footnotes

pnpm add https://pkg.pr.new/comark-footnotes@468

comark-git-graph

pnpm add https://pkg.pr.new/comark-git-graph@468

comark-github

pnpm add https://pkg.pr.new/comark-github@468

comark-icon

pnpm add https://pkg.pr.new/comark-icon@468

comark-include

pnpm add https://pkg.pr.new/comark-include@468

comark-keys

pnpm add https://pkg.pr.new/comark-keys@468

comark-links

pnpm add https://pkg.pr.new/comark-links@468

comark-linter

pnpm add https://pkg.pr.new/comark-linter@468

comark-magic-move

pnpm add https://pkg.pr.new/comark-magic-move@468

comark-mark

pnpm add https://pkg.pr.new/comark-mark@468

markdown-it-to-comark

pnpm add https://pkg.pr.new/markdown-it-to-comark@468

marked-to-comark

pnpm add https://pkg.pr.new/marked-to-comark@468

comark-mathml

pnpm add https://pkg.pr.new/comark-mathml@468

comark-media

pnpm add https://pkg.pr.new/comark-media@468

comark-metrics

pnpm add https://pkg.pr.new/comark-metrics@468

migrate-to-comark

pnpm add https://pkg.pr.new/migrate-to-comark@468

comark-outline

pnpm add https://pkg.pr.new/comark-outline@468

comark-properties

pnpm add https://pkg.pr.new/comark-properties@468

comark-qr

pnpm add https://pkg.pr.new/comark-qr@468

comark-quiz

pnpm add https://pkg.pr.new/comark-quiz@468

comark-reading-time

pnpm add https://pkg.pr.new/comark-reading-time@468

remark-to-comark

pnpm add https://pkg.pr.new/remark-to-comark@468

comark-sources

pnpm add https://pkg.pr.new/comark-sources@468

comark-steps

pnpm add https://pkg.pr.new/comark-steps@468

comark-table

pnpm add https://pkg.pr.new/comark-table@468

comark-tabs

pnpm add https://pkg.pr.new/comark-tabs@468

comark-tests

pnpm add https://pkg.pr.new/comark-tests@468

comark-time

pnpm add https://pkg.pr.new/comark-time@468

comark-ui

pnpm add https://pkg.pr.new/comark-ui@468

comark-xref

pnpm add https://pkg.pr.new/comark-xref@468

comark-zoom

pnpm add https://pkg.pr.new/comark-zoom@468

commit: 8fe2603

@vite-hub

vite-hub Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-11-18T16:08:33.811Z 1m 32s
View session Cancelled 2026-11-18T15:40:51.119Z 18m 39s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Merged 8fe2603 directly: required checks passed and review threads were resolved.

View session

PR #468 is ready to merge. All current-head checks passed, and the 63 badge tests passed locally. Lint exited successfully with warnings outside the changed files. I verified the fixes for legacy badge specs, invalid custom fields, and numeric URL serialization. All three review threads are resolved, and no new repair was needed.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. No P0 or P1 findings remain.

Reviewed changes since 4f00911:

  • Restored compatibility for legacy BadgeSpec objects by making custom fields optional and omitting missing values from hosted URLs.
  • Validated custom fields before applying defaults, and normalized radius and padding so leading zeroes don’t carry over to hosted URLs.
  • Verified the fixes with a clean badge build and publint check, all 63 badge package tests, and both Chromium badge tests.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub
vite-hub Bot merged commit 4ea98ad into main Nov 18, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the feat/badge-custom-style branch November 18, 2026 16:11
This was referenced Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant