Make the library UI framework agnostic by removing MUI dependency#9
Conversation
Co-authored-by: harrybin <15869006+harrybin@users.noreply.github.com>
Co-authored-by: harrybin <15869006+harrybin@users.noreply.github.com>
Co-authored-by: harrybin <15869006+harrybin@users.noreply.github.com>
Co-authored-by: harrybin <15869006+harrybin@users.noreply.github.com>
|
@copilot why are you using "React.ComponentType" instead of interfaces? What is the benefit? |
Using
If you prefer separate interfaces for better reusability or if you'd like to export these types for consumers to implement their own wrapper components, I can refactor to use named interfaces instead. Would that be preferable? |
|
@copilot
|
@copilot do these changes |
Co-authored-by: harrybin <15869006+harrybin@users.noreply.github.com>
Added all requested items in commit b69422e:
The codemod can be run with: npx jscodeshift -t node_modules/@harrybin/react-common/codemod.js --parser=tsx src/All files are included in the published npm package.
Completed in commit b69422e. All documentation and migration tools are now available:
|
Overview
This PR makes the
@harrybin/react-commonlibrary completely UI framework agnostic by removing the hard dependency on Material-UI (MUI). The library can now be used with any React UI framework (Material-UI, Chakra UI, Ant Design, shadcn/ui, etc.) or with no framework at all.Motivation
Previously, the library required users to install MUI, Emotion, and tss-react as peer dependencies, even if they were using a different UI framework. This created unnecessary bundle bloat and prevented adoption in projects using other UI libraries.
Changes
1. Component Refactoring
All UI components now accept framework components as props, with sensible native HTML defaults:
ConfirmationDialog
DialogComponent,DialogTitleComponent,DialogContentComponent,DialogActionsComponent,ButtonComponent,TextComponentNameValueText
ContainerComponent,ItemComponent,TextComponentErrorReportDialog
BoxComponent,GridContainerComponent,GridItemComponent,TextFieldComponent,TextComponent,LinkComponentMarkdown
TextComponent,LinkComponent2. Dependency Changes
Removed from peerDependencies:
@mui/material(>=5.15.14)@emotion/css(>=11.11.2)@emotion/styled(>=11.11.0)Removed entirely:
tss-react(^4.9.6)Moved to devDependencies (Storybook only):
@mui/material,@emotion/css,@emotion/styledRemaining peerDependencies:
react(>=18.2.0)react-dom(>=18.2.0)3. Usage Examples
Without any framework:
With Material-UI (backward compatible):
With shadcn/ui:
With Chakra UI:
Benefits
Testing
dist/)Migration Tools & Documentation
Automatic Migration Codemod
For existing MUI users, we provide a codemod to automatically transform your code:
The codemod automatically:
ConfirmationDialog,NameValueText,ErrorReportDialog, andMarkdown@mui/materialimport statementsComprehensive Documentation
MIGRATION_GUIDE.md
USAGE_EXAMPLES.md
Updated README.md
Migration Guide (Quick Reference)
For existing users with MUI, update component usage to pass MUI components as props:
Or simply accept the default implementations which provide similar functionality, or use the automated codemod for instant migration.
Documentation
Closes #8
Original prompt
Fixes #8
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.