-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Macro to generate component functions #50
Conversation
This is very cool, thank you for the PR, let me check it out and see how it works, but will likely merge it. Feel free to add some documentation to the README. Maybe under the usage section. |
Amazing! One thing I just realised, nested components of the same name will overwrite each other so that will need to be more carefully generated. I'll take a look anyway, and also add to the README 👍 |
One thing I noticed is that it's not fully working, not sure why though. For example the animations in the chat are not visible anymore and also the amount field gets reset on click in the hybrid view. macro.mp4 |
#17 will be closed by this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you for working on this, seems to be working!
Available in |
Changes
This PR creates an experimental macro which checks the
assets/svelte
folder for any Svelte components, and injects local functiondef
s for those components into the calling module.My thinking is that this would provide a cleaner more ergonomic interface into Svelte from Liveview, with a better DX. In the future
attr
macros could even be generated based on Svelte component exports.Usage
Examples
See the live_chat file at example_project/lib/example_web/live/live_chat.ex in the example project for a working example!
Caveats
The
assets/svelte
directory is parsed once per module which callsuse LiveSvelte.Components
. A future improvement would be to only check here once per compile, and then reference the previously generated functions.