Repository navigation
Description
Summary
Consolidate the app's menu-style dropdowns onto a single shared Dropdown atom
ported from WeMeditateWeb (@floating-ui/react-based popover + DropdownItem),
so Atlas and WeMeditateWeb share one dropdown abstraction and look. Today Atlas
has two separate NextUI dropdown implementations — LanguageSelector (active, in
the Navbar) and SelectionDropdown (dead code) — with no shared primitive. This
replaces them with one component, styled to adapt to Atlas's NextUI + accent
theme (not WeMeditateWeb's hardcoded grays), so it respects light/dark and the
accent token.
Background
WeMeditateWeb's Dropdown
(~/Documents/Projects/WeMeditateWeb/components/atoms/Dropdown/Dropdown.tsx) is a
presentational popover built on @floating-ui/react: viewport-aware placement
(flip/shift), portaled panel (never clipped by overflow/transform/the map), and
controlled/uncontrolled open state. Its DropdownItem renders an <a>. It is
not a form control and carries no selection-state model.
Atlas's current dropdowns:
LanguageSelector(LanguageSelector.tsx) — NextUIDropdown, single-select, tracks active locale, used at Navbar.tsx:50.SelectionDropdown(SelectionDropdown.tsx) — generic NextUI single-select. Unused — referenced only by its own story + the atoms barrel.EventRegistration's NextUI<Select>(EventRegistration.tsx:233) — a form field wired into react-hook-form. Different category; out of scope (stays on NextUI).
Proposed changes
- Add the shared atom
src/components/atoms/Dropdown/(Dropdown.tsx,
Dropdown.stories.tsx,index.ts) by porting WeMeditateWeb'sDropdown+
DropdownItemmore or less verbatim (floating-ui placement, portal, flip/shift,
controlled/uncontrolled,side/align/role/ariaLabel/sizeprops). - Add
@floating-ui/reacttodependencies(pick a React-18-compatible
version; Atlas isreact@^18.3.1). - Restyle to Atlas's theme: keep the structure/layout (rounded panel, shadow,
min-w-*size variants, item padding scale, hover/transition) but swap
WeMeditateWeb's hardcoded grays (bg-white,text-gray-700,border-gray-200,
hover:bg-gray-100) for NextUI semantic tokens (e.g.bg-content1,
text-foreground,border-default-200,hover:bg-default-100) so it follows
light/dark + accent. Match the rest of the repo's styling conventions per
.claude/rules/components.md(tailwind-variantsfor the size/variant axes if
it reads cleanly; plain Tailwind otherwise). - Make
DropdownItemwork for buttons, not just links: Atlas's language items
firesetLocale(nohref), soDropdownItemshould render a<button>when
givenonClick/nohref(keep<a>forhref) to preserve a11y semantics. - Rebuild
LanguageSelectoron the sharedDropdown: trigger keeps the
currentLanguageIcon+ uppercase locale code; panel listssupportedLanguages
viauseLocale(), highlights the active locale (text-primary), calls
setLocaleon select, and keeps thearia-label={t('language_selector')}.
Navbar usage and visible behavior unchanged. - Remove the dead
SelectionDropdown: delete the folder, drop its barrel
export, remove its story. The generic single-select need (currently unexercised)
is covered by aDropdownstory/example. (If a generic selectable wrapper is
wanted later, build it on the sharedDropdownthen — YAGNI for now.) - Barrels: add
export * from './Dropdown'to
atoms/index.ts; remove theSelectionDropdown
export. - Story + test: add a Ladle story for
Dropdown/DropdownItem; add a
node-onlyrenderToStaticMarkupunit test asserting the closed-state trigger
renders (the portaled open panel is interaction — covered in Ladle/browser, per
.claude/rules/tests.md).
Out of scope
EventRegistration's react-hook-form<Select>stays on NextUI.- No new selection-state / multi-select model on the shared
Dropdownbeyond what
LanguageSelectorneeds.
Acceptance criteria
- New
src/components/atoms/Dropdown/atom (Dropdown+DropdownItem) ported from WeMeditateWeb on@floating-ui/react, portaled with flip/shift placement. -
@floating-ui/reactadded topackage.json(React-18-compatible version). - Panel styling uses NextUI semantic tokens and visibly follows light/dark + the accent token (no hardcoded grays).
-
DropdownItemrenders a<button>for action items (nohref) and an<a>for links; keyboard +ariapreserved. -
LanguageSelectorrebuilt on the sharedDropdown: switches locale, highlights the active locale, keeps itsaria-label, and renders unchanged in the Navbar. - Dead
SelectionDropdownremoved (component, story, barrel export); no remaining references (grep -r SelectionDropdown srcis empty). -
atoms/index.tsexportsDropdown;SelectionDropdownexport removed. - Ladle story added for
Dropdown;LanguageSelectorstory still renders. - Node-only unit test for
Dropdown(closed-staterenderToStaticMarkup) added. - Lint + typecheck +
test:run+ build +ladle:buildpass. - Verified in the running widget: language switch works from the Navbar, and the panel is not clipped by the map / overflow ancestors.
Files affected
src/components/atoms/Dropdown/{Dropdown.tsx,Dropdown.stories.tsx,index.ts}— newsrc/components/atoms/LanguageSelector/LanguageSelector.tsx— rewrite on sharedDropdownsrc/components/atoms/index.ts— barrel: addDropdown, removeSelectionDropdownsrc/components/atoms/SelectionDropdown/**— deletepackage.json— add@floating-ui/react
References
- Source component:
~/Documents/Projects/WeMeditateWeb/components/atoms/Dropdown/Dropdown.tsx(+LanguageDropdownusage example) .claude/rules/components.md,DESIGN_SYSTEM.md— atomic tier, barrels,tailwind-variants, NextUI-first.claude/rules/tests.md— node-onlyrenderToStaticMarkuplane
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(atoms): use plain triggers in Dropdown story so demos open