feat(Timeline): add badge variant prop and one-end clipSidebar#7698
feat(Timeline): add badge variant prop and one-end clipSidebar#7698hectahertz wants to merge 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 0807a2b 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. | |
| */ |
Closes github/primer#6465
Two features for
Timeline:1. Badge color variants (
Timeline.Badgevariantprop)Adds a
variantprop toTimeline.Badgefor built-in color schemes, replacing the need for custom classNames or the deprecatedsxprop to colorize timeline icons.Available variants:
accent,success,attention,severe,danger,done,open,closed,sponsors. When set, the badge background uses the emphasis token and icon color automatically switches to--fgColor-onEmphasis.2. One-end sidebar clipping (
clipSidebarprop extension)Extends
clipSidebarto accept'start'or'end'in addition totrue(which still clips both ends, preserving backward compatibility).Changelog
New
Timeline.Badge:variantprop with values'accent' | 'success' | 'attention' | 'severe' | 'danger' | 'done' | 'open' | 'closed' | 'sponsors'Timeline:clipSidebarnow accepts'start'or'end'for one-sided trimmingChanged
Removed
Rollout strategy
Testing & Reviewing
npm startand check the Timeline stories:variant="done"instead of className workaroundclipSidebarvalues and badge variant propMerge checklist