Skip to content

Commit f7126a9

Browse files
authored
refactor(accordion) - remove accordion dependency (#782)
* remove label && slot * remove react-label dependency * remove dependency * format * adapt plan * chore(button) - remove react-slog * updates * update plan * edit plan * refactor(accordion) - remove radix accordion dependency * edit plan * format * fix test * fix accordion * add improvements * fix animation * fix * fix
1 parent 02725b7 commit f7126a9

7 files changed

Lines changed: 190 additions & 130 deletions

File tree

package-lock.json

Lines changed: 0 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
},
8888
"dependencies": {
8989
"@hookform/resolvers": "^4.1.3",
90-
"@radix-ui/react-accordion": "^1.2.12",
9190
"@radix-ui/react-checkbox": "^1.3.3",
9291
"@radix-ui/react-collapsible": "^1.1.12",
9392
"@radix-ui/react-dialog": "^1.1.15",

plans/headless-library.md

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,19 @@ Decouple all Radix UI (and other visual) dependencies from the library core, mak
88

99
### Radix packages in use (11 total)
1010

11-
- `@radix-ui/react-accordion``ui/accordion.tsx`
1211
- `@radix-ui/react-checkbox``ui/checkbox.tsx`
1312
- `@radix-ui/react-collapsible``ui/collapsible.tsx`
1413
- `@radix-ui/react-dialog``ui/dialog.tsx`
15-
- `@radix-ui/react-label``ui/label.tsx`, `ui/form.tsx`
1614
- `@radix-ui/react-popover``ui/popover.tsx`
1715
- `@radix-ui/react-radio-group``ui/radio-group.tsx`
1816
- `@radix-ui/react-scroll-area``ui/scroll-area.tsx`
1917
- `@radix-ui/react-select``ui/select.tsx`
20-
- `@radix-ui/react-slot``ui/form.tsx` (`FormControl`)
2118
- `@radix-ui/react-tabs``ui/tabs.tsx`
2219

23-
### Visual components embedded in flows/shared (must be made overridable or moved)
24-
25-
- `EstimationResults` — uses `Accordion`
26-
- `SummaryResults` — uses `Accordion`
27-
2820
---
2921

3022
## Phases
3123

32-
### Phase 1 — Simplify `src/components/ui/form.tsx`
33-
34-
Remove the two Radix dependencies while keeping the helper pattern intact.
35-
36-
**Changes:**
37-
38-
- `FormLabel`: replace `@radix-ui/react-label` + `Label` with a plain `<label>` element.
39-
- `FormControl`: replace `@radix-ui/react-slot` `Slot` with a lightweight wrapper that clones the child and merges `id` + `aria-*` props using `React.cloneElement`, keeping accessibility intact.
40-
- Remove imports: `@radix-ui/react-label`, `@radix-ui/react-slot`, `Label`.
41-
42-
`FormField`, `FormItem`, `FormDescription`, `FormMessage` require no changes (no Radix).
43-
44-
---
45-
4624
### Phase 2 — Move all Default components to `examples/`
4725

4826
All files in `src/components/form/fields/default/` are reference implementations that depend on Radix-backed `ui/` components. Move them to `examples/fields/`.
@@ -139,45 +117,6 @@ These pure-HTML components have no Radix dependency but are still visual. Move t
139117

140118
---
141119

142-
### Phase 4 — Make flows with embedded visual components headless
143-
144-
For each flow component that directly renders visual elements (Card, Button, Alert, Accordion), replace the hardcoded component with either:
145-
146-
- **Component override slot** via a `components` prop (preferred for public-facing output components).
147-
- **Native HTML equivalent** where the component is simple enough (e.g., `Button``<button>`, `Card``<div>`).
148-
149-
#### 4a. `EstimationResults`
150-
151-
Currently accepts a partial `components` prop. Extend it to cover all internal visual dependencies:
152-
153-
```ts
154-
type EstimationResultsComponents = {
155-
Accordion?: React.ComponentType<...>;
156-
Tooltip?: React.ComponentType<{ content: React.ReactNode; children: React.ReactNode }>;
157-
ActionsDropdown?: React.ComponentType<ActionsDropdownProps>;
158-
HiringSection?: React.ComponentType<...>; // already exists
159-
OnboardingTimeline?: React.ComponentType<...>; // already exists
160-
Header?: React.ComponentType<...>; // already exists
161-
Footer?: React.ComponentType; // already exists
162-
};
163-
```
164-
165-
The default for each slot is a plain HTML fallback (no Radix).
166-
167-
#### 4b. `SummaryResults`
168-
169-
Same approach — accept `Card` and `Accordion` overrides. Provide plain HTML defaults.
170-
171-
#### 4d. `Termination/PaidTimeOff`
172-
173-
Replace `Button` import with a `components?.button` override or a plain `<button>`.
174-
175-
#### 4f. `ActionsDropdown`
176-
177-
Replace `Button` from `ui/button` with a native `<button>` element directly. `ActionsDropdown` is already a plain dropdown with no Radix — only the `Button` wrapper is Radix-backed.
178-
179-
---
180-
181120
### Phase 5 — Remove all `@radix-ui/*` from `package.json`
182121

183122
After phases 1–4, verify no file in `src/` imports from `@radix-ui/*`. Then remove all 11 Radix entries from `package.json` dependencies.
@@ -246,8 +185,4 @@ examples/
246185

247186
## Open questions before starting
248187

249-
1. **`form.tsx` `FormControl` replacement**: Use `React.cloneElement` or remove entirely? Since Default components move to examples and those are the only `FormControl` consumers, we could remove `FormControl` from the core export and let examples bring their own version.
250-
251-
2. **`EstimationResults` plain HTML defaults**: When no `Card`/`Accordion` override is given, should the component render plain `<div>` fallbacks (keeping it functional but unstyled), or should it throw (forcing the consumer to provide all slots)? Recommendation: plain `<div>` fallbacks so the component works out-of-the-box without any Radix.
252-
253-
3. **Naming the examples folder**: `examples/` vs `packages/ui/` vs keeping it in the repo as a separate package. TBD with team.
188+
1. **Naming the examples folder**: `examples/` vs `packages/ui/` vs keeping it in the repo as a separate package. TBD with team.

0 commit comments

Comments
 (0)