-
Notifications
You must be signed in to change notification settings - Fork 18
Simplify SSW.Rules footer deployment line + iPad portrait fix (+ review follow-ups) #2646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+112
−36
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1443e30
Shorten footer deployment text for portrait iPad
0xharkirat a36ec4a
Apply Tiago feedback: tooltip date, lg breakpoint, commit hash link
0xharkirat bab328d
Simplify footer affordances: drop continuous-deployment link, refine …
0xharkirat f760969
Add RelativeTime client component with custom tooltip and UTC fix
0xharkirat c8f8cb8
Link 'continuous deployment' to the SSW rule with visible underline
0xharkirat 8c486ef
Consistent hover style on footer hoverables: white -> red, no underline
0xharkirat 169c4eb
Merge branch 'main' into hs/footer-shorten-deployment-info
tiagov8 acc1586
Apply Copilot review feedback + a11y / bundle polish
0xharkirat 6bf1664
Apply Copilot follow-ups: pathPrefix, Last updated, conditional curso…
0xharkirat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useId, useState } from "react"; | ||
|
|
||
| interface Props { | ||
| buildTimestamp: number; | ||
| buildDate?: string; | ||
| } | ||
|
|
||
| const MONTHS = [ | ||
| "Jan", | ||
| "Feb", | ||
| "Mar", | ||
| "Apr", | ||
| "May", | ||
| "Jun", | ||
| "Jul", | ||
| "Aug", | ||
| "Sep", | ||
| "Oct", | ||
| "Nov", | ||
| "Dec", | ||
| ]; | ||
|
|
||
| function formatRelative(deltaMs: number): string { | ||
| const delta = Math.abs(deltaMs) / 1000; | ||
| const days = Math.floor(delta / 86400); | ||
| const hours = Math.floor((delta % 86400) / 3600); | ||
| const minutes = Math.floor((delta % 3600) / 60); | ||
| if (days > 0) return `${days} day${days > 1 ? "s" : ""} ago`; | ||
| if (hours > 0) return `${hours} hour${hours > 1 ? "s" : ""} ago`; | ||
| if (minutes > 1) return `${minutes} min ago`; | ||
| return "1 min ago"; | ||
| } | ||
|
|
||
| function formatUtcDate(iso: string): string | undefined { | ||
| const d = new Date(iso); | ||
| if (Number.isNaN(d.getTime())) return undefined; | ||
| const day = d.getUTCDate(); | ||
| const month = MONTHS[d.getUTCMonth()]; | ||
| const year = d.getUTCFullYear(); | ||
| const hh = String(d.getUTCHours()).padStart(2, "0"); | ||
| const mm = String(d.getUTCMinutes()).padStart(2, "0"); | ||
| return `${day} ${month} ${year} at ${hh}:${mm} UTC`; | ||
| } | ||
|
|
||
| /** | ||
| * Renders "X min/hour/day(s) ago" and ticks every 60s so the relative time | ||
| * stays accurate even when the page HTML is cached. On hover or keyboard | ||
| * focus it shows a custom tooltip with the exact build date (UTC). Client- | ||
| * only — server initially renders with delta=0 ("1 min ago") and the | ||
| * client immediately recomputes on mount to avoid hydration mismatch. | ||
| * | ||
| * Accessibility: the wrapper is focusable when a tooltip is present so | ||
| * keyboard users can reveal it, and the tooltip is linked via | ||
| * `aria-describedby` so screen readers announce it after the visible time. | ||
| */ | ||
| export function RelativeTime({ buildTimestamp, buildDate }: Props) { | ||
| const [now, setNow] = useState<number>(buildTimestamp); | ||
| const tooltipId = useId(); | ||
|
|
||
| useEffect(() => { | ||
| setNow(Date.now()); | ||
| const id = setInterval(() => setNow(Date.now()), 60_000); | ||
| return () => clearInterval(id); | ||
| }, []); | ||
|
|
||
| const formatted = buildDate ? formatUtcDate(buildDate) : undefined; | ||
| const tooltip = formatted ? `Last updated ${formatted}` : undefined; | ||
|
|
||
|
0xharkirat marked this conversation as resolved.
|
||
| return ( | ||
| <span | ||
| className={`relative inline-block group text-white hover:text-ssw-red focus-visible:text-ssw-red transition-all duration-300 ease-in-out${tooltip ? " cursor-help" : ""}`} | ||
| tabIndex={tooltip ? 0 : undefined} | ||
| aria-describedby={tooltip ? tooltipId : undefined} | ||
|
0xharkirat marked this conversation as resolved.
|
||
| title={tooltip} | ||
| > | ||
| {formatRelative(now - buildTimestamp)} | ||
| {tooltip && ( | ||
| <span | ||
| id={tooltipId} | ||
| role="tooltip" | ||
| className="absolute left-1/2 -translate-x-1/2 bottom-full mb-1 px-2 py-1 bg-white text-gray-900 text-[11px] leading-none rounded whitespace-nowrap opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 pointer-events-none transition-opacity duration-150 shadow-md z-10" | ||
| > | ||
| {tooltip} | ||
| </span> | ||
| )} | ||
| </span> | ||
|
0xharkirat marked this conversation as resolved.
|
||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.