From 0ad4b86e3bb2cc03e889c363885d38639f864b92 Mon Sep 17 00:00:00 2001 From: Rui Maduro Date: Thu, 26 Nov 2026 21:42:58 +0000 Subject: [PATCH] feat: show a QR code for profiles --- DESIGN.md | 2 +- bun.lock | 3 + package.json | 1 + resources/js/components/profile-qr-button.tsx | 86 +++++++++++++++++++ resources/js/pages/organization/show.tsx | 5 ++ resources/js/pages/profile/unclaimed.tsx | 5 ++ resources/js/pages/user/show.tsx | 7 +- tests/Unit/ProfileQrButton.test.tsx | 16 ++++ 8 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 resources/js/components/profile-qr-button.tsx create mode 100644 tests/Unit/ProfileQrButton.test.tsx diff --git a/DESIGN.md b/DESIGN.md index 1cb2aab6e5..b2660c4d94 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -304,7 +304,7 @@ Content sits on the Cool Shell in a grid of panels: Feed White, 8px, hairline-bo 403, 404, 429, 500 (outside debug), and 503 render one standalone `error` page, with no app shell, for guests and signed-in users alike. A broken rail: the wordmark sits on a node in the viewer's lane (Rail Gray for guests) whose segment fades out before reaching a hollow, dangling node. Beside it, a mono git-style line (`fatal: path '/x' does not exist in 'HEAD'`), a Headline sentence saying what happened, one muted sentence saying what to do, and a single primary button ("Back to your log", "Go to the home page", or "Try again" during maintenance). A 419 is not a page: it redirects back with an error toast. ### Profile Header -A 80px avatar with a 2px lane ring offset 4px from the surface, name in Title, mono handle led by the lane dot, metadata with 16px line icons, and mono counts paired with sans labels ("3 commits", "5 following"). +A 80px avatar with a 2px lane ring offset 4px from the surface, name in Title, mono handle led by the lane dot, metadata with 16px line icons, and mono counts paired with sans labels ("3 commits", "5 following"). Its actions sit top right and wrap under each other when they do not fit; a QR code button beside Share opens a small dialog with the profile URL as a QR code, always black on a white 6px-rounded panel so any camera reads it in either theme, and the URL in mono under it. ### Commit Activity Below the profile header, scaled to how long the user has been visibly active (from their first visible commit, or account creation when there is none): the smallest window that holds all of it wins. Within the last 24 hours, a strip of 24 hourly cells labelled every six local hours in mono ("06:00"); within 7 days, a strip of 7 day cells labelled "Thu 15" (the weekday above the date below sm); within 30 days, a strip of 30 day cells labelled on Mondays ("Oct 12"); anything longer, a GitHub-style 53-week grid (Sunday-first columns, Mon/Wed/Fri row labels, month labels on month change). Strips are zoomed-in rows of the grid: equal-width cells, 40px tall (48px from sm), same gaps and rounding. Cells are 2px-rounded with 3px gaps, filled in the profile owner's lane: Muted for empty buckets, then the lane mixed into the surface at 32/56/80/100% for levels 1–4 relative to the busiest bucket. The total is mono, followed by the window ("in the last 24 hours/7 days/30 days/year"); a user with no visible commits reads "No commits yet" over an empty strip. Day cells are UTC days; hourly cells are UTC hours labelled in the viewer's local time. On narrow screens the year grid scrolls horizontally, opening on the most recent week; strips always fit. diff --git a/bun.lock b/bun.lock index 34926b5cba..864d980765 100644 --- a/bun.lock +++ b/bun.lock @@ -29,6 +29,7 @@ "laravel-vite-plugin": "^3.2.1", "lucide-react": "^1.77.0", "pusher-js": "^8.6.0", + "qrcode.react": "^4.2.0", "react": "^19.3.1", "react-dom": "^19.3.1", "sonner": "^2.0.8", @@ -707,6 +708,8 @@ "pusher-js": ["pusher-js@8.6.0", "", { "dependencies": { "tweetnacl": "^1.0.3" } }, "sha512-wShJPfCS/kYkCBVzVW67wa9cnQIgHTszEK2XHNrFkOgGruuGw081aERAxfRjfdFU+WcIt8x6dvbwkTW4iZuQ8Q=="], + "qrcode.react": ["qrcode.react@4.2.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-QpgqWi8rD9DsS9EP3z7BT+5lY5SFhsqGjpgW5DY/i3mK4M9DTBNz3ErMi8BWYEfI3L0d8GIbGmcdFAS1uIRGjA=="], + "react": ["react@19.3.1", "", {}, "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw=="], "react-aria": ["react-aria@3.53.1", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.9", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "aria-hidden": "^1.2.3", "clsx": "^2.0.0", "react-stately": "3.51.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-dikisyOjJd3D2fFrIDWmVWzqiLz5B86GzZv1zxs7xI4dVc0JIz/1Wa52I20gYvVL2WXeFXlygYsle/QcOMhtcg=="], diff --git a/package.json b/package.json index 376ea114ed..05fec43b8c 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "laravel-vite-plugin": "^3.2.1", "lucide-react": "^1.77.0", "pusher-js": "^8.6.0", + "qrcode.react": "^4.2.0", "react": "^19.3.1", "react-dom": "^19.3.1", "sonner": "^2.0.8", diff --git a/resources/js/components/profile-qr-button.tsx b/resources/js/components/profile-qr-button.tsx new file mode 100644 index 0000000000..5d0152730d --- /dev/null +++ b/resources/js/components/profile-qr-button.tsx @@ -0,0 +1,86 @@ +import { QrCode } from 'lucide-react'; +import { QRCodeSVG } from 'qrcode.react'; +import { useState } from 'react'; +import { Button } from '@/components/ui/button'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog'; + +/** + * Shows the profile's link as a QR code, so someone nearby can open it with a phone camera. + */ +export function ProfileQrButton({ + handle, + href, +}: { + handle: string; + href: string; +}) { + const [open, setOpen] = useState(false); + const [url, setUrl] = useState(null); + + // The absolute URL needs the browser's origin, so it is resolved when the dialog opens + // and kept while it closes, so the code stays put through the exit animation. + const onOpenChange = (next: boolean) => { + if (next) { + setUrl(new URL(href, window.location.origin).href); + } + setOpen(next); + }; + + return ( + + + + + + + + Scan @{handle}'s profile + + + Point a phone camera at the code to open the profile. + + + {url !== null && ( +
+ {/* Always dark on white, even in dark mode, so every camera can read it. */} +
+ +
+

+ {url.replace(/^https?:\/\//, '')} +

+
+ )} +
+
+ ); +} diff --git a/resources/js/pages/organization/show.tsx b/resources/js/pages/organization/show.tsx index c0acd0801c..8a4ddcc106 100644 --- a/resources/js/pages/organization/show.tsx +++ b/resources/js/pages/organization/show.tsx @@ -10,6 +10,7 @@ import { GitHubIcon } from '@/components/github-icon'; import { OrganizationAvatar } from '@/components/organization-avatar'; import { OrganizationFollowButton } from '@/components/organization-follow-button'; import { PageTabs } from '@/components/page-tabs'; +import { ProfileQrButton } from '@/components/profile-qr-button'; import { ProfileShareButton } from '@/components/profile-share-button'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Button } from '@/components/ui/button'; @@ -91,6 +92,10 @@ export default function Show({ handle={organization.handle} href={show(organization).url} /> + + {auth.user === null ? (