From eb628fbdb0a01793d1a7d16dca5ef7e7f16c2d8d Mon Sep 17 00:00:00 2001 From: Xavy Date: Sat, 28 Mar 2026 16:03:53 +0100 Subject: [PATCH] feat: implement streak sharing functionality with ShareStreakCard and ShareOptionsSheet components --- frontend/app/streak/page.tsx | 27 ++-- frontend/components/ShareOptionsSheet.tsx | 28 +++- frontend/components/ShareStreakCard.tsx | 155 ++++++---------------- 3 files changed, 82 insertions(+), 128 deletions(-) diff --git a/frontend/app/streak/page.tsx b/frontend/app/streak/page.tsx index f844d0f..ca14e6d 100644 --- a/frontend/app/streak/page.tsx +++ b/frontend/app/streak/page.tsx @@ -162,7 +162,7 @@ const StreakCalendar: React.FC = ({

Streak

diff --git a/frontend/components/ShareOptionsSheet.tsx b/frontend/components/ShareOptionsSheet.tsx index 213b6d8..c925dcc 100644 --- a/frontend/components/ShareOptionsSheet.tsx +++ b/frontend/components/ShareOptionsSheet.tsx @@ -77,6 +77,27 @@ const ShareOptionsSheet: React.FC = ({ }; }, [isOpen, onClose]); + const handleTabKey = (event: React.KeyboardEvent) => { + if (event.key !== 'Tab' || !sheetRef.current) return; + + const focusable = sheetRef.current.querySelectorAll( + 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' + ); + + if (focusable.length === 0) return; + + const first = focusable[0]; + const last = focusable[focusable.length - 1]; + + if (event.shiftKey && document.activeElement === first) { + event.preventDefault(); + last.focus(); + } else if (!event.shiftKey && document.activeElement === last) { + event.preventDefault(); + first.focus(); + } + }; + // Prevent body scroll when sheet is open useEffect(() => { if (isOpen) { @@ -101,7 +122,7 @@ const ShareOptionsSheet: React.FC = ({
{/* Backdrop */}
@@ -113,12 +134,13 @@ const ShareOptionsSheet: React.FC = ({ role="dialog" aria-modal="true" aria-labelledby="share-sheet-title" + onKeyDown={handleTabKey} > {/* Header */}
+ +

I'm on a - +
{streakCount} - +
day streak!

{shareText}

- Streak flame +
+ Streak flame +
-

mind block

-
-
-
+ +

mind block

-
event.stopPropagation()} - > -
-
+ {/* Share Button */} -

Share Your Streak

-
-
-
- {shareOptions.map((option) => ( - - ))}