From 84008807bd811fe9cb2fe1e7467d169eaf0ed439 Mon Sep 17 00:00:00 2001 From: Kaycee276 Date: Sun, 26 Apr 2026 13:53:43 +0100 Subject: [PATCH] feat: add creator profile section anchor links (#159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enable enableHashRouting on ProfileTabPillGroup in LandingPage - Initialise activeProfileTab from window.location.hash on first render so direct URL hash navigation (e.g. /#creations) works immediately - Consolidate two duplicate useEffect calls in ProfileTabPillGroup into one effect that both syncs from the initial hash on mount and listens for subsequent hashchange events, eliminating a mount-time race - Add id/aria-controls to each ProfileTabPill for tab ↔ panel ARIA wiring - Wrap tab-panel content in a div with id, role=tabpanel, aria-labelledby, and tabIndex so the semantic relationship is complete - Add ProfileTabPillGroup.test.tsx (8 tests) covering hash routing, ARIA attributes, initial hash read, hashchange listener, and edge cases - Add docs/CreatorProfileAnchorLinks.md with implementation notes and manual verification steps --- docs/CreatorProfileAnchorLinks.md | 54 ++++++ src/components/common/ProfileTabPill.tsx | 29 +-- .../__tests__/ProfileTabPillGroup.test.tsx | 173 ++++++++++++++++++ src/pages/LandingPage.tsx | 68 +++++-- 4 files changed, 294 insertions(+), 30 deletions(-) create mode 100644 docs/CreatorProfileAnchorLinks.md create mode 100644 src/components/common/__tests__/ProfileTabPillGroup.test.tsx diff --git a/docs/CreatorProfileAnchorLinks.md b/docs/CreatorProfileAnchorLinks.md new file mode 100644 index 0000000..bea4a57 --- /dev/null +++ b/docs/CreatorProfileAnchorLinks.md @@ -0,0 +1,54 @@ +# Creator Profile Anchor Links + +> Issue #159 — Adds URL hash navigation for main creator profile sections. + +## Overview + +Each creator profile tab (`overview`, `creations`, `collectors`, `activity`) is now addressable via a URL hash fragment. This enables: + +- **Direct deep-linking** — share or bookmark a URL like `/#creations` and land on the correct tab. +- **Browser back/forward navigation** — pressing back after switching tabs returns to the previous section. +- **Preserved layout** — the visual appearance and existing component structure are unchanged. + +## How it works + +### `ProfileTabPillGroup` (`src/components/common/ProfileTabPill.tsx`) + +The `enableHashRouting` prop has been activated and the implementation improved: + +| Behaviour | Detail | +| ---------------------- | ------------------------------------------------------------------------------------------------ | +| **On mount** | Reads `window.location.hash` and calls `onTabChange` if the hash matches a tab value. | +| **Tab click** | Calls `onTabChange` _and_ sets `window.location.hash` to the tab value. | +| **`hashchange` event** | Listens for browser-level hash changes (e.g. back/forward) and syncs the active tab. | +| **ARIA attributes** | Each ` @@ -507,6 +528,7 @@ function LandingPage() { ]} activeTab={activeProfileTab} onTabChange={setActiveProfileTab} + enableHashRouting className="mb-4" /> @@ -514,10 +536,23 @@ function LandingPage() { repeated creator facts into one responsive grid that stays tidy on mobile and desktop. -
- - - +
+
+ + + +
@@ -534,9 +569,7 @@ function LandingPage() { label="Creator Share Supply" value={`${formatCompactNumber(250)} shares available`} /> - {isNetworkMismatch && ( - - )} + {isNetworkMismatch && }
- +