Skip to content

feat(badge): add pf-v6-badge element#3138

Open
zeroedin wants to merge 4 commits intostaging/pfv6from
feat/v6-badge
Open

feat(badge): add pf-v6-badge element#3138
zeroedin wants to merge 4 commits intostaging/pfv6from
feat/v6-badge

Conversation

@zeroedin
Copy link
Copy Markdown
Collaborator

@zeroedin zeroedin commented May 8, 2026

Summary

  • Adds <pf-v6-badge> web component for PatternFly v6
  • Displays numeric values with read/unread styling via light DOM text content
  • Supports threshold attribute to cap displayed value (e.g., "999+")
  • number attribute for programmatic value setting
  • disabled attribute dims the badge
  • Demos: basic (index), read, unread, disabled, threshold

Closes #2982
Depends on #3130

Intentional divergences from React

  • Uses light DOM text content instead of React's children prop for the numeric value
  • number and threshold attributes are not reflected (no CSS selectors use them)
  • disabled uses aria-disabled via ElementInternals rather than a host attribute

Test plan

  • npm run test passes
  • Demos render correctly at localhost:8000 with ?rendering=chromeless
  • Read/unread badge styling matches patternfly.org
  • Threshold displays "999+" when value exceeds threshold
  • Disabled badge is visually dimmed

Assisted-By: Claude noreply@anthropic.com

zeroedin added 4 commits May 8, 2026 14:06
Port pf-v5-badge to pf-v6-badge with v6 design tokens, CSS, and
API parity with PatternFly v6 React Badge component.

Changes from v5:
- Updated CSS custom properties to --pf-v6-c-badge--* namespace
- Added border overlay via ::after pseudo-element (new in v6)
- Added disabled state with pointer-events: none
- Switched to CSS logical properties (padding-inline-start/end)
- Simplified render: no wrapper span, slot for default content
- Added `@cssprop` JSDoc for all public CSS custom properties
- Added `@summary` and `@slot` JSDoc annotations
- Exported BadgeState type union

Demos match patternfly.org: read, unread, disabled, plus
WC-specific threshold demo.

Tests cover: instantiation, number/threshold display, state colors,
disabled styling, accessibility tree, slot content.

Closes #2982

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove reflect from number and threshold properties (no CSS selectors)
- Fix threshold comparison: use <= instead of < so number=threshold shows +
- Simplify render return type to TemplateResult
- Add cem generate output path to config

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

⚠️ No Changeset found

Latest commit: 3a4af73

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

✅ Commitlint tests passed!

More Info
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input": "feat(badge): add pf-v6-badge element"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Deploy Preview for patternfly-elements ready!

Name Link
🔨 Latest commit ac95104
😎 Deploy Preview https://deploy-preview-3138--patternfly-elements.netlify.app/

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions Bot added the AT passed Automated testing has passed label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

SSR Test Run for ac95104: Report

Copy link
Copy Markdown
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

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

see comments on the other 2 prs

* A **badge** is used to annotate other information like a label or an object name.
* @summary Displays a numeric value as an annotation
* @slot - Badge content, typically a number or short text
* @cssprop {<color>} --pf-v6-c-badge--Color - Text color of the badge
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

inline these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT passed Automated testing has passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants