Repository navigation
feat(share): region-aware targets + native Web Share via react-share - #62
Merged
Merged
Conversation
Add the foundation for region-aware, native-first event sharing (#61): - react-share dependency (named imports; tree-shaken to the rendered buttons). - src/lib/share/platforms.ts: a PlatformKey union, DEFAULT_PLATFORMS, a hand-maintained ISO alpha-2 -> ordered-platforms map (DataReportal-seeded), and a case-insensitive platformsForCountry() resolver (+ test). - useWebShare: SSR-safe { canShare, share } over navigator.share; share() resolves false on a missing API / AbortError / NotAllowedError so callers can fall back to the grid (+ test). - useViewerCountry: IP country_code -> locale region subtag -> undefined. - IpLocationSchema gains an optional, self-healing country_code. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace ShareContent's fixed 5-target row with a region-aware, native-first share block (#61): - platform-buttons.tsx: PlatformKey -> react-share button + round icon, each with a "Share on %{platform}" aria-label (Facebook carries no title text; Email maps the title to the mail subject). - ShareContent: keeps CopyField + the label/url API, adds an optional `country`, drops the encodeURI double-encode (react-share/the native sheet encode their own params), and renders native-"Share…"-button-or-grid — revealing the grid when there's no Web Share API or the native call is blocked/dismissed. - share.share_on / share.native aria-label keys across all 10 locales. - Unit test (region ordering, default fallback, raw-URL, native-first) + a Ladle story with a `country` control and an always-visible region-ordering gallery. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both ShareContent consumers now resolve the viewer's country via useViewerCountry() and pass it as `country`, so the share grid is ordered to the viewer's region — the event share drawer and the registration thank-you screen. Resolving in the consumers keeps ShareContent a pure, prop-driven molecule. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…share Remove Email/Facebook/Twitter/LinkedIn/VK/Flipboard from socials.tsx and trim the SOCIAL_ICONS/SocialIcon dispatcher + the Icons story gallery to the kept online-meeting glyphs (Zoom/Google Meet/YouTube), which the event detail row still resolves via detectPlatform. The social-share targets now render react-share's own bundled icons. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Read the shared ['ip-location'] cache with enabled:false so opening a share sheet never triggers the third-party geolocation lookup itself — it reuses the result when the nearby-events suggestion already fetched it, and otherwise falls back to the locale subtag / default set. Respects the suppression the nearby suggestion applies when dismissed or during an active search (from the /simplify pass). Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…al link An unpublished/gated event has a null webUrl; the consumers passed '' through to ShareContent, so the new native share sheet would resolve the empty URL to the host page (and the copy field would be blank). Fall back to window.location.href — the widget's current deep link — in both the share drawer and the registration thank-you screen, so a share/copy always carries a real URL. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add react-share to the CLAUDE.md tech-stack table and refresh the ShareContent row in DESIGN_SYSTEM.md — it's now a region-ordered react-share grid with a native Web Share fallback, not a fixed social-links block. Refs #61 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
6ab20d0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://05170ddd.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-region-aware-share.sahajatlas.pages.dev |
Reconcile #61 (region-aware share) with #58 (event-surfaces redesign), now on main. Conflict resolutions: - ShareContent.tsx: keep #58's exported i18n/a11y CopyField + #61's region grid and native Web Share body (drops the old socials row, which #58 left untouched and #61 replaces). - ShareContent.test.tsx: keep #61's region/native/raw-URL SSR tests (the old encodeURIComponent socials assertions no longer apply). - ShareView / RegistrationView: keep #58's EventSummary header + registration gating; add #61's useViewerCountry + country prop. Both sides already converge on `event.webUrl ?? window.location.href`. - public/locales/*/common.json: union of share.{copy_link,copied} (#58) + share.{share_on,native} (#61). - DESIGN_SYSTEM.md: #58's reorganized molecules table with #61's ShareContent description (region-ordered react-share + native Web Share fallback). - Button API: #58 dropped startContent, so the native-share icon renders as a child of Button. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…mbed key Two fixes to the PreToolUse security-scan, both surfaced while committing the main merge: - The block reason was written only to stdout while exiting 2, so the harness reported a bare "No stderr output" with no clue what tripped. Write the reason (file, matched pattern, matched line, remediation) to stderr too. - Split the patterns into high-confidence secrets (sk.… tokens, private keys, named secret env vars — scanned everywhere) and generic quoted-credential heuristics. Skip the heuristics for known public embed files (demo.html), which carry the PUBLISHED sahaj-atlas-client api-key by design — the widget's whole purpose is embedding a publishable key in host HTML. Real secrets in demo.html are still caught by the high-confidence set. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The share grid fits six icons per row in the drawer, and every country list is already six or fewer — only DEFAULT_PLATFORMS had seven, so the unknown-region fallback wrapped a lone Email icon onto a second row. Drop Reddit from the universal default (it's anglophone-skewed and stays in the US/GB/CA/AU/BR lists), keeping Email; the default now matches the country lists and the grid stays one balanced row. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Email is now appended by platformsForCountry rather than listed in each set, so it's available everywhere and appears exactly once (last). Removed email from DEFAULT_PLATFORMS and every country list, and trimmed RU to five so the appended email keeps it a single six-icon row. Tests cover the append-once invariant, the no-email-in-stored-lists invariant, and the ≤6 single-row bound per region. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the in-person/online examples with a Region control (Default, Russia, East Asia, South Asia, Southeast Asia, Middle East, Europe, Americas, Africa, Oceania), each seeding a representative country_code into ['ip-location'] so the share grid reorders to that viewer's region. Disable the Web Share API in the preview so the grid renders instead of the single native "Share…" button (scoped to the Ladle session; the widget is untouched). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Collapse the duplicated DEFAULT_PLATFORMS ternary arms into a single `(code && PLATFORMS_BY_COUNTRY[…]) || DEFAULT_PLATFORMS` — every country list is a non-empty array, so one branch covers an unknown, empty, and nullish code. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
SocialIcon looked up SOCIAL_ICONS[platform] and rendered it unconditionally; the react-share migration shrank the keyset to three (zoom/google_meet/youtube), so a dropped key would render an undefined element and crash. Return null for an unknown key, and drop the stale comment referencing detectPlatform in EventDetails (removed in the event-surfaces redesign). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
block_secret interpolated the raw regex into the {"continue":false,"reason":…}
JSON; the patterns' backslashes (sk\.eyJ) and literal quotes (['\"]) made that
JSON invalid whenever the hook fired. The authoritative block is exit 2 + the
stderr reason (unaffected), but a host parsing only stdout would choke. Drop the
pattern from the JSON reason — it's still on stderr with the matched line.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
6ab20d0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7f1171cf.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-region-aware-share.sahajatlas-design.pages.dev |
Ardnived
pushed a commit
that referenced
this pull request
Sep 14, 2026
…oute (#207) * docs(embedding): document the head metadata a host writes per atlas route `docs/embedding.md` is the host-facing contract, and it never said what a host should put in its `<head>`. Every region and class page under an embed was described correctly by the sites that bothered; the entry point was not. #62 on WeMeditateWeb mounts `/map` with `atlas=/` and presents to a crawler as a duplicate of the site's homepage, because the page inherits the global title and description and emits no canonical. The rule is finally writable: sydevs/SahajCloud#769 made `GET /api/atlas/seo` answer **every** route the widget can mount with, the atlas root included. So the new section states the rule — a page's metadata describes the atlas route the widget mounted with — and names the endpoint that supplies it. What it covers, each verified against the shipped code and a live call: - Three worked examples, pasted from real responses: a region route, the root, and a bare view route. The region example also shows that `route` comes back normalized (`/gb/london` answers `/gb/south-east/london`), which a host comparing its canonical needs to know. - Which routes answer as the root, as a RULE rather than a list of five: eleven reserved segments are dropped wherever they appear, so `/events/areas` reduces to the root too. - Fetch server-side at render time, and cache for up to 300s per route and locale. `Vary: Authorization` splits that cache per SITE, not per visitor, because the credential is the host's own published client key — the header otherwise reads as "do not cache". A server-to-server call also sends no Origin, which the allowed-domains gate deliberately permits. - `canonical` for the root is the caller's own verified mount page, and so is per-API-key; a caller publishing none gets the We Meditate surface. - `description` is `null` in a locale with no operator copy, stated as a rule rather than as today's snapshot — sydevs/SahajCloud#778 fills that copy and would make a snapshot sentence false the day it merges. The host writes its own line and a self-referencing canonical. - The 400 and the two 404s, which say different things on purpose. - That the CSP table does not change, and why: the host's server makes the request, and `cloud.sydevelopers.com` is already in `connect-src`. `CHANGELOG.md` carries the host-visible entry, per the rule that it and `docs/embedding.md` move together. Nothing under `src/` changes. Closes #173. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * docs(embedding): tighten two claims against the endpoint's source `jsonLd`'s escaping names what is actually escaped — `<`, `>`, `&` and the two Unicode line separators (`jsonLdEscape` in SahajCloud's `seo/jsonLd.ts`) — so a host reading "already escaped" knows what re-stringifying would lose. `canonical` can be `null` for a region or an event, where no site publishes one (`seo/index.ts` reads `region.webUrl ?? null`). The section said it resolves, full stop. It now says what a `null` means and what to write instead. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(docs): name the locale codes the seo endpoint accepts `locale` is refined with `isValidLocale` against nineteen exact codes (SahajCloud `src/lib/locales/index.ts:14-33`), and `parseQuery` answers 400 on a miss. "Send the language your page declares in `<html lang>`" therefore breaks any host declaring `en-GB`, `en-US` or `pt`, and the refusal table blamed `route` for the 400 it got. Names the set, gives the mapping rule, and adds `locale` to the 400 row. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA * fix(docs): elide the canonical origin from the worked examples The examples printed `wemeditate-web.contact-c66.workers.dev` eight times, while the compact-card section names `wemeditate.com/map` as the same fallback surface — two answers to one question. sydevs/SahajCloud#783 asks whether that host is a misconfiguration at all, so baking it into the host-facing contract risks documenting a transient state. `…/map…` matches how `alternates` and `breadcrumbs` already abridge, so the responses stay pasted rather than hand-written, and a new paragraph says what the ellipsis stands for. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA * fix(docs): mark the example root title as the fallback constant `Free Meditation Classes` is `ROOT_TITLE_FALLBACK` (SahajCloud `src/endpoints/atlas/seo/rootStrings.ts:48`), the bottom of the chain, reached only because no operator root copy exists in any locale yet — `locale=de` returns the same English string. Printed bare, the example read as the root's real title and would date the day the copy lands. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA --------- Co-authored-by: Claude <[email protected]>
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
Replaces Atlas's hand-rolled, static 5-target share row (Email/Facebook/X/LinkedIn/Flipboard, identical for every viewer, no native sheet) with a region-aware, native-first share experience:
Permissions-Policy), so nobody is stranded.react-sharebutton grid ordered to the viewer's country (RU → VK/OK/Telegram, JP → LINE, IN → WhatsApp, US → X/Facebook…), resolved from the IP lookup with a locale-subtag fallback and a universal default. Email is always appended last (available everywhere, exactly once); every set is ≤6 so the grid stays a single balanced row.encodeURIdouble-encode is gone (react-share and the native sheet encode their own params).Changes
src/lib/share/platforms.ts— purePlatformKeyunion +PLATFORMS_BY_COUNTRY(DataReportal-seeded, ≤5 each) +platformsForCountry(case-insensitive, default fallback, appendsemail).src/hooks/use-web-share.ts— SSR-safe{ canShare, share };share()resolvesfalseon missing/blocked/dismissed so the caller reveals the grid.src/hooks/use-viewer-country.ts— IPcountry_code(cache-only,enabled:false) → locale region subtag →undefined.src/types/ip-location.ts— optional, self-healingcountry_code(.catch(undefined)).src/components/molecules/ShareContent/—ShareContent(native-or-grid, optionalcountry, pure/SSR-testable) +platform-buttons.tsx(react-share button+icon registry, i18n aria-labels).ShareView+RegistrationForm/RegistrationViewresolveuseViewerCountry()and passcountry; both fall back towindow.location.hrefwhen an event has no canonical link.socials.tsx); kept + guarded the Zoom/Meet/YouTube meeting glyphs.share.share_on/share.nativearia-label keys across all 10 locales.src/views/ShareView/ShareView.stories.tsx— a Region control (Default, Russia, East Asia, South Asia, Southeast Asia, Middle East, Europe, Americas, Africa, Oceania), each seeding acountry_codeso the grid reorders.Verification
platformsForCountryordering / append-once / single-row bound,ShareContentregion grid + raw-URL + native-first,useWebSharedetection/return) · Build ✓ ·ladle:build✓embed.jsentry unchanged (~1.6 kB gzip — react-share isn't in the bootstrap); react-share adds ~16 kB gzip to the lazily-loaded app chunk, tree-shaken to the rendered*ShareButton/*Icon.Manual / visual verification
The node lane can't drive the real native sheet or react-share intents:
Permissions-Policy: web-share 'none') reveals the region grid; copy-link stays visible.Notes for reviewer
ShareCountcomponents pull injsonp(dynamic<script>injection); Rollup doesn't tree-shake it despitesideEffects:false, so it ships as dead, never-executed code (endpoints hardcoded to first-party APIs;[email protected]is the CVE-patched version). We import only*ShareButton/*Icon, so "zero head/SDK assumptions" holds for what renders. Accepting it; no build plugin / lib swap warranted for nil runtime risk.Object.defineProperty(navigator,'share',…)at module scope) so the region grid renders instead of the single native button. Scoped to the Ladle session — story files never enter the widget bundle. Reviewers flagged it as a documented trade-off (no other story uses web-share); a cleaner per-story seam is possible later if wanted..claude/hooks/security-scan.shnow surfaces its block reason on stderr (it was stdout-only → the harness showed a bare "No stderr output") and allowlistsdemo.html's publicsahaj-atlas-clientembed key while still scanning it for real secrets (sk./private keys). Happy to split this to its own PR if you'd prefer.['ip-location']cache withenabled:false, so opening a share sheet never itself pings the third-party geolocation service.Closes #61
🤖 Generated with Claude Code