Skip to content

feat(avatar): add pf-v6-avatar element#3139

Open
zeroedin wants to merge 5 commits intostaging/pfv6from
feat/v6-avatar
Open

feat(avatar): add pf-v6-avatar element#3139
zeroedin wants to merge 5 commits intostaging/pfv6from
feat/v6-avatar

Conversation

@zeroedin
Copy link
Copy Markdown
Collaborator

@zeroedin zeroedin commented May 8, 2026

Summary

  • Adds <pf-v6-avatar> web component for PatternFly v6
  • Displays user avatar image or placeholder SVG graphic when no src is provided
  • Supports size (sm/md/lg/xl), bordered, alt, and src attributes
  • Fires PfV6AvatarLoadEvent when image loads
  • Placeholder colors reference PF v6 design tokens with light-dark() fallbacks
  • Demos: basic (index), basic, bordered, size-variations

Closes #2979
Depends on #3130

Intentional divergences from React

  • Placeholder SVG: React's Avatar is always an <img> (with src defaulting to empty string). Our web component renders an inline SVG placeholder when src is not provided, avoiding a network request and enabling CSS-based theming of the placeholder via --pf-t--global--background--color--200 and --pf-t--global--icon--color--subtle design tokens. This is a net-new feature not present in React.
  • bordered attribute instead of React's isBordered (no is- prefix per ADVICE.md)
  • alt is optional (defaults to "" decorative image); React requires alt: string
  • load event added (PfV6AvatarLoadEvent) — not in React

Test plan

  • npm run test passes
  • Demos render correctly at localhost:8000 with ?rendering=chromeless
  • Avatar with src displays image; without src displays placeholder SVG
  • Placeholder renders correctly in both light and dark mode
  • All size variants visually match patternfly.org
  • Bordered variant shows border matching patternfly.org
  • Placeholder SVG is hidden from accessibility tree (aria-hidden="true")

Assisted-By: Claude noreply@anthropic.com

zeroedin added 5 commits May 8, 2026 14:07
Port pf-v5-avatar to pf-v6-avatar with the following v6 API changes:

- Replace `border` string attribute (light/dark) with boolean `bordered`
  attribute, matching React v6 `isBordered` prop
- Drop `dark` boolean attribute (removed in v6 React)
- Update all CSS custom property tokens from `--pf-v5-c-avatar--*` to
  `--pf-v6-c-avatar--*` matching the v6 SCSS source
- Use v6 global tokens (`--pf-t--global--border--*`) for bordered
  variant
- Simplify placeholder SVG to use `light-dark()` for automatic
  light/dark mode, replacing the separate dark boolean
- Use private CSS custom properties (`--_*`) with public token fallback
  defaults at use sites
- Remove default value from `alt` property to avoid sprouting attributes
- Add `aria-hidden="true"` to placeholder SVG
- Add `@cssprop` JSDoc for all public CSS custom properties
- Export `AvatarSize` type union

Demos match patternfly.org: basic, bordered, size-variations.
Tests cover sizes (offsetWidth), load event, alt text (a11ySnapshot),
bordered, and placeholder rendering.

Closes #2979

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use `static styles = [style]` array form convention
- Simplify render return type to TemplateResult
- Change img/svg display from inline to block (prevents baseline gap)
- Add placeholder avatar to basic demo
- Add a11ySnapshot test for placeholder hidden from ax tree
- Add size=md test case
- Strengthen bordered test assertion (check border adds to size)
- 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: 47ea912

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(avatar): add pf-v6-avatar 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 a3970da
😎 Deploy Preview https://deploy-preview-3139--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 a3970da: Report

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.

1 participant