From 686c51254390391c0ffd63a7a434bdca39acd944 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 10 Jul 2024 14:38:25 +0300 Subject: [PATCH] Stack preferred auth button over other auth buttons on small screens --- app/assets/javascripts/auth_providers.js | 2 +- .../application/_auth_providers.html.erb | 29 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/auth_providers.js b/app/assets/javascripts/auth_providers.js index 3dd7601a0..75eca253e 100644 --- a/app/assets/javascripts/auth_providers.js +++ b/app/assets/javascripts/auth_providers.js @@ -11,7 +11,7 @@ $(document).ready(function () { // Add click handler to show OpenID field $("#openid_open_url").click(function () { $("#openid_url").val("http://"); - $("#login_auth_buttons").hide().removeClass("d-flex"); + $("#login_auth_buttons").hide(); $("#login_openid_url").show(); $("#openid_login_button").show(); }); diff --git a/app/views/application/_auth_providers.html.erb b/app/views/application/_auth_providers.html.erb index bdd0c474a..ddf143d96 100644 --- a/app/views/application/_auth_providers.html.erb +++ b/app/views/application/_auth_providers.html.erb @@ -1,17 +1,18 @@ -
-
+<% prefered_auth_button_available = false %> +<% %w[google facebook microsoft github wikipedia].each do |provider| %> + <% if Settings.key?("#{provider}_auth_id".to_sym) -%> + <% if @preferred_auth_provider == provider %> + <% prefered_auth_button_available = true %> + <% end %> + <% end -%> +<% end -%> - <% prefered_auth_button_available = false %> - <% %w[google facebook microsoft github wikipedia].each do |provider| %> - <% if Settings.key?("#{provider}_auth_id".to_sym) -%> - <% if @preferred_auth_provider == provider %> - <% prefered_auth_button_available = true %> - <% end %> - <% end -%> - <% end -%> +
+ <%= tag.div :id => "login_auth_buttons", + :class => ["row row-cols-1", { "row-cols-sm-2" => prefered_auth_button_available }, "g-2 mb-3"] do %> <% if prefered_auth_button_available %> -
+
<% %w[google facebook microsoft github wikipedia].each do |provider| %> <% if Settings.key?("#{provider}_auth_id".to_sym) -%> <% if @preferred_auth_provider == provider %> @@ -20,11 +21,9 @@ <% end -%> <% end -%>
-
- <% else %> -
<% end %> +
<%= button_tag image_tag("openid.svg", :alt => t(".openid.alt"), :size => "36"), @@ -41,7 +40,7 @@ <% end %> <% end -%>
-
+ <% end %> <%# :tabindex starts high to allow rendering at the bottom of the template %> <%= form_tag(auth_path(:provider => "openid"), :id => "openid_login_form") do %> -- 2.39.5