I can’t get a Logout button (or plain link) to look good in either a Bootstrap or Bulma navbar. My general question is: how do you make a <form> that wraps an <a class="button"...>...</a> render the same as the <a> alone?
Per the Phoenix book, logging out is done with:
link("Log out", to: session_path(conn, :delete, current_user)
Thanks. That fixes the buttons when the media is desktop, but when it’s phone-like narrow, the form button doesn’t expand to fill the width as the non-form button does.
Which is OK. I was mainly curious to see whether there’s a documented set of tricks that I could use. I suspect that I’ll just have to become more competent in CSS.
This may not help you in this scenario, but I discovered yesterday that you can supply a block to the link helper function. This allows you to provide any HTML within the generated form and link element.
<%= if @current_user do %>
<span class="nav-item">
<%= link to: auth_path(@conn, :delete), method: :delete, class: "button" do %>
Log out
<% end %>
</span>
<% end %>
Not sure if that would help. The key issue, it seems to me, is that link sometimes expands into a simple <a> tag and sometimes into a <form> that contains <a> tags. Things like class attributes passed to link are attached to the <a>, but sometimes they should be attached to the <form> for layout to work right.