Skip to content

feat: expose compact absolute time in RelativeTime - #4259

Draft
tay1orjones wants to merge 5 commits into
mainfrom
copilot/expose-compact-absolute-time-preset
Draft

tay1orjones wants to merge 5 commits into
mainfrom
copilot/expose-compact-absolute-time-preset

Conversation

@tay1orjones

@tay1orjones tay1orjones commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

Add an opt-in preset to Primer::Beta::RelativeTime. When the element selects absolute output, it shows localized 12-hour time for today or a short date with its year for any other day. Relative and duration output stay unchanged.

render Primer::Beta::RelativeTime.new(datetime: timestamp, absolute_format: :compact)

Screenshots

No screenshots attached. Verified preview text: today at 3:04 PM and Nov 2, 2026.

Integration

No consumer changes required. Keep in draft: 5.3.1 is still the latest release and does not support the preset. Before merge, verify the release that contains the feature, update the root package.json and package-lock.json, remove the 5.3.1 test guards, and rerun the browser checks against that release.

List the issues that this change affects.

Upstream dependency: compact absolute-time preset · implementation PR

Risk Assessment

  • Low risk — Opt-in; omitting the argument preserves existing behavior.
  • Medium risk
  • High risk

What approach did you choose and why?

  • Wrapper: Validate with fetch_or_fallback and emit absolute-format="compact" only for the valid preset. Keep server fallback text, datetime, and title handling unchanged.
  • Formatting: Keep formatting in the shared element. Compact absolute text overrides prefix, format_style, and individual date/time display fields. Locale and display time zone still apply; the visible time zone is omitted.
  • Coverage: Add a Lookbook control and preview, component and system tests, and a minor changeset.

Anything you want to highlight for special attention from reviewers?

  • Verified build: All 8 component tests and 4 Chrome 156 system tests passed with the package built from upstream commit 84ab6dc47882f5e487a46059a13b340076c33e06. With locked 5.3.1, only the compact absolute-output system test skips.
  • Upstream recheck: Head moved to adfbb14caacd38914cfd5c52dac2c7a3996ac9ea. The new commit caps the initial timer at one hour without changing the attribute API or formatting. The wrapper tests did not use this newer commit.

Accessibility

  • No new axe scan violation - The tested Chrome previews reported no axe violations. Full and custom titles and no_title behavior are unchanged.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a3a9e5d

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

This PR includes changesets to release 1 package
Name Type
@primer/view-components 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

tay1orjones and others added 2 commits November 19, 2026 21:01
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@tay1orjones tay1orjones changed the title [WIP] Expose the compact absolute-time preset in Primer::Beta::RelativeTime feat: expose compact absolute time in RelativeTime Nov 19, 2026
@tay1orjones

Copy link
Copy Markdown
Contributor Author

@copilot @github/relative-time-element 5.4.0 is out with the absolute-format attribute. Update this PR to use it.

  1. Set @github/relative-time-element to ^5.4.0 in the root package.json.
  2. Update package-lock.json so it resolves 5.4.0. Don't change any other dependency.
  3. Remove the 5.3.1 guards. In test/components/primer/beta/relative_time_test.rb, restore the original assert_empty class_params - fields - deprecated_fields, "Extra fields on component" line and drop the extra_fields exception and its comment. In test/system/beta/relative_time_test.rb, remove the 5.3.1 skip, the package line above it, and the require "json" this PR added.
  4. Run the component tests and the RelativeTime system tests.
  5. In the PR description, rewrite "Integration" to say this needs 5.4.0 or later. Delete the "Verified build" and "Upstream recheck" bullets. Leave the rest alone.

5.4.0 also ships other fixes: calendar-day "yesterday" and "tomorrow", tabular numerals, and relative text for past times under a minute. If a RelativeTime test fails because of one of them, don't change the test. Comment with the test name and the error, then stop.

Keep the PR in draft. Don't hand-edit static/*.json. The "Generate static files" workflow updates them.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@copilot @github/relative-time-element 5.4.0 is out with the absolute-format attribute. Update this PR to use it.

  1. Set `@gi...

Updated in 6be7ad7. The root dependency is ^5.4.0, the lockfile resolves 5.4.0, and both temporary test guards are gone. All 865 component tests and all 4 RelativeTime system tests (Chrome 156) passed with no skips. The PR remains in draft; no other dependencies or tracked static files changed.

I couldn’t edit the PR description from this session. Replace the Integration paragraph with: “No consumer changes required. The compact preset requires @github/relative-time-element 5.4.0 or later.” Delete the Verified build and Upstream recheck bullets and leave the rest unchanged.

This branch was successfully deployed

1 active deployment
preview — a3a9e5d0 Deployed Nov 20, 2026 by primer[bot] via Demo Build & Deploy #8164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the compact absolute-time preset in Primer::Beta::RelativeTime

3 participants