Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Component Code to Registry Folder #26

Open
DeadmanAbir opened this issue Aug 6, 2024 · 7 comments
Open

Migrate Component Code to Registry Folder #26

DeadmanAbir opened this issue Aug 6, 2024 · 7 comments

Comments

@DeadmanAbir
Copy link
Owner

Description:
Currently, the component codes in AgentGenesis are hardcoded in MDX files. To improve the maintainability and organization of the codebase, we propose migrating the component code to a dedicated registry folder. This approach will allow us to fetch the component code from the registry folder when it is needed in MDX files. The structure and implementation can be inspired by the registry folder setup in the shadcn-ui repo.

Objective:

  • Enhance the maintainability and scalability of the codebase.
  • Improve the organization of component code.
  • Facilitate easier updates and management of reusable components.

Requirements:

  1. Refactor Component Code:

    • Move existing hardcoded component code from MDX files to the appropriate files within the registry folder.
    • Ensure that each component is self-contained and follows best practices.
  2. Update MDX Files:

    • Modify MDX files to fetch and utilize components from the registry folder.
    • Ensure seamless integration and functionality of components when fetched from the registry.
  3. Documentation:

    • Document the new folder structure and guidelines for adding or updating components.
    • Provide examples and references for developers to follow.

Reference:

  • The registry folder structure and implementation can be inspired by the shadcn-ui repo.

Impact:

  • Improved code maintainability and organization.
  • Easier management and updating of reusable components.
  • Enhanced developer experience and collaboration.

Approval:

  • Approval from relevant stakeholders is required before proceeding with the migration.

Additional Notes:

  • Ensure to communicate any potential impacts or downtime during the migration process to all stakeholders.

By migrating the component code to a dedicated registry folder, we aim to streamline the development process and enhance the overall quality of the AgentGenesis.

@DeadmanAbir DeadmanAbir added the enhancement New feature or request label Aug 6, 2024
@J-B-Mugundh
Copy link

J-B-Mugundh commented Oct 2, 2024

Could you please elaborate on this?

Should we just move the Component from src/components/DemoComponents/...tsx to the registry folder src/registry/...tsx folder and Update the imports?

@faisal004
Copy link
Collaborator

hi @J-B-Mugundh current problem is that we are hardcoding the component code in component.mdx file. But if try to look at
(https://github.com/magicuidesign/magicui/blob/main/content/docs/components/animated-beam.mdx?plain=1) they have made a component preview thing in which they import components from registry that what we want to achieve . So that we can use that same component in other parts of app also . For reference use https://magicui.design github , shadcn has changed there folder structure .

@DeadmanAbir DeadmanAbir added gssoc-ext hacktoberfest-accepted level 1 Typo fixings or low level changes level 3 30 points and removed enhancement New feature or request level 1 Typo fixings or low level changes labels Oct 3, 2024
@J-B-Mugundh
Copy link

hi @J-B-Mugundh current problem is that we are hardcoding the component code in component.mdx file. But if try to look at (https://github.com/magicuidesign/magicui/blob/main/content/docs/components/animated-beam.mdx?plain=1) they have made a component preview thing in which they import components from registry that what we want to achieve . So that we can use that same component in other parts of app also . For reference use https://magicui.design github , shadcn has changed there folder structure .

@faisal004 @DeadmanAbir

What u basically mean is to put the components (example in screenshot) into registry folder and import them as code?

image

While I tried it by creating a .tsx file in registry folder, i couldn't return the code inside the file. It was only possible to return a response value. Please find the following snips for better understanding.

image
image
image

However, this didn't help me in displaying the code. All I was able to get was the return value from this.

So, I tried returning the component's code as a string and it ended up like this.

image

Could you please help me figure out where I'm going wrong? There might be some issue with my approach to solve this.

This is actually a great project and I would really love to take this task up once I have clarity of what I had to do. I would also love to have a gmeet or a call to discuss on this. Let's get on a conclusion and discuss further.

My email: [email protected]
My linkedin: https://www.linkedin.com/in/mugundhjb/

@dev628140
Copy link

Description: Currently, the component codes in AgentGenesis are hardcoded in MDX files. To improve the maintainability and organization of the codebase, we propose migrating the component code to a dedicated registry folder. This approach will allow us to fetch the component code from the registry folder when it is needed in MDX files. The structure and implementation can be inspired by the registry folder setup in the shadcn-ui repo.

Objective:

  • Enhance the maintainability and scalability of the codebase.
  • Improve the organization of component code.
  • Facilitate easier updates and management of reusable components.

Requirements:

  1. Refactor Component Code:

    • Move existing hardcoded component code from MDX files to the appropriate files within the registry folder.
    • Ensure that each component is self-contained and follows best practices.
  2. Update MDX Files:

    • Modify MDX files to fetch and utilize components from the registry folder.
    • Ensure seamless integration and functionality of components when fetched from the registry.
  3. Documentation:

    • Document the new folder structure and guidelines for adding or updating components.
    • Provide examples and references for developers to follow.

Reference:

  • The registry folder structure and implementation can be inspired by the shadcn-ui repo.

Impact:

  • Improved code maintainability and organization.
  • Easier management and updating of reusable components.
  • Enhanced developer experience and collaboration.

Approval:

  • Approval from relevant stakeholders is required before proceeding with the migration.

Additional Notes:

  • Ensure to communicate any potential impacts or downtime during the migration process to all stakeholders.

By migrating the component code to a dedicated registry folder, we aim to streamline the development process and enhance the overall quality of the AgentGenesis.

@DeadmanAbir Hey there, as you asked me to provide approach architecture that I will follow to fix the concerned issue. So I will try to specify you the details in structured manner:

At the very beginning I shall Clone the repository and understand the current structure and dependencies.

Identify Components:
List all components to be moved to the Registry folder.

Create Registry Folder:
Create a new Registry folder.

I Shall Move Components:
Move components to the Registry folder.
Update import paths in all files referencing the moved components.

Most Importantly After Every Major Changes I Shall Test the Application:
Run the app locally to ensure everything works.
Fix any issues that arise.

I Will Commit and Push Changes:
Commit changes to a new branch.
Push the branch to GitHub.

I Shall Create Pull Request:
Create a pull request with a detailed description of the changes.

Detailed Steps:-

I Will Clone the Repository:
git clone https://github.com/DeadmanAbir/AgentGenesis.git
cd AgentGenesis

Identify All Components:
Search for all component files and list them.

Then I Shall Create Registry Folder:
mkdir -p src/Registry

Move Components:
Move each component file to the Registry folder.
Update import paths.

Test the Application:
npm install
npm run dev

Commit and Push Changes:
git checkout -b migrate-components-to-registry
git add .
git commit -m "Migrate components to Registry folder"
git push origin migrate-components-to-registry

Create Pull Request:
Go to the GitHub repository.
Create a pull request with a detailed description.

Example Of Changes To Be Made:-

Before Migration:
import { Button } from '@/components/ui/button';

After Migration:
import { Button } from '@/registry/ui/button';

Testing and Validation
Run the application locally to ensure all components work correctly.
Fix any issues that arise.
Commit and push the changes to a new branch...

Now please verify my approach towards the issue and please assign it to me as I am very eagerly waiting to contribute into this particular project.

@dev628140
Copy link

Screenshot 2024-10-03 205842
@DeadmanAbir As you can see in the attached screenshot that I have already Migrated Component Code to Registry Folder and it's running smoothly on localhost:3000. I have also made the loading time of every page to almost zero second, every page loads instantly...Now please assign this to me so that I can make these contributions to the project.

@faisal004
Copy link
Collaborator

hi @dev628140 actually not we dont want ui components to be moved in different folder that fine . What we are trying to acheive is something like this - #26 (comment)

@faisal004
Copy link
Collaborator

hi @J-B-Mugundh if go through magic ui's github you will see they have suppose
this is a component in which they pass the name of component and inside this component they fetch the code of this component from registry.This whole componet is a tab component. https://github.com/magicuidesign/magicui/blob/main/components/component-preview.tsx . Just try to acheive this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants