bitcrowd / bitstyles_phoenix

A collection of Elixir phoenix helpers for bitstyles
ISC License
12 stars 0 forks source link

phoenix_html v4 compatibility #129

Closed angelikatyborska closed 2 months ago

angelikatyborska commented 2 months ago

Currently, this library is not compatible with phoenix_html v4. The incompatible code is this and only this:

defmodule BitstylesPhoenix.Showcase do
  @moduledoc false

  import Phoenix.HTML, only: [safe_to_string: 1]
  import Phoenix.HTML.Tag, only: [content_tag: 3]

Phoenix.HTML.Tag no longer exists in phoenix_html, it was extracted to a separate library, phoenix_html_helpers, and renamed (PhoenixHTMLHelpers.Tag)

Note that it's a bit weird that this library uses phoenix_html directly but does not list it in its mix.exs.

angelikatyborska commented 2 months ago

The incompatible code is this and only this:

I was very much mistaken. There's more incompatible code. In fact, the whole approach to writing forms changed. A quick summary:

Removed in phoenix_html 4 (https://hexdocs.pm/phoenix_html/changelog.html#v4-0-0-2023-12-19)

New "phoenix way" of creating forms: In a newely generated Phoenix app, there's a module CoreComponents that includes components like input, label, error.

New "phoenix way" of writing HTML when tags are dynamic (replacement for Phoenix.HTML.Tag.content_tag): No idea ???

Fallback for people who do not want to use the new "phoenix way": Old HTML helpers were moved to a separate library: https://hexdocs.pm/phoenix_html_helpers/PhoenixHTMLHelpers.html

andreasknoepfle commented 2 months ago

True. But that part can be replaced also by writing our own html templates, just like we do with the other components.

I think the main think will be BitstylesPhoenix.Component.Form.render_input/4 needs to be componentized. But luckily the interface is well defined.

New "phoenix way" of writing HTML when tags are dynamic (replacement for Phoenix.HTML.Tag.content_tag):
No idea ???

The only place that I know is the heading component. And there we might want to deprecate the tag attribute in favour of level and just have a dynamic assign for <h1> to <h6>.

I think we should move towards the new way of things there.

angelikatyborska commented 2 months ago

So the desired way forward would be roughly to:

?

angelikatyborska commented 2 months ago

Elixir Slack to the rescue, the correct replacement for Phoenix.HTML.tag.content_tag would be https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#dynamic_tag/1