From 2ac0c69842f06b0d78138dbf4edff957ba1ea16b Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Sep 2026 13:53:38 +0300 Subject: [PATCH 1/4] Fix stub login banner in dark mode, add dark mode toggle to login screen Fix: the stub login banner was unreadable in dark mode. The banner styled itself with Tailwind utilities (bg-red-50, text-red-900, dark:bg-red-900/30 and friends). Those classes live in a view shipped inside the gem, which the host application's Tailwind build never scans, so the CSS for them was never generated. The banner rendered with no background and no text color -- effectively white on white. Replaced them with inline styles that need no build step: a translucent red tint and border, and no explicit text color so the text inherits the page's, which reads on both a light and a dark card. Applied to the gem view (both the Active Admin 4 and 3 branches) and to both generator templates. Improvement: added Active Admin's dark mode toggle to the login screen. Active Admin only renders the toggle in the signed-in top bar, so a signed out admin had no way to switch themes. The logged out layout already renders active_admin/html_head, which loads the JS that delegates clicks on .dark-mode-toggle, so the button needs no script of its own -- only the markup, copied from Active Admin's own _site_header partial. Added to the Active Admin 4 markup only; Active Admin 3 has no dark mode. The auto margin is an inline style rather than ms-auto for the same reason as above: the gem's views are outside the host's Tailwind content path, so only utilities Active Admin itself already emits are safe to use here. Co-Authored-By: Clanker --- .../active_admin/devise/sessions/new.html.erb | 23 +++++++++++++++---- lib/activeadmin/oidc/version.rb | 2 +- .../install/templates/sessions_new.html.erb | 2 +- .../templates/sessions_new_v4.html.erb | 21 +++++++++++++---- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/views/active_admin/devise/sessions/new.html.erb b/app/views/active_admin/devise/sessions/new.html.erb index efdb1f5..c9e0d89 100644 --- a/app/views/active_admin/devise/sessions/new.html.erb +++ b/app/views/active_admin/devise/sessions/new.html.erb @@ -1,11 +1,24 @@ <% if ActiveAdmin::Oidc.aa_v4? %>
-

- <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> -

+
+

+ <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> +

+ + <%# Active Admin's own dark mode toggle. The logged out layout renders + active_admin/html_head, which loads the JS that delegates clicks on + .dark-mode-toggle, so the button needs no script of its own. %> + +
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> @@ -22,7 +35,7 @@

<%= active_admin_application.site_title(self) %>

<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> diff --git a/lib/activeadmin/oidc/version.rb b/lib/activeadmin/oidc/version.rb index 458ffdb..12e877b 100644 --- a/lib/activeadmin/oidc/version.rb +++ b/lib/activeadmin/oidc/version.rb @@ -2,6 +2,6 @@ module ActiveAdmin module Oidc - VERSION = "2.2.0" + VERSION = "2.2.1" end end diff --git a/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb b/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb index ce2d8a9..ea16fb3 100644 --- a/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb +++ b/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb @@ -5,7 +5,7 @@

<%= active_admin_application.site_title(self) %>

<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> diff --git a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb index 1d7832d..5484668 100644 --- a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb +++ b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb @@ -2,12 +2,25 @@ route while ActiveAdmin::Oidc.config.stub_dev_env_login! is on, which only ever happens in the development environment. %>
-

- <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> -

+
+

+ <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> +

+ + <%# Active Admin's own dark mode toggle. The logged out layout renders + active_admin/html_head, which loads the JS that delegates clicks on + .dark-mode-toggle, so the button needs no script of its own. %> + +
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> From 3b0842ca94ddfb89296161b1af1ec4e7de95b345 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Sep 2026 14:02:14 +0300 Subject: [PATCH 2/4] Use Active Admin's own utility classes on the login screen Only Tailwind utilities that Active Admin itself emits are compiled, because the gem's views sit outside the host application's Tailwind content path. The previous commit worked around that with inline styles; reuse Active Admin's own class strings instead, so the login screen matches the rest of the admin and follows its theme. * The stub login banner now uses the exact classes and icon of Active Admin's error flash (_flash_messages.html.erb). * The dark mode toggle uses ms-auto, which _main_navigation.html.erb emits, in place of an inline margin-inline-start. The Active Admin 3 branch keeps its plain inline style: there is no Tailwind and no dark mode there. Co-Authored-By: Clanker --- app/views/active_admin/devise/sessions/new.html.erb | 13 ++++++++----- .../oidc/install/templates/sessions_new.html.erb | 2 +- .../oidc/install/templates/sessions_new_v4.html.erb | 11 +++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/views/active_admin/devise/sessions/new.html.erb b/app/views/active_admin/devise/sessions/new.html.erb index c9e0d89..d27bda1 100644 --- a/app/views/active_admin/devise/sessions/new.html.erb +++ b/app/views/active_admin/devise/sessions/new.html.erb @@ -9,8 +9,7 @@ active_admin/html_head, which loads the JS that delegates clicks on .dark-mode-toggle, so the button needs no script of its own. %>
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> <%= button_to ActiveAdmin::Oidc.config.login_button_label, @@ -35,7 +38,7 @@

<%= active_admin_application.site_title(self) %>

<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> diff --git a/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb b/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb index ea16fb3..ce2d8a9 100644 --- a/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb +++ b/lib/generators/active_admin/oidc/install/templates/sessions_new.html.erb @@ -5,7 +5,7 @@

<%= active_admin_application.site_title(self) %>

<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> diff --git a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb index 5484668..14eccb5 100644 --- a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb +++ b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb @@ -11,8 +11,7 @@ active_admin/html_head, which loads the JS that delegates clicks on .dark-mode-toggle, so the button needs no script of its own. %>
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> -

+ <%# Classes copied from Active Admin's own error flash. The gem's views are + outside the host's Tailwind content path, so only utilities Active Admin + itself already emits are compiled. %> +

+ Stub login is enabled: the button below signs in without contacting the identity provider. -

+
<% end %> <%= button_to ActiveAdmin::Oidc.config.login_button_label, From 2d84df5f0fe9e178360947c4266c45c21d0616dc Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Sep 2026 14:07:27 +0300 Subject: [PATCH 3/4] Address review: keep the toggle's focus outline, cover both changes * Drop focus:outline-hidden from the dark mode toggle. It was copied from Active Admin's own site header, but nothing replaces the outline it removes, so a keyboard user could not see the button focused. The login card has no other control to borrow a focus style from. * Cover the toggle in login_page_spec: present on Active Admin 4, absent on Active Admin 3. The markup is the whole feature -- the JS that drives it already ships with Active Admin -- so dropping it fails silently. * Cover the banner styling in stub_login_spec. The old test asserted only the warning text, so it passed while the banner rendered white on white. Each matrix run now asserts the styling that run actually compiles: the dark variant on Active Admin 4, the inline style on Active Admin 3. Both specs were checked against a deliberately broken view to confirm they fail when the markup goes away. Co-Authored-By: Clanker --- .../active_admin/devise/sessions/new.html.erb | 2 +- .../templates/sessions_new_v4.html.erb | 2 +- spec/requests/login_page_spec.rb | 23 +++++++++++++++++++ spec/requests/stub_login_spec.rb | 21 +++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/app/views/active_admin/devise/sessions/new.html.erb b/app/views/active_admin/devise/sessions/new.html.erb index d27bda1..84a43ba 100644 --- a/app/views/active_admin/devise/sessions/new.html.erb +++ b/app/views/active_admin/devise/sessions/new.html.erb @@ -9,7 +9,7 @@ active_admin/html_head, which loads the JS that delegates clicks on .dark-mode-toggle, so the button needs no script of its own. %>