Skip to content

refactor(ui): migrate components from NextUI to Radix UI - #24

Merged
Ardnived merged 10 commits into
mainfrom
refactor/nextui-to-radix
Jul 1, 2026
Merged

Ardnived merged 10 commits into
mainfrom
refactor/nextui-to-radix

Conversation

@Ardnived

@Ardnived Ardnived commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate the entire widget UI off NextUI onto Radix Primitives + Tailwind, removing the @nextui-org/react dependency. ~12 distinct NextUI components across 17 files are replaced with headless-Radix + tailwind-variants atoms, all consuming a Radix-style 12-step token scale instead of NextUI's DEFAULT/foreground-only model.
  • Re-express the design tokens as a 12-step semantic scale — neutral gray + status danger from @radix-ui/colors, brand primary/secondary from the feat(ui): white-label brand palette for the embedded widget #16 runtime palette engine — so the white-label brand-palette repaint keeps working through every new component (verified: switching tenant palette repaints chips/buttons/links/nav/swiper live, light & dark).
  • Net −~990 lines and a smaller dependency tree (the heavy @react-aria subtree NextUI dragged in collapses).

Changes

  • Token foundation — tailwind.config.js (drops the nextui() plugin; adds gray/primary/secondary/danger 1–12 + semantic aliases), globals.css (imports the Radix gray/red scales scoped to the theme-root class + seeds the built-in teal/orange defaults), src/config/theme/palette.ts (emits a 12-step --primary/--secondary ramp; applyPalette signature unchanged so the Ladle decorator still drives it), providers.tsx (drops NextUIProvider).
  • New atoms — Button, Link (react-router-aware), Switch, Alert, Spinner, Modal (Dialog), Select — each with a Ladle story. Modal/Select and the floating-ui overlays (Dropdown/EventTime) now portal into the theme root via src/lib/overlay.ts, which fixes the long-standing embedded-overlay theming gap noted in providers.tsx.
  • Rebuilt Chip/Fallbacks/ThemeSwitch; migrated all molecules/organisms/pages (Navbar, SearchBar, List, EventImages, EventShare, EventDetails, EventRegistration — Modal + native form + Radix Select bridged to react-hook-form via Controller).
  • A palette.defaults.test.ts gate asserts the static globals.css brand defaults equal buildScale(DEFAULT_SEEDS), so the ladder can't silently desync.

Verification

  • Lint ✓ · Types ✓ · Tests ✓ (105) · Build ✓ · ladle:build ✓
  • grep -rl "@nextui-org" src tailwind.config.js → no matches.

Manual / visual verification

Driven in Ladle via Playwright (light & dark, with non-default wemeditate.com / sahajayoga.org brand palettes):

  1. Atoms (Chip, Button matrix, Switch, Spinner) render correctly in both themes; the brand palette dynamically repaints primary/secondary surfaces (teal→green on palette switch).
  2. EventPanel/EventDetails organisms — brand buttons, chips, the swiper active pill, and the dark-mode month badge all read correctly.
  3. The EventRegistration modal opens, the Radix Select date dropdown works inside the Dialog (no dismissal), inputs/validation render.

Two checks the node lane can't cover, for the reviewer: the registration form submit (needs a SahajCloud backend — rendering + select interaction verified in Ladle), and overlay theming inside the actual embedded widget (verified standalone/Ladle; the wrapper-portal path only runs when embedded).

Notes for reviewer

  • Radix Primitives + Tailwind was chosen over Radix Themes (embedding constraints — no <head>/global-CSS control — plus the existing tailwind-variants + CSS-var brand engine). Shipped as one PR per request.
  • Visual verification caught & fixed an overlay portal bug (a <div> can't be a child of <html> standalone/Ladle) and the code-review findings (modal thank-you reset, dark badge step, inert scroll-shadow, spinner colour, falsy-0 guard).
  • The new atoms keep their full colour×variant matrices — deliberate design-system surface, exercised by the stories.
  • Dismissed finding: the share-link clipboard copy no-ops on insecure/old host pages — but the URL stays select-all for manual copy (the same constraint the old NextUI Snippet had).
  • A separate security-review (public-bundle threat model) came back clean: all five Radix packages are authentic scoped packages, the transitive surface shrank, overlay portaling improves host-page isolation, and no new HTML/secret sinks were introduced.

Follow-up polish (later commits)

  • Spinner now uses the canonical Radix/Tailwind-ecosystem approach — an <svg> with animate-spin + currentColor (the previous <span> ring didn't animate: transform is ignored on inline elements).
  • Link colours now apply: an explicit color uses Tailwind's ! modifier so it beats the global a { color: inherit !important } rule (default still inherits).
  • Ladle: regrouped stories to their intended tiers (EventDetails/Map/MapSearch/LanguageSelector/ThemeSwitch → Molecules; SearchBar → Organisms — story grouping only, folders unchanged); fixed the EventTime "Time Zone" example layout; and gave the story wrapper bg-background so a story's own <ThemeSwitch> visibly themes the whole preview area.

Closes #22

🤖 Generated with Claude Code

Ardnived and others added 10 commits June 30, 2026 23:11
… yet)

Lay the groundwork for the NextUI→Radix migration without touching components:

- add @radix-ui/colors + react-dialog/switch/select/label deps
- tailwind: drop the nextui() plugin + dist content glob; define a 12-step
  token layer — gray/danger from Radix Colors, primary/secondary from the
  runtime engine, plus semantic aliases (background/foreground/divider/focus)
  and the opacity-hover/disabled tokens
- globals.css: import the Radix gray/red scales (light/dark scoped to the
  theme-root class) and seed the built-in teal/orange brand defaults; repoint
  the swiper vars off --nextui-*
- palette.ts: emit a Radix-semantic 12-step ramp (--primary-1..12 + contrast)
  per role instead of NextUI's DEFAULT/foreground; applyPalette signature
  unchanged so the Ladle decorator still drives it
- providers.tsx: drop NextUIProvider (Primitives are headless; links route via
  react-router)

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…/ThemeSwitch

Introduce the headless-Radix + Tailwind replacements for NextUI primitives, all
on the 12-step token scale:

- new atoms: Button, Link (react-router-aware), Switch (@radix-ui/react-switch),
  Alert, Spinner, Modal (@radix-ui/react-dialog), Select (@radix-ui/react-select).
  Modal + Select portal into the theme root so overlays stay brand/light-dark
  themed (fixes the embedded-overlay gap noted in providers.tsx).
- rebuild Chip on tv() (no NextUI), Fallbacks on the new Spinner/Alert, and
  ThemeSwitch as a plain icon toggle (drops useSwitch).

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the remaining NextUI usage with the new Radix-based primitives and
rebind every semantic token class to the Radix 12-step scale:

- Navbar: custom top bar from primitives (drops the dead, toggle-less mobile
  menu); SearchBar: the new Switch; List: a scroll-listener shadow wrapper;
  EventImages: native <img>; ListItem/ListHeader/EventItem/EventDetails/event:
  the new Link; EventShare: Modal + a click-to-copy field.
- EventRegistration: Modal + native form fields + the Radix Select bridged to
  react-hook-form via Controller (string↔coerced-Date), Alert for notices.
- token rebind across components + stories: default-N/content1 → gray steps,
  brand tints 10/50/100/900 → 2/3/4/11, text-tiny/small → text-xs/sm, NextUI
  border-width utilities → Tailwind equivalents.

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The widget no longer imports NextUI anywhere; drop the dependency. Closes the
migration from NextUI to Radix Primitives + Tailwind.

Closes #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Dialog/Select portaled into getThemeRoot(), which is the document element
standalone/in Ladle — and a <div> can't be a valid child of <html>, triggering
validateDOMNesting + aria-hidden warnings (caught in Ladle). Add overlayContainer():
the theme root when it's the widget wrapper (keeps overlays brand/theme-scoped),
else <body> (still inherits the html-level theme class + vars).

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Button, Link, Switch, Alert, Spinner, Modal, and Select each get a story so the
component library previews them (light/dark + brand palette) per DESIGN_SYSTEM.

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…als, gates

- reuse the Icons-barrel DownArrowIcon (Select) and AnchorIcon (Link) instead of
  inline one-off SVGs
- route the floating-ui overlays (Dropdown, EventTime) through overlayContainer()
  too, so every overlay stays brand/light-dark scoped (overlayContainer is now
  SSR-safe — returns undefined with no DOM)
- List scroll-shadow: coalesce scroll/resize to one rAF and bail out of no-op
  re-renders; passive resize listener
- gate the static globals.css brand defaults against buildScale(DEFAULT_SEEDS)
  (new palette.defaults.test.ts) so the ladder can't silently desync

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- EventRegistration: reset the thank-you state when the footer Cancel/Okay
  buttons close the modal (they bypass Radix's onOpenChange), so reopening
  shows the form, not the previous confirmation [HIGH]
- EventDetails: the dark month badge used dark:bg-primary-11 (a light text
  step) as a surface → near-invisible; use a dark component-bg step [MED]
- List: drop the inert scroll-shadow machinery — the Panel is the scroll
  container, so the <ul> never scrolled and no fade ever showed; back to a
  plain styled <ul> [MED]
- Modal: drop the dead data-[state=open]:animate-in (plugin not installed)
- Button: loading spinner inherits the button's text colour (currentColor)
  instead of always grey
- SearchBar: guard the eventCount count against a falsy-0 leak
- EventImages: drop the redundant h-full on the carousel img

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Spinner: the spinning element was a <span> — an inline box, where CSS
  transform (and width/height) is ignored, so animate-spin did nothing. Switch
  to the canonical Radix/Tailwind-ecosystem approach: an <svg> with animate-spin
  and currentColor (Radix Primitives ships no spinner).
- Link: an explicit `color` now uses Tailwind's `!` modifier so it beats the
  global `a { color: inherit !important }` rule; `default` still inherits.

Refs #22

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… preview

- Regroup Ladle stories: EventDetails/Map/MapSearch and LanguageSelector/
  ThemeSwitch → Molecules; SearchBar → Organisms (story `title` only; the
  component folders are unchanged).
- EventTime story: wrap each example in the "Time Zone" section in a block so
  the inline-rendering EventTime examples stack on their own lines.
- Ladle decorator: give the story wrapper `bg-background` so the whole preview
  area follows the app theme — so a story's own <ThemeSwitch> visibly flips the
  background too, not just Ladle's toolbar (Ladle's own chrome stays on its
  theme, as expected).

Refs #22

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

cloudflare-workers-and-pages Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Deploying atlas-legacy with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e38493
Status: ✅  Deploy successful!
Preview URL: https://9f3b912c.syatlas.pages.dev
Branch Preview URL: https://refactor-nextui-to-radix.syatlas.pages.dev

View logs

@Ardnived
Ardnived merged commit 61d53d7 into main Jul 1, 2026
3 checks passed
@Ardnived
Ardnived deleted the refactor/nextui-to-radix branch November 13, 2026 03:49
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): migrate components from NextUI to Radix UI

1 participant