Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/src/Timeline/Timeline.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"props": []
}
]
}
}
53 changes: 53 additions & 0 deletions packages/react/src/Timeline/Timeline.stories.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Story-local styles for the Custom Event playground in Timeline.stories.tsx.
*
* The `LeftRailGutter` wrapper reserves horizontal whitespace to the left of the
* timeline rail so toggling between `actorSize: 'small'` and `actorSize: 'large'`
* does not horizontally shift the timeline. This mirrors the Rails ViewComponents
* `.TimelineItem-avatar { position: absolute; left: -72px; }` treatment WITHOUT
* adding a public avatar slot to Primer React's Timeline component (Phase 2 will
* evaluate that API change).
*/

.LeftRailGutter {
/* Reserve enough room to the left of the rail for a 40px avatar plus a 16px gap. */
padding-left: calc(var(--base-size-40) + var(--base-size-16));
}

.LargeActorAvatar {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How many of these are truly story-only since they look like fundamental changes? Should we be representing what things actually render as OOTB and file some follow-up issues to better align the rendering to the expected output rather than overriding locally?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@adierkens 100% agree, and this is the loudest finding of the whole exercise. The fact that we need story-local CSS to fake a left-rail avatar gutter is exactly what tells us the component needs a real avatar slot. Same for the right-controls floats we left out entirely — lots of events have buttons, SHAs, and other content on the right side. The story-local CSS is deliberately scoped to this file to keep the React component untouched in this PR, so the gap stays loud rather than hidden.

That said, they're not strictly new — the large-avatar treatment mirrors how the equivalent Rails ViewComponents already render today, it just never formally made it into the React API. One of the reasons I've kept this PR as a draft is that I've been wondering whether we should land those API changes first, so when this merges it's not story-only. It's a real chicken/egg question and I'd be curious what you think.

I noted these in the wrap-up comment and on the parent issue github/primer#6662, but you're right that we should have actual followup issues. Will be filing these to scope for Phase 2:

  • Avatar slot on Timeline.Item (covers the large-avatar gutter and the Copilot-avatar fallback that the Rails component has already outgrown)
  • Right-controls slot
  • List semantics evaluation
  • Octicon cleanup + BADGE_VARIANTS dedup from your other comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

position: absolute;
/* Vertically centered with the 32px badge: badge top (16px padding) + 16px half = 32px center; avatar top = 32px - 20px (half avatar) = 12px. */
top: var(--base-size-12);
/* Matches Rails Timeline ViewComponents `.TimelineItem-avatar { left: -72px }`. */
left: calc(-1 * (var(--base-size-40) + var(--base-size-32)));
z-index: 1;
}

.SmallActorAvatar {
margin-right: var(--base-size-4);
/* `vertical-align: middle` is more reliable than `text-bottom` for 20px avatars next
to body text; the slight negative nudge optically aligns the avatar to the x-height. */
vertical-align: middle;
position: relative;
/* stylelint-disable-next-line primer/spacing -- 1px optical nudge to align avatar with text x-height */
top: -1px;
}

.ActorName {
font-weight: var(--base-text-weight-semibold);
color: var(--fgColor-default);
}

.AppName {
font-weight: var(--base-text-weight-semibold);
color: var(--fgColor-default);
}

.AppAvatar {
margin-right: var(--base-size-4);
vertical-align: middle;
position: relative;
/* stylelint-disable-next-line primer/spacing -- 1px optical nudge to align avatar with text x-height */
top: -1px;
border-radius: var(--borderRadius-medium);
}
Loading
Loading