tmjoen
A small QoL improvement for live components?
I was noticing when moving my app from Surface to LiveView 0.17 that it is a little harder to quickly scan the element tree when glancing at the source code when using <.live_component> mixed in with function components.
For instance:
<.fieldset heading="Project">
<.live_component module={Input.RichText} form={@form} field={:title} id={"#{field.id}-title"} />
<Input.slug form={@form} field={:slug} from={:title} />
<.live_component module={Input.Image} id={"#{field.id}-image"} form={@form} field={:slug} />
<Input.text form={@form} field={:meta_title} />
<Input.text_area form={@form} field={:meta_description} />
<!-- etc etc -->
<./fieldset>
I forked phoenix_live_view and added a little helper to the use Phoenix.LiveComponent logic
def live_component(assigns) do
assigns
|> assign(:module, __MODULE__)
|> Phoenix.LiveView.Helpers.live_component()
end
So now my code can look like this:
<.fieldset heading="Project">
<Input.RichText.live_component form={@form} field={:title} id={"#{field.id}-title"} />
<Input.slug form={@form} field={:slug} from={:title} />
<Input.Image.live_component id={"#{field.id}-image"} form={@form} field={:slug} />
<Input.text form={@form} field={:meta_title} />
<Input.text_area form={@form} field={:meta_description} />
<!-- etc etc -->
<./fieldset>
Much easier to scan imo.
I have a PR ready if the Phoenix Live View team thinks this is worth having ![]()
(thanks to lostkobrakai and jonr for the idea!)
Popular in Questions
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Other popular topics
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









