Timeline: add Code Scanning event stories (Phase 2)#8074
Timeline: add Code Scanning event stories (Phase 2)#8074janmaarten-a11y wants to merge 5 commits into
Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds a new set of Storybook “Features” stories for Code Scanning alert timeline events, demonstrating how to compose GitHub-like timeline rows using Primer React Timeline slots (including Timeline.Actions) and a co-located CSS Module for faithful styling.
Changes:
- Added
Timeline.code-scanning.features.stories.tsximplementing Code Scanning event-group stories (Detected, Fixed/Config-deleted, Closed by user, Reopened, Dismissal requested/reviewed) with shared helpers. - Added
Timeline.code-scanning.features.stories.module.cssto style story-only scaffolding and GitHub-like sub-row/link treatments.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/Timeline/Timeline.code-scanning.features.stories.tsx | New Storybook feature stories for Code Scanning timeline events, including helper components and per-variant scaffolding. |
| packages/react/src/Timeline/Timeline.code-scanning.features.stories.module.css | CSS Module supporting realistic layout, sub-rows, and link/badge-related styling for the Code Scanning stories. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Low
cbe8f65 to
befdae6
Compare
02c0dad to
a3b9975
Compare
Recreate GitHub's Code Scanning alert 'Detected' timeline events (alert created / appeared in branch / reappeared) with Primer React Timeline, translated from the live ERB (CodeScanning::TimelineComponent). Scoped to a proof-of-pattern: one event group + file scaffold + helpers, mirroring the Dependabot and Secret Scanning story conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the Fixed/Config-deleted, Closed-by-user, Reopened, Dismissal-requested, and Dismissal-reviewed event groups, translated from the live ERB (CodeScanning::TimelineComponent). Extract UserActor, MonoPill, and NoteSubRow helpers shared across the user-actor groups. Completes the Code Scanning surface of github/primer#6663. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Correct three stale/inaccurate inline comments flagged in review: the file header no longer claims to be a Detected-only proof-of-pattern (all six groups ship), the accessibility note reflects that the user-actor groups now render in-text profile links, and the tool-version Label comment states the faithful 'Label:'-prefixed title from the live ERB. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… guard (Code Scanning stories) Strip the restating aria-label from every Octicon nested directly in a Timeline.Badge so screen readers no longer announce each event twice (the badge icon is decorative; the adjacent Body conveys the event), matching live GitHub's bare badge octicons. The workflow sub-row icon keeps its label (separate finding). Extract a shared Examples wrapper that sets data-a11y-link-underlines="true" (reproduces production's default-on link underlines for any Link inline) and guards the placeholder-link click handler with an instanceof Element check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Swap the Code Scanning story's local scaffolding for the shared internal helpers in ./internal/timelineStoryHelpers: VariantSection (captioned section), Examples / RealisticTimeline (wrappers), BoldLink (#6826), InlineAvatar (#6827), and MutedTime (#6828). EventFixed has no in-text links, so it uses the no-links RealisticTimeline wrapper; the link-bearing groups keep Examples. Delete the now-duplicated local classes (.Variant, .VariantLabel, .RealisticTimeline, .LinkWithBoldStyle, .InlineAvatar, .Timestamp). Pure refactor — no rendered output change; the workflow sub-row icon label and tool-version Label are untouched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
befdae6 to
8f0835d
Compare
Summary
Adds Storybook Features stories that recreate GitHub's live Code Scanning alert timeline events using the Primer
Timelinecomponent and its compositional slots. This is the Code Scanning surface — a Security surface — of Phase 2 of the Timeline events effort (github/primer#6663). The Issues surface (#8070), Issue comment cards (#8072), the Dependabot alert surface (#8071), and the Secret Scanning surface (#8073) already landed; License Compliance will follow as a separate Security surface.Like Dependabot (and unlike Secret Scanning, which is fully React), Code Scanning is server-rendered ERB — there is no React timeline anywhere in
github/github-ui. So these events were translated faithfully from the live ERB ViewComponents into Primer React, the same approach used for the Dependabot surface (#8071).All examples live in a single new file,
Timeline.code-scanning.features.stories.tsx(+ a.module.css), exported under the titleComponents/Timeline/Events/Code Scanning— one story export per event group.The 6 event groups (15 variants total)
EventDetectedshield/ baregit-branch(default gray)EventFixedshield-checkon soliddone(purple, selected ref) / barecheck(other ref)EventClosedByUsershield-xon soliddanger(red)EventReopeneddot-fillon solidsuccess(green)EventDismissalRequestedcomment(default gray)EventDismissalReviewedcheck/ barex(default gray)Source of truth
These stories were recreated from the live ERB implementation in
github/github. The authoritative dispatch is thecase timeline_event.typeinapp/components/code_scanning/timeline_component.html.erb; per-event copy, badges, and actors were read directly from it, the sharedtimeline_item_component.html.erb, and the helpers (code_scanning_helper.rb,timeline_component.rb) and translated faithfully into Primer React. There is no React Code Scanning timeline — this surface is server-rendered.We verified the live render path rather than trusting the Figma audit blindly. The notable resolutions:
alert_closure_reasonsincode_scanning_helper.rb—False positive,Used in tests,Won't fix— andalert_closure_reason_descriptiondowncases them, so they render as "false positive" / "used in tests" / "won't fix". Closed-by-user bolds the reason; the:NO_RESOLUTIONpath (just "closed this") is also built.ref_name_bytes == @selected_ref) the badge isshield-checkon soliddone(purple); otherwise it is a plaincheckon the bare default badge. Both branches are shown for each of the two events.item.with_body(font_weight: :bold)), no avatar or link.delegated_dismissal_enabled?, and the "Review request" button is further gated ontimeline_event.show_dismissal_actions— both gates are noted inline. The button label "Review request" was confirmed fromdismissal_review_dialog_component.html.erb(aPrimer::Alpha::Dialogshow-button,scheme: :primary, size: :small).Slots
UserActorhelper — a circle avatar + bold login profile link.Timeline.Actions(right-controls slot, added in Add Timeline.Actions sub-component #7886) carries the right-aligned tool-versionLabel(scheme: :secondary, on any row carrying atool_version) and the Dismissal "Review request" button.Badge note
Gray/default events render as a bare
Timeline.Badge(no solid fill, no--timelineBadge-bgColorhook) — the whole Detected group, Fixed/Config-deleted on a non-selected ref, and both Dismissal events. Only Fixed-on-selected-ref (purple/done), Closed-by-user (red/danger), and Reopened (green/success) are solidvariant=badges — matching the livewith_badge(bg:)model, where only events that pass an explicitbackground:get a solid color.Scope & conventions
Timeline.docs.jsonorbuild.ts. Individual timeline events are not consumer-facing components.primer_react_timeline_list_semantics, refs Timeline: Use list semantics for screen reader navigation #7910) so every story renders in the<ol>/<li>DOM the timeline will ship.<section><h3 caption>scaffolding above each row so variants stay scannable like a Figma component set, without pollutingTimeline.Body.data-*event-category taxonomy (still open in github/primer#6663) — intentionally not baked in yet.repos/scanning/commitERB partials — noted in-code.Accessibility
The
UserActorprofile link is bold — the bold weight is the non-color differentiator that satisfies the axelink-in-text-blockrule (WCAG 1.4.1) in high-contrast themes, matching the livetext-boldprofile link and the Issues / Dependabot precedent.Changelog
Stories-only change — no consumer-facing component or API change, so no changeset (the
skip changesetlabel is applied).Rollout
No rollout concerns — adds Storybook examples only; ships no runtime code.
Testing
prettier— cleaneslint— cleanstylelint— cleantsc— 0 new type errors (the only repo tsc error is pre-existing inscript/components-json/build.ts)Merge checklist
Components/Timeline/Events/Code Scanningskip changeset+component: Timelinelabels applied