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

feat: extract component from AFX #330

Closed
wants to merge 1 commit into from

Conversation

PRGfx
Copy link
Contributor

@PRGfx PRGfx commented Sep 22, 2024

When a range in AFX in selected, you can find the "Extract component" option in the refactoring menu.
This will open a dialog prompting you for a name for the new component and showing a preview of the generated output: the new component and the code generated at the old location.
You can currently choose whether to include the children in the component or not (only works when a "complete" tag is selected, i.e. no surrounding text or sibling elements). This will make the difference of generating <New /> vs <New>existing child content</New> and <Original>existing child content</Original> vs. <Original>{props.content}</Original>.

It tries to expose the "dynamic values" (not explicit variables, but everything in an eel expression) so it should still work in the end, but for now my confidence is limited ^^

The extracted prototype is created in the same file and I don't intend to make this configurable. That's what #323 is intended for.

This currently is super rough, but I decided to put it out there for feedback or interested testers.
Working with the injected language elements felt super awkward, but possibly I just haven't understood the intended way yet.

ToDo:

  • add tests
  • focus name input for faster editing
  • add warning, if selected name is already known (could be in a different fusion tree, so I wouldn't add an error)
  • make selection of AFX content more stable - currently it's super wonky when selecting anything outside of AST element bounds
  • (make exposed props selectable from list)
  • (make exposed props renamable)
  • (toggle all advanced options in the dialog for easy every-day usage? second refactoring action for quick/advanced extract?)
  • (try to derive better names for exposed props?)
  • (try to derive a sensible default type?)
  • (move carets to new positions)
  • (make base-prototype configurable? We expect Neos.Fusion:Component behavior, but could be some subtype.)

Includes the EelElementFactory from #324 but deliberately not the whole branch.
Resolves #46

@PRGfx
Copy link
Contributor Author

PRGfx commented Nov 3, 2024

I started adding some tests, but I had more trouble with the prop refactoring than I'm willing to debug right now, so I close this in favor of a more minimal approach for the time being.

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.

Feature request: Extract AFX into separate component
1 participant