Skip to content

refactor(ui): unify dropdowns on a shared floating-ui Dropdown - #13

Merged
Ardnived merged 6 commits into
mainfrom
refactor/shared-dropdown
Jun 22, 2026
Merged

Ardnived merged 6 commits into
mainfrom
refactor/shared-dropdown

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

Unifies the app's menu-style dropdowns onto a single shared Dropdown atom
ported from WeMeditateWeb (a @floating-ui/react popover), so Atlas and
WeMeditateWeb share one dropdown abstraction.

  • New atoms/Dropdown (Dropdown + DropdownItem): portaled, viewport-aware
    placement (flip/shift), controlled/uncontrolled open — restyled to Atlas's
    NextUI + accent theme
    (semantic tokens, no hardcoded grays), so it follows
    light/dark and the accent token.
  • DropdownItem renders a real <button> for actions (onClick/no href) and
    an <a> for links, preserving keyboard + aria semantics.
  • LanguageSelector rebuilt on the shared Dropdown (switches locale, highlights
    the active locale, closes on select); the dead SelectionDropdown is removed.

Changes

  • src/components/atoms/Dropdown/** — new atom (Dropdown.tsx, story, node-only test, barrel)
  • src/components/atoms/LanguageSelector/LanguageSelector.tsx — rebuilt on the shared Dropdown; controlled isOpen to close on select; active locale via text-primary
  • src/components/atoms/SelectionDropdown/** — deleted (dead code; zero references)
  • src/components/atoms/index.ts — barrel: add Dropdown, drop SelectionDropdown
  • package.json — add @floating-ui/react@^0.27.19 (React-18-compatible)
  • CLAUDE.md, DESIGN_SYSTEM.md, STORYBOOK.md — atom tables updated

Verification

  • Lint: ✓ No errors (pnpm lint)
  • Types: ✓ Clean (pnpm typecheck)
  • Unit: ✓ 42/42 (pnpm test:run) — incl. new node-only Dropdown SSR test
  • Build: ✓ Success (pnpm build)
  • Ladle: ✓ pnpm ladle:build clean

Manual / visual verification (Ladle)

Verified the real components in Ladle (the standalone dev app is gated behind a
client fetch that 401s locally without a published Atlas key — backend auth, not
this change):

  1. LanguageSelector — opens a portaled role="menu" of real <button> items;
    selecting French switches the trigger en → fr and closes the panel
    (controlled isOpen). Active locale shows in text-primary.
  2. Dropdown — items render <a> (href) vs <button> (onClick); placement
    flip/shift; panel portals to document.body so it overflows its section
    (never clipped by an overflow ancestor — the same mechanism that keeps it
    above the Mapbox map).
  3. Theme — with the theme class at the document root (Ladle global dark toggle,
    mirroring the real app's class on <html>), the portaled panel renders in
    dark mode with the accent-colored active item, confirming it follows
    light/dark + accent.

The live "over the Mapbox map" check is left for a reviewer with a working local
VITE_ATLAS_API_KEY; portal-to-body makes map-clipping impossible by
construction.

Notes for reviewer

  • The broad Dropdown API (openOnFocus/closeOnBlur/fullWidth/side/align/
    role) is an intentional ~verbatim port for cross-repo parity — not all of it
    is exercised by Atlas today. Per the issue, no extra selection-state model was
    added; close-on-select is done by LanguageSelector via the controlled isOpen.
  • Two code-review hardenings applied to the new atom: a shared, typed
    DropdownItem.onClick (so an inline onClick={(e) => …} infers a typed event,
    not any), and a default rel="noopener noreferrer" for target="_blank"
    links (the widget embeds in untrusted host pages; caller rel still wins).
  • Story fix in its own commit: NextUI <Button> triggers couldn't drive the
    dropdown (react-aria swallows the click), so the demos never opened — swapped to
    plain triggers matching real usage.

Closes #12

🤖 Generated with Claude Code

Ardnived and others added 6 commits June 22, 2026 23:09
Adds the floating-ui peer used by the ported shared Dropdown atom
(viewport-aware placement + portal). React-18-compatible (^0.27.19).

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Port WeMeditateWeb's Dropdown/DropdownItem onto @floating-ui/react:
viewport-aware placement (flip/shift), portaled panel (never clipped by
overflow/transform/the map), controlled or uncontrolled open state.

Restyled to Atlas's theme — NextUI semantic tokens (bg-content1,
text-foreground, border-default-200, hover:bg-default-100) via
tailwind-variants, so the panel follows light/dark + the accent token.
DropdownItem renders a <button> for actions (onClick / no href) and an
<a> for links, preserving keyboard + aria semantics.

Includes a Ladle story and a node-only renderToStaticMarkup unit test.

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Swap the NextUI Dropdown for the shared floating-ui Dropdown atom. Trigger
keeps the LanguageIcon + uppercase locale code; the panel lists
supportedLanguages, highlights the active locale (text-primary), and calls
setLocale on select. Controlled open state closes the panel on select,
matching the prior behaviour. aria-label and Navbar usage unchanged.

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The dead SelectionDropdown is gone; export the shared Dropdown from the
atoms barrel instead and update the atom tables (CLAUDE.md,
DESIGN_SYSTEM.md, STORYBOOK.md) to match.

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address code-review findings on the new shared atom:
- Declare a shared, typed onClick on DropdownItem (omitting it from the
  a/button arms) so an inline onClick infers a typed event instead of any.
- Default rel="noopener noreferrer" for target="_blank" links; a
  caller-provided rel still wins. The widget embeds in untrusted host pages.

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The story's NextUI <Button> triggers couldn't drive the dropdown — NextUI's
react-aria press handling swallows the click before it reaches the wrapper's
useClick, so the demo panels never opened (ladle:build only renders the
closed state, so CI stayed green). Swap to plain styled triggers, matching
how LanguageSelector actually uses the atom; this also avoids nesting a
<button> inside the wrapper's role="button".

Verified in Ladle: every demo opens; panel follows light/dark + accent.

Refs #12

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying atlas-legacy with  Cloudflare Pages  Cloudflare Pages

Latest commit: 135f26e
Status: ✅  Deploy successful!
Preview URL: https://26d3c163.syatlas.pages.dev
Branch Preview URL: https://refactor-shared-dropdown.syatlas.pages.dev

View logs

@Ardnived
Ardnived merged commit 5f91dac into main Jun 22, 2026
3 checks passed
@Ardnived
Ardnived deleted the refactor/shared-dropdown branch June 22, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(ui): unify dropdowns on a shared floating-ui Dropdown

1 participant