Add liveview folder locations to Projectionist#50
Add liveview folder locations to Projectionist#50mhanberg merged 11 commits intoelixir-tools:mainfrom
Conversation
mhanberg
left a comment
There was a problem hiding this comment.
I have a general question, I think the general naming convention for live views is something like lib/my_app_web/live/foo_live/show.ex and MyAppWeb.FooLive.Show.
If that is true, are you able to make the projection match that pattern? That was the problem I had myself when i tried to add this in my own dotfiles.
Co-authored-by: Mitchell Hanberg <mitch@mitchellhanberg.com>
Co-authored-by: Mitchell Hanberg <mitch@mitchellhanberg.com>
5ec8c8e to
1f9ae72
Compare
|
Rebased and added the HTML/Component projections shown by German Velasco here: https://twitter.com/germsvel/status/1610283195018141696 |
Most projects I've seen (LiveBeats as an example) tend to put their LiveViews in the root https://github.com/fly-apps/live_beats/tree/master/lib/live_beats_web/live It would be nice to support the folder containing the views components as seen in that repo, but I don't see a clear way to do that in projectionist at the moment. |
Interesting, the Probably alright tho, if people seem to disagree i assume they'll open an issue. |
| "end", | ||
| }, | ||
| }, | ||
| ["lib/**/components/*_component.ex"] = { |
There was a problem hiding this comment.
this i would for sure just name lib/**/components/*.ex.
I don't think anyone would be naming their components in a way that would be <TableComponent.render {@foo}>...</TableComponent.render>
(well, at least I wouldn't ever name a component like that).
There was a problem hiding this comment.
Hm, okay so you'd also change the module definition to
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize} do",
" use Phoenix.Component",
"end",
or would you scope it differently?
Looking through other open source repos
https://github.com/BeaconCMS/beacon/blob/main/lib/beacon_web/live/admin/media_library_live/upload_form_component.ex
Dockyard seems to use _component on BeaconCMS
https://github.com/adoptoposs/adoptoposs/blob/develop/lib/adoptoposs_web/live/project_component.ex
This one seems to too!
https://github.com/qhwa/bonfire/blob/master/lib/bonfire_web/live/reading_state_componnet.ex
Same here
There was a problem hiding this comment.
We use Surface at my job, which actually has module components, and we don't name them with a "component" suffix 🤷.
But, I'll note that excluding the last link (which was last modified two years ago), those are all examples of LiveComponents, not function components.
I can add a PR that allows to easily override these defaults if that is what you'd like to see.
There was a problem hiding this comment.
That is true, I suppose what might make sense would be another set of projections that detect _component.ex in the live directory and make live component tests?
Though at that point the tests are the same format as normal LiveViews I believe so hm, no action needed!
There was a problem hiding this comment.
Yeah I did realize that there wasn't one for live components.
nor the new _json convention.
a PR for either/both of those would great!
|
@zolrath thanks for getting this updated! I'm going to pull it down and make sure it all works (on my machine), but other than my one comment it looks 💯 . |
Oh I didn't see this comment before I left mine about the Component projection. I think I still disagree, even with German's testimony. |
|
I pulled it down and fixed several bugs, but it's good to go now. Thank you so much! |
Hello!
This adds the
livefolder to projectionist, though with Phoenix 1.7 lurking around the corner some other additions are likely useful with the modified directory structure.