Add social share for completed hands (canvas image + Twitter/X + copy as text) - #484
Merged
Merged
Conversation
…+ copy as text) - hand-share.ts: builds a plain-text hand summary (rank, pot, table/ hand number, explorer link), renders a canvas summary image, and converts it to a PNG blob for sharing - HandShareButton.tsx: share modal offering "Share to X" (uses the Web Share API with the rendered image when supported, falling back to the Twitter/X web intent + an image download when it isn't, since Twitter's intent URL cannot attach an image directly), "Copy as text", and "Download image" - HandHistoryPanel.tsx: adds the share button next to the existing replay button on each completed hand entry Closes HitEmPoka#162
|
@gboigwe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a share button to each completed hand in the hand history panel, offering:
navigator.canShare({ files })); falls back to opening Twitter/X's web intent with the text pre-filled plus triggering an image download, since Twitter's intent URL has no way to attach an image directly — a real platform limitation, not something a client-side app can work around.The canvas summary and the share text both include hand rank, pot size, and a link to the hand's transaction on the explorer (via the existing
stellarExpertUrlhelper), per the issue.Issue
Closes #162
Test plan
npx vitest run— 131 passed, same 4 pre-existing failures as onmain(audio-controls.test.tsx,reconnect-state.test.ts— unrelated, unchanged by this work)hand-share.test.ts(8 tests): share-text formatting incl. fallback for missing rank/no tx hash, Twitter intent URL encoding, canvas dimensions, and graceful (non-throwing) degradation when the environment has no 2D canvas contexthand-share-button.test.tsx(4 tests): button open/close, modal contents, clipboard copy + "Copied!" feedbackvi.stubGlobal("navigator", ...)in the new component test wasn't being unstubbed after each test, which leaked into and broke an unrelated test file (replay-viewer.test.tsx) when running the full suite. Added the missingafterEach(() => vi.unstubAllGlobals())and confirmed the full suite is clean again.npx tsc --noEmit— no new errors from this change. All remaining errors are pre-existing and unrelated (token-selector.test.tsx,page.tsx:668,Table.tsxreplayEntry/setReplayEntry,reconnect-state.ts) — not touched, since this PR doesn't cause them.