feat(Timeline): add variant prop to Timeline.Badge#7698
feat(Timeline): add variant prop to Timeline.Badge#7698hectahertz wants to merge 15 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: f5d7c71 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
|
cc @HiroAgustin, this addresses your requests for timeline icon color customization and one-end trimming from the thread. Would love your feedback! |
There was a problem hiding this comment.
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.Badgevariantprop for built-in emphasis color schemes. - Extended
TimelineclipSidebarto support one-sided clipping via'start' | 'end'(while keepingtrueas “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 */ |
There was a problem hiding this comment.
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.
| /** 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. | |
| */ |
|
Oh, FYI, my version of this Timeline edge clip was already merged #7662 I think those are the conflicting files? |
0807a2b to
a2b5b51
Compare
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.
|
A successful canary CI run (i.e., a valid canary version published via the Note: Make sure the Canary Release label is applied to the PR — the Next steps:
For more details, see this workflow run. |
…or CI regeneration
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}, () => { |
There was a problem hiding this comment.
Added this cause this one is super slow
Closes github/primer#6465
Adds a
variantprop toTimeline.Badgefor built-in emphasis colors, replacing the className/sx workarounds people currently use for colored badges.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-onEmphasisautomatically.Changelog
New
Timeline.BadgevariantpropRollout strategy
Testing & Reviewing
npm startand check the Badge Variants and Timeline Break stories to verify the colors and icon rendering.Merge checklist