mojotech / torch

A rapid admin generator for Elixir & Phoenix
Other
1.08k stars 79 forks source link

Enable Phoenix LiveView support option in Torch #149

Open cpjolicoeur opened 4 years ago

JoeWoodward commented 3 years ago

It's really not easy to use Torch with liveview. The classes are an issue. The PageView includes body_classes/2 which fails with a live page. I've been bypassing these classes by checking if the conn include the action name. However, now I have an issue that the css is tied to the body

e.g. the .torch-new, .torch-index classes etc are all defined as body.torch-new, body.torch-index etc. This means I can't use those classes easily. I was planning on just wrapping my live templates in the correct classes but that's not possible.

form#torch-form is also incompatible as live forms don't actually use an html form element. I bypassed this by importing the styles into my app without attaching them to the form e.g. instead of form#torch-form I imported as #torch-form.

Would be really good to improve this when live view support is implemented.

cpjolicoeur commented 3 years ago

@JoeWoodward Thanks for the info/notes here. We haven't gotten too far down the line with making a LiveView "version" of Torch yet, but we'll keep these notes in mind as we progress on it.

nickurban commented 3 years ago

Looks like @andreaseriksson has started on this: https://github.com/fullstack-phoenix/lit

andreaseriksson commented 3 years ago

@cpjolicoeur do you have any idea how the install generator should work?

mix torch.install

I mean, mean, should it detect if liveview is installed and to a leex-version of the layout template or should that be an option passed in?

cpjolicoeur commented 3 years ago

@andreaseriksson I'd prefer to see a --live flag to force live view regardless. We'd want/need a manual flag at a minimum.

mix torch.install --live

It would be nice though to auto-detect, if possible, if the phoenix app was/is using liveview and then default to liveview templates in that case, (or perhaps prompt the user).

andreaseriksson commented 3 years ago

@cpjolicoeur got it.