Files
hanzo.ai/components/products/OssAttribution.tsx
zeekay 24e67d965e landing: what we ship is counted, and drawn from the page's own parts
The commits section read numbers that were typed into scripts/sync-oss.ts
(5,420 repositories, 214 orgs, 784 pushes a day, 245,417 commits, each
contributor's count), a day's count scaled by a made-up factor, and a star
count that began at 1,420. The forge's database holds 1,150 repositories
and 46 orgs; none of that was read. Its panels were tinted rgba over a
stylesheet, DualStarButton showed its guess before GitHub answered, and
BulkStarModal said "successfully starred" over a forge PUT.

scripts/sync-oss.ts (was .mjs) now counts GitHub's public activity for the
orgs we publish: commits a day, the year, the week, active repositories and
the newest commits, written at each build with the moment it was read. A
figure the snapshot does not hold is not drawn. The grid, bars and
repository card are @hanzo/ui/marketing (8.29.19); the showcase stylesheet
and DayActivityModal are deleted. The org and repo pages lose their typed
"velocity" banners.

Design lint is zero in components/oss, home/OpenSource and ForgeBetaBanner.
e2e/gates/activity.spec.ts holds each figure to the snapshot, the cards to
one fill and edge in both schemes, a card's name, line and foot to their own
rows, and the phone to no sideways scroll.

Claude-Session: https://claude.ai/code/session_017vrVus6PPBgP5YRzKV1iqW
2026-10-26 09:57:01 -07:00

102 lines
4.1 KiB
TypeScript

'use client'
/**
* OSS attribution: the row of pills under a product's name in ProductFooter.
*
* One source of strings: lib/constants/products-metadata.ts. A small pill row
* (License, GitHub, Stars); the heading and the frame are ProductFooter's.
*
* Stars come from lib/data/oss-stars.json, which scripts/sync-oss.ts writes once
* per build, the starred repositories alone. Asked from the browser they cost every reader one of GitHub's sixty
* unauthenticated requests an hour and answered 403 once those ran out. A
* repository the snapshot does not hold draws no Stars pill; the block does not
* depend on a count.
*
* The three pills are `Chip`, this site's hairline outline. What the rule
* leaves to a caller is the SIZE — a chip and a badge are the same outline at
* two of them — so the padding and the rung are stated here and nothing else
* is. The GitHub pill is the one that is a link, and `Chip` is
* already the rule for that.
*
* The name lost its `hz-` prefix when this document's rules did, and this call
* site did not follow: with no rule behind it each pill was a full-width block
* with no outline, rather than a chip. `Start.tsx` carries the measurement.
*/
import React from 'react'
import { Scale, Star, ExternalLink } from 'lucide-react'
import { Github } from '@/components/brand'
import { getProductMetadata, type ProductMetadata } from '@/lib/constants/products-metadata'
import { Text, XStack } from '@hanzo/ui'
import oss from '@/lib/data/oss-stars.json'
import { Chip } from '@hanzo/ui/marketing'
type Props = {
/** Product slug matching app/(marketing)/<slug>/page.tsx */
slug: string
/** Override metadata (useful when the page is generated from a non-canonical slug) */
meta?: ProductMetadata
className?: string
}
/** The pill at chip size: 12/4 of padding, one rung down, over a half-strength fill. */
const CHIP = { px: 12, py: 4, fontSize: "$1", lineHeight: "calc(1 / 0.75)", bg: "color-mix(in oklab, var(--secondary) 50%, transparent)" } as const
function parseRepoFromUrl(repoUrl: string): { owner: string; name: string } | null {
const m = /^https?:\/\/github\.com\/([^\/]+)\/([^\/?#]+)/.exec(repoUrl)
if (!m) return null
return { owner: m[1], name: m[2] }
}
export function OssAttribution({ slug, meta: metaProp, className = '' }: Props) {
const meta = metaProp ?? getProductMetadata(slug)
const parsed = meta ? parseRepoFromUrl(meta.github_repo) : null
const counts: Record<string, number> = oss.stars
const stars = parsed ? (counts[`${parsed.owner}/${parsed.name}`] ?? null) : null
if (!meta) return null
return (
// A plain element carries the test id the products audit locates this
// row by; a data attribute handed to a gui stack is not something this
// repo has measured reaching the DOM.
<div data-testid="oss-attribution" className={className || undefined}>
<XStack flexWrap="wrap" items="center" gap={12}>
{/* License pill */}
<Chip data-testid="oss-license" {...CHIP}>
<Scale width={12} height={12} />
<Text fontWeight="500" color="inherit">License:</Text> {meta.license}
</Chip>
{/* GitHub repo pill */}
<Chip
render="a"
data-testid="oss-github"
href={meta.github_repo}
target="_blank"
rel="noopener noreferrer"
{...CHIP}
>
<Github width={12} height={12} />
<Text fontFamily="$mono" lineHeight="unset" color="inherit">
{meta.github_repo.replace('https://github.com/', '')}
</Text>
<ExternalLink width={12} height={12} opacity={0.6} />
</Chip>
{/* Stars pill, only when there are some: "0 stars" on a repository
the snapshot could not count, or one nobody has starred yet,
reads as an abandoned project rather than as a number. */}
{stars !== null && stars > 0 && (
<Chip data-testid="oss-stars" {...CHIP}>
<Star width={12} height={12} />
{stars.toLocaleString()} {stars === 1 ? 'star' : 'stars'}
</Chip>
)}
</XStack>
</div>
)
}
export default OssAttribution