Skip to content

feat(data): share and embed cards for every section, behind the share flag - #65994

Merged
iamdavidhill merged 190 commits into
devfrom
data-share
Nov 25, 2026
Merged

iamdavidhill merged 190 commits into
devfrom
data-share

Conversation

@iamdavidhill

@iamdavidhill iamdavidhill commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

No issue: new feature for opencode.ai/data.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a Share button to each section of the data home page. It opens an editor that makes a branded card of that section as a video, an image or an embed.

Behind the new data-site flag share (src/lib/flags.ts): on in local builds and every stage except production, off in production. DATA_FLAGS=share or DATA_FLAGS=-share forces it either way at build time. With it off, the buttons, the editor, /data/embed and /data/oembed are gone.

  • Editor: opens on the card alone, the modal hugging it, with Close, Mute, Shuffle, Customize and Save. Customize grows the modal and reveals every setting in the bar: Type, Date, Lead with, Chart, Layout, Size, Style, Data (embeds) and Music. Shuffle spins every setting's reel to a random card. Undo and redo with ⌘Z / ⇧⌘Z. The settings are remembered once changed. On phones the settings move to a bottom sheet.
  • Cards: drawn on a canvas (src/share/card.ts), so the preview, the PNG and every video frame come from the same code. Headline, Number and Title layouts; 4:5, 1:1, 9:16 and 16:9; Dark, Light and Top styles.
  • Charts: bars, or a race of the leaders overtaking each other day by day over the range. For a single day: bars, a ranked list or a dot matrix. Plus the leaderboard podium and the model comparison.
  • Video: MediaRecorder (MP4, WebM fallback) with an optional soundtrack of 14 tracks (public/share-music, 7 explicit). It opens on a blank card, cuts on the track's beat, plays a dot equaliser behind bar charts and ends on beat-cut closing slides. Music always starts muted when the editor opens. A timeline under the card seeks the video and the music.
  • Embed: /data/embed/<section> draws the card in an iframe, silent, playing once when it scrolls into view. Live (rebuilt from the latest data) or Fixed (the card packed into the URL fragment). /data/oembed turns a pasted link into the card.
  • Translated: the cards, the editor, the calendar and the embeds follow the site's language, in all 18 locales. translate() gains plural forms ({{count|one:day|other:days}}). The editor works right to left in Arabic, and Arabic falls back to a proportional Arabic face instead of Courier New's monospace Arabic.
flowchart LR
  Page[Section Share button] --> Sections[share/sections.ts]
  Embed[/data/embed/section/] --> Sections
  Sections --> Card[share/card.ts canvas]
  Card --> Preview[Editor preview]
  Card --> PNG[Image]
  Card --> Video[Video + soundtrack]
  Card --> Iframe[Embed iframe]
Loading

How did you verify your code works?

Exported images, videos and embeds from every section, size and chart, and checked frames, in English, German, Japanese and Arabic.

Screenshots / recordings

Editor Customized Phone
Share editor Share editor after Customize Share editor on a phone
Race (1:1 and 16:9) One day as dots
Race chart Dot matrix
German and Japanese cards Arabic editor
Translated cards Arabic editor

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit-track point is fixed: Share opens with its music muted, and Shuffle only picks clean tracks. I couldn't watch the cards because there's no browser here. I checked on vite dev that translated embeds and oEmbed work: /de/data/embed/retention is served in German, and /data/oembed returns the German title and a /de/ iframe. The package tests (44, including share-i18n.test.ts) and tsc pass. Public API: unchanged.

The nav font and Live-embed threads are still open. The new chart choice (race, list, dots) has the same problem as the day and Lead: embedUrl doesn't carry it, so a Live embed falls back to the default bars.

adamdotdevin
adamdotdevin previously approved these changes Nov 25, 2026

@adamdotdevin adamdotdevin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approved. Merge once CI is green.

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.

2 participants