-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove invalid nested <button> inside <a> element in heex templates #5814
base: main
Are you sure you want to change the base?
Remove invalid nested <button> inside <a> element in heex templates #5814
Conversation
@@ -1,8 +1,8 @@ | |||
<.header> | |||
Listing <%= schema.human_plural %> | |||
<:actions> | |||
<.link href={~p"<%= schema.route_prefix %>/new"}> | |||
<.button>New <%= schema.human_singular %></.button> | |||
<.link href={~p"<%= schema.route_prefix %>/new"} class="py-2 px-3 text-sm font-semibold rounded-lg bg-zinc-100 hover:bg-zinc-200/80"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest this style since a very similar style is already used for the button-alike link "Get Started" in app.html.heex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid using tailwind styles in generators. The home page is fine, because we discard it. Could we use <.button> only instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my projects I have a <.button link={%{patch: ...}}
that then has a properly styled <.link
inside. Maybe that's the way to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about plain old link by simply using <.link> without any fancy style?
Buttons would always require javascript and some users might create their projects with --no-live flag.
Or the generators could produce different elements:
- mix phx.gen.live could use <.button> with phx-click only
- while mix phx.gen.html could stick to simple <.link> (which could still be styled/replaced further if CoreComponents gets some button-alike link component in the future)
Fixes #5770