Goal: make bitstyles_phoenix work in any combination of phoenix_live_view versions 18 to 20, and phoenix_html versions 3 to 4
Replacements
Phoenix.HTML.Tag.content_tag in a LV context can be replaced with dynamic_tag which exists in phoenix_live_view v18
Phoenix.HTML.Tag.content_tag in a non-LV context is used for generating the "showcase" macros, can be replaced with a copy-paste of the function. It relies on import Phoenix.HTML, only: [attributes_escape: 1, html_escape: 1] which both still exist in phoenix_html v4
Phoenix.HTML.Form.humanize - this function was previously used by Phoenix to generate default label text from a field name. It looks like there no longer is a default label text. We can copy-paste this function and keep using it.
Phoenix.HTML.Form.text_input, Phoenix.HTML.Form.email_input, and so on, and Phoenix.HTML.Form.textarea, and Phoenix.HTML.Form.select - should all be replaced with a new BitstylesPhoenix.Component.Form.input component that's a copy-paste from Phoenix's CoreComponents but modified to be just the input, no label and no errors. (yes, "textarea" and "select" are handled by an "input" component in CoreComponents 🤷)
The best practice of handling mix.lock file therefore would be to keep it in VCS, and run two different Continuous Integration (CI) workflows: the usual deterministic one, and another one, that starts with mix deps.unlock --all and always compiles your library and runs tests against latest versions of dependencies. The latter one might be even run nightly or otherwise recurrently to stay notified about any possible issue in regard to dependencies updates.
Running tests with unlocked deps would detect that bitstyles_phoenix does not work with the newest phoenix_html version because there was no version specification for this dependency in the mix file.
Other notes
Phoenix.Component.used_input? that's used by PLV 1.0.0-RC in core components does not exist in lower versions. It's used to decide whether input errors should be rendered.
Phoenix.HTML.FormField was added to phoenix_html in 3.3.0, so we need to require that version at minimum.
Phoenix.Component.to_form used in the tests was added to PLV in 18.12. Since we cannot provide different PLV version requirements for local development and for library usage, we need to bump the lowest supported version from 18.9 to 18.12.
Resolves https://github.com/bitcrowd/bitstyles_phoenix/issues/129
Goal: make bitstyles_phoenix work in any combination of phoenix_live_view versions 18 to 20, and phoenix_html versions 3 to 4
Replacements
Phoenix.HTML.Tag.content_tag
in a LV context can be replaced withdynamic_tag
which exists in phoenix_live_view v18Phoenix.HTML.Tag.content_tag
in a non-LV context is used for generating the "showcase" macros, can be replaced with a copy-paste of the function. It relies onimport Phoenix.HTML, only: [attributes_escape: 1, html_escape: 1]
which both still exist in phoenix_html v4Phoenix.HTML.Form.humanize
- this function was previously used by Phoenix to generate default label text from a field name. It looks like there no longer is a default label text. We can copy-paste this function and keep using it.Phoenix.HTML.Form.label
- should be replaced with a newBitstylesPhoenix.Component.Form.label
component that's a copy-paste from Phoenix's CoreComponentsPhoenix.HTML.Form.text_input
,Phoenix.HTML.Form.email_input
, and so on, andPhoenix.HTML.Form.textarea
, andPhoenix.HTML.Form.select
- should all be replaced with a newBitstylesPhoenix.Component.Form.input
component that's a copy-paste from Phoenix's CoreComponents but modified to be just the input, no label and no errors. (yes, "textarea" and "select" are handled by an "input" component in CoreComponents 🤷)CI changes
https://hexdocs.pm/elixir/library-guidelines.html#dependency-handling recommends:
Running tests with unlocked deps would detect that bitstyles_phoenix does not work with the newest phoenix_html version because there was no version specification for this dependency in the mix file.
Other notes
Phoenix.Component.used_input?
that's used by PLV 1.0.0-RC in core components does not exist in lower versions. It's used to decide whether input errors should be rendered.Phoenix.HTML.FormField
was added to phoenix_html in 3.3.0, so we need to require that version at minimum.Phoenix.Component.to_form
used in the tests was added to PLV in 18.12. Since we cannot provide different PLV version requirements for local development and for library usage, we need to bump the lowest supported version from 18.9 to 18.12.