Repository navigation
refactor(ui): unify dropdowns on a shared floating-ui Dropdown - #13
Merged
Merged
Conversation
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]>
Deploying atlas-legacy with
|
| Latest commit: |
135f26e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://26d3c163.syatlas.pages.dev |
| Branch Preview URL: | https://refactor-shared-dropdown.syatlas.pages.dev |
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
Unifies the app's menu-style dropdowns onto a single shared
Dropdownatomported from WeMeditateWeb (a
@floating-ui/reactpopover), so Atlas andWeMeditateWeb share one dropdown abstraction.
atoms/Dropdown(Dropdown+DropdownItem): portaled, viewport-awareplacement (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.
DropdownItemrenders a real<button>for actions (onClick/nohref) andan
<a>for links, preserving keyboard + aria semantics.LanguageSelectorrebuilt on the sharedDropdown(switches locale, highlightsthe active locale, closes on select); the dead
SelectionDropdownis removed.Changes
src/components/atoms/Dropdown/**— new atom (Dropdown.tsx, story, node-only test, barrel)src/components/atoms/LanguageSelector/LanguageSelector.tsx— rebuilt on the sharedDropdown; controlledisOpento close on select; active locale viatext-primarysrc/components/atoms/SelectionDropdown/**— deleted (dead code; zero references)src/components/atoms/index.ts— barrel: addDropdown, dropSelectionDropdownpackage.json— add@floating-ui/react@^0.27.19(React-18-compatible)CLAUDE.md,DESIGN_SYSTEM.md,STORYBOOK.md— atom tables updatedVerification
pnpm lint)pnpm typecheck)pnpm test:run) — incl. new node-onlyDropdownSSR testpnpm build)pnpm ladle:buildcleanManual / 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):
LanguageSelector— opens a portaledrole="menu"of real<button>items;selecting French switches the trigger
en → frand closes the panel(controlled
isOpen). Active locale shows intext-primary.Dropdown— items render<a>(href) vs<button>(onClick); placementflip/shift; panel portals to
document.bodyso it overflows its section(never clipped by an overflow ancestor — the same mechanism that keeps it
above the Mapbox map).
mirroring the real app's class on
<html>), the portaled panel renders indark 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 byconstruction.
Notes for reviewer
DropdownAPI (openOnFocus/closeOnBlur/fullWidth/side/align/role) is an intentional ~verbatim port for cross-repo parity — not all of itis exercised by Atlas today. Per the issue, no extra selection-state model was
added; close-on-select is done by
LanguageSelectorvia the controlledisOpen.DropdownItem.onClick(so an inlineonClick={(e) => …}infers a typed event,not
any), and a defaultrel="noopener noreferrer"fortarget="_blank"links (the widget embeds in untrusted host pages; caller
relstill wins).<Button>triggers couldn't drive thedropdown (react-aria swallows the click), so the demos never opened — swapped to
plain triggers matching real usage.
Closes #12
🤖 Generated with Claude Code