Repository navigation
Description
Summary
Atlas event sharing is hand-rolled and static: ShareContent (src/components/molecules/ShareContent/ShareContent.tsx) renders a fixed row of 5 share targets (Email, Facebook, X, LinkedIn, Flipboard) from inline intent-URL templates, with no Web Share API and no awareness of who is sharing or from where. Meditation events are shared globally — a viewer in Russia wants VK/Telegram, one in Japan wants LINE, one in India wants WhatsApp — yet every viewer sees the same five Western targets, and mobile users never get their native OS share sheet (the one surface that already knows their installed apps). This replaces the mechanism with a comprehensive, library-backed one: react-share for broad global + region-specific coverage, the native Web Share API on capable devices, and a small region→platforms map that orders targets to the viewer's region.
Research finding: no single library covers all three needs (broad + region-specific platforms, region filtering, Web Share API). The architecture is react-share (base — React 18, TS, tree-shakeable, zero <head>/SDK assumptions, so safe inside the <sahaj-atlas> embed) + a tiny self-authored navigator.share wrapper + a hand-maintained country → ordered platforms map (no npm package provides per-region platform preferences).
Relationship to #52: WS7 adds the resolver summary header above ShareContent; it does not touch the share targets. This ticket replaces the targets/mechanism inside ShareContent; the two are complementary (PR #58 line).
Current behavior
ShareContent({ label, url })hardcodes asocialsarray of 5 intent URLs (ShareContent.tsx:72-93), rendered as<Link target="_blank">around house SVG icons — identical for every viewer, region, and device.- No
navigator.shareanywhere in the repo — mobile users never get the native sheet. label/urlareencodeURI'd then interpolated into intent URLs (ShareContent.tsx:70-71), which double-encodes once a library that encodes internally takes over (fix in passing).- Share icons are hand-drawn SVGs in
src/components/atoms/Icons/socials.tsx. - Two consumers pass only
label+url:ShareView.tsx:36andRegistrationForm.tsx:111(registration thank-you screen).
Proposed improvement
Confirmed product decisions:
- Region signal → the viewer's location (not the event's country). From
useIpLocation()(extended to expose the ISOcountry_code) with a locale-region-subtag fallback, then a universal default. - Mobile → native-first, grid fallback, keyed on
navigator.sharecapability (not UA): when available, one prominent "Share…" button opens the native sheet (which surfaces the user's installed apps — WhatsApp, KakaoTalk, WeChat, SMS — the ultimate region filter); otherwise render the region-filtered button grid. Copy-link always visible. If a native call fails (a host page can disableweb-shareviaPermissions-Policy→NotAllowedError), reveal the grid so the user is never stranded. - Icons → react-share's bundled icon components, and remove the in-house social-share icons react-share replaces (Email, Facebook, X/Twitter, LinkedIn, VK) plus Flipboard (dropped — react-share has no Flipboard button). Keep the meeting glyphs (Zoom, Google Meet, YouTube).
Changes:
- Add
react-share(pnpm add; named imports only so Vite tree-shakes to the ~5–8 buttons actually rendered). - New pure
src/lib/share/platforms.ts: aPlatformKeyunion,DEFAULT_PLATFORMS, aPLATFORMS_BY_COUNTRYmap (ISO alpha-2 → ordered list, seeded from DataReportal, hand-maintained) andplatformsForCountry(code?). Platforms: WhatsApp, Telegram, Facebook, X, LinkedIn, Reddit, Email, VK, OK.ru, LINE, Viber, Weibo. (KakaoTalk/WeChat/Zalo/SMS have no web-share URL → native sheet only.) - Extend
IpLocationSchema(src/types/ip-location.ts) with optionalcountry_code; new thin hooksrc/hooks/use-viewer-country.ts(IP → locale subtag → undefined). - New
src/hooks/use-web-share.ts: SSR-safe{ canShare, share }wrapper overnavigator.share. - New
src/components/molecules/ShareContent/platform-buttons.tsx:PlatformKey→ react-share*ShareButton+*Iconrenderer, each with an i18n aria-label. - Refactor
ShareContent: keepCopyField+ thelabel/urlAPI, add an optionalcountry?prop (resolved by the consumers so the molecule stays pure/SSR-testable), drop theencodeURIdouble-encode, render native-button-or-grid. - Wire
ShareView+RegistrationFormto resolve viewer country viauseViewerCountry()and passcountry. - Remove the replaced icons from
socials.tsx; trim theSOCIAL_ICONS/SocialIcondispatcher and theIcons.stories.tsxgallery. - Add i18n aria-label keys (
share.share_onwith%{platform},share.native) across all locales viapnpm i18n:add.
Acceptance criteria
-
react-shareadded; only named*ShareButton/*Iconimports (tree-shaken);embed.jsgzip delta noted in the PR -
platformsForCountryreturns a region-ordered list for seeded countries (RU→VK/OK/Telegram, JP→LINE, IN→WhatsApp, US→X/Facebook) andDEFAULT_PLATFORMSfor unknown/undefined; case-insensitive - Share drawer shows the region-filtered grid on desktop; each button opens the correct platform composer with the right URL/title (no double-encoding)
- On a
navigator.share-capable device a "Share…" button opens the native OS sheet; the grid is the fallback when unavailable or when the native call is blocked; copy-link always present - Viewer country resolves from
useIpLocation().country_codewith a locale-subtag fallback and a graceful default (no error when both are absent) -
ShareContentstays pure/prop-driven (label,url, optionalcountry); both consumers (ShareView,RegistrationForm) keep working - In-house social-share icons replaced by react-share are removed (Email/Facebook/Twitter/LinkedIn/VK/Flipboard); meeting glyphs (Zoom/Meet/YouTube) kept; dispatcher + icon story updated; no dangling references
- Platform aria-labels added across all 10 locales (
%{}interpolation) viapnpm i18n:add - Unit tests (node-only,
renderToStaticMarkup):platformsForCountryselector,ShareContentgrid output for ≥2 regions + a raw-URL assertion,useWebSharedetection - Ladle stories demo region variants (a
countryarg onShareContent; seeded['ip-location']onShareView) - Lint + typecheck +
test:run+ build +ladle:buildpass
Files affected
src/components/molecules/ShareContent/ShareContent.tsx(+ newplatform-buttons.tsx, story, test)src/lib/share/platforms.ts(new, + test)src/hooks/use-web-share.ts,src/hooks/use-viewer-country.ts(new)src/types/ip-location.ts(addcountry_code)src/views/ShareView/ShareView.tsx(+ story),src/components/organisms/RegistrationForm/RegistrationForm.tsxsrc/components/atoms/Icons/socials.tsx,src/components/atoms/Icons/Icons.stories.tsxpublic/locales/<lng>/common.json(aria-label keys)
References
- feat(event): redesign event display & registration surfaces #52 (event-surfaces redesign — WS7 adds the share summary header; complementary), PR feat(event): redesign event display & registration surfaces #58
react-share— https://github.com/nygardk/react-share- Web Share API — https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
- Region seed — DataReportal "Digital 2026"
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
Merge main into feat/region-aware-share
feat(share): region-aware targets + native Web Share via react-share (#…