Skip to content

feat(Timeline): add variant prop to Timeline.Badge#7698

Open
hectahertz wants to merge 15 commits intomainfrom
hectahertz/timeline-color-trimming
Open

feat(Timeline): add variant prop to Timeline.Badge#7698
hectahertz wants to merge 15 commits intomainfrom
hectahertz/timeline-color-trimming

Conversation

@hectahertz
Copy link
Copy Markdown
Contributor

@hectahertz hectahertz commented Mar 24, 2026

Closes github/primer#6465

Adds a variant prop to Timeline.Badge for built-in emphasis colors, replacing the className/sx workarounds people currently use for colored badges.

// before
<Timeline.Badge className={styles.mergedBadge}>
  <Octicon icon={GitMergeIcon} className={styles.mergedIcon} />
</Timeline.Badge>

// after
<Timeline.Badge variant="done">
  <Octicon icon={GitMergeIcon} />
</Timeline.Badge>

Available values: accent, success, attention, severe, danger, done, open, closed, sponsors. When set, the badge uses the corresponding emphasis background and switches the icon color to --fgColor-onEmphasis automatically.

Changelog

New

  • Timeline.Badge variant prop

Rollout strategy

  • Minor release

Testing & Reviewing

npm start and check the Badge Variants and Timeline Break stories to verify the colors and icon rendering.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge
  • (GitHub staff only) Integration tests pass at github/github-ui

@hectahertz hectahertz requested a review from a team as a code owner March 24, 2026 13:40
@hectahertz hectahertz requested review from TylerJDev and Copilot March 24, 2026 13:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: f5d7c71

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@hectahertz
Copy link
Copy Markdown
Contributor Author

cc @HiroAgustin, this addresses your requests for timeline icon color customization and one-end trimming from the thread. Would love your feedback!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class styling and layout options to Timeline in @primer/react, improving ergonomics for common Timeline use cases without requiring custom CSS overrides.

Changes:

  • Added Timeline.Badge variant prop for built-in emphasis color schemes.
  • Extended Timeline clipSidebar to support one-sided clipping via 'start' | 'end' (while keeping true as “both ends”).
  • Updated stories, docs metadata, unit tests, VRT coverage, and public type exports to reflect the new API.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react/src/index.ts Exports TimelineBadgeVariant from the package entrypoint.
packages/react/src/Timeline/index.ts Re-exports TimelineBadgeVariant from the Timeline barrel.
packages/react/src/Timeline/tests/Timeline.test.tsx Adds unit tests for `clipSidebar="start"
packages/react/src/Timeline/Timeline.tsx Implements clipSidebar string values and introduces TimelineBadgeVariant + variant prop wiring.
packages/react/src/Timeline/Timeline.module.css Adds CSS for one-sided clipping and badge variant styling via data-variant.
packages/react/src/Timeline/Timeline.features.stories.tsx Adds stories for new clipSidebar modes and showcases badge variants; updates existing story to use variant="done".
packages/react/src/Timeline/Timeline.features.stories.module.css Removes no-longer-needed workaround styles for the “done” badge background/icon color.
packages/react/src/Timeline/Timeline.docs.json Documents the expanded clipSidebar type and the new Badge variant prop.
e2e/components/Timeline.test.ts Adds VRT coverage for the new stories (clip start/end, badge variants).
.changeset/timeline-badge-variant-clip-sidebar.md Declares a minor release for the new Timeline APIs.

export type TimelineBadgeProps = {
children?: React.ReactNode
className?: string
/** The color variant of the badge */
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

TimelineBadgeVariant includes a 'default' value, but Timeline.Badge treats 'default' the same as omitting variant (no data-variant is rendered). Consider clarifying this in the variant JSDoc (e.g., “defaults to 'default' / omit for default styling”) or, if 'default' shouldn’t be public API, remove it from the union and update docs/tests accordingly.

Suggested change
/** The color variant of the badge */
/**
* The color variant of the badge.
*
* Defaults to the "default" styling. Omit this prop or set it to "default"
* for the default appearance; other values render a variant-specific style.
*/

Copilot uses AI. Check for mistakes.
@HiroAgustin
Copy link
Copy Markdown
Contributor

Oh, FYI, my version of this Timeline edge clip was already merged #7662

I think those are the conflicting files?

@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7698 April 1, 2026 12:57 Inactive
Remove incorrectly-named underscore snapshots and locally-generated
Badge Variants snapshots. Revert Timeline Break snapshots to main.
The 'update snapshots' label will regenerate them in Docker.
@hectahertz hectahertz added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7698 April 1, 2026 14:10 Inactive
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@primer-integration
Copy link
Copy Markdown

⚠️ Hi from github/github-ui! The integration workflow could not find a canary version for the latest commit on this PR.

A successful canary CI run (i.e., a valid canary version published via the release.yml workflow) must exist for the latest commit before integration checks will succeed.

Note: Make sure the Canary Release label is applied to the PR — the release.yml workflow requires this label to publish a canary version.

Next steps:

  1. Wait for the release.yml canary CI run to complete successfully for the latest commit on this PR.
  2. Once a valid canary version exists, re-trigger the integration workflow by visiting the primer-react-pr-test workflow page, clicking Run workflow, and pasting this PR's URL.

For more details, see this workflow run.

@hectahertz hectahertz added update snapshots 🤖 Command that updates VRT snapshots on the pull request Canary Release Apply this label when you want CI to create a canary release of the current PR labels Apr 1, 2026
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7698 April 1, 2026 14:43 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-7698 April 1, 2026 14:53 Inactive
@hectahertz hectahertz added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 1, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7698 April 1, 2026 15:55 Inactive
The parseTypeInfo function initializes TypeScript's compiler API, which
can take longer than the default 5s timeout on CI, especially with
React 19's type definitions.
const FIXTURE_PATH = path.join(directory, 'fixtures')

describe('getPropTypeForComponent', () => {
describe('getPropTypeForComponent', {timeout: 30_000}, () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this cause this one is super slow

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

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants