-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Description
I would like to propose the addition of generators support to the PhlexUI project. This feature, inspired by Shadcn, aims to enhance the gem's customizability by allowing users to copy components into their own applications. Each component can be generated individually or used directly from the gem, providing flexibility and ease of use.
Features
Component Generators:
- Allow users to generate individual components along with their dependencies.
- Ensure that if a component has a dependency (e.g.,
Phlex.Button), the component file referencesPhlex.Buttonrather than copying it over.
Direct Usage Option:
- Provide an option to use the components directly from the gem without generating them, catering to different development preferences.
Hierarchy and Override Support:
- Ensure that any generated components are loaded in the correct hierarchy, allowing components in the
app/*directory to override the gem's components. - For example,
PhlexUI::Buttonshould be overridden byapp/components/phlex_ui/button.rb.
Example Workflow
-
Generate a Component:
rails generate phlex_ui:component Button
This command will copy the
Buttoncomponent to the user's application, ensuring proper references. -
Generate All Components:
rails generate phlex_ui:install
This command will copy over all components and create an initializer to map the
UInamespace. -
Use Directly from the Gem:
Users can choose to use the components directly from the gem without generating them:PhlexUI::Button.new
Benefits
- Enhanced Customizability: Users can easily customize components by copying them into their own applications.
- Flexibility: Allows users to choose between generating components or using them directly from the gem.
- Consistency: Ensures a consistent approach to component dependencies and overrides, reducing potential conflicts.