Add dark mode with toggle and localStorage persistence
Uses Tailwind v4 class-based dark mode with a Stimulus controller for toggling. Respects prefers-color-scheme as default, prevents FOUC with an inline script, and persists the user's choice in localStorage. All views updated with dark: variants for backgrounds, text, borders, badges, buttons, and form inputs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<%= form_with url: signin_path, class: "contents", data: { controller: "form-errors" } do |form| %>
|
||||
<%= hidden_field_tag :rd, params[:rd] if params[:rd].present? %>
|
||||
<div class="my-5">
|
||||
<%= form.label :email_address, "Email Address", class: "block font-medium text-sm text-gray-700" %>
|
||||
<%= form.label :email_address, "Email Address", class: "block font-medium text-sm text-gray-700 dark:text-gray-300" %>
|
||||
<%= form.email_field :email_address,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
@@ -14,17 +14,17 @@
|
||||
placeholder: "your@email.com",
|
||||
value: @login_hint || params[:email_address],
|
||||
data: { action: "blur->webauthn#checkWebAuthnSupport change->webauthn#checkWebAuthnSupport" },
|
||||
class: "block shadow-sm rounded-md border border-gray-400 focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
|
||||
class: "block shadow-sm rounded-md border border-gray-400 focus:outline-blue-600 px-3 py-2 mt-2 w-full dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100" %>
|
||||
</div>
|
||||
|
||||
<!-- WebAuthn section - initially hidden -->
|
||||
<div id="webauthn-section" data-login-form-target="webauthnSection" class="my-5 hidden">
|
||||
<div class="bg-green-50 border border-green-200 rounded-lg p-4 mb-4">
|
||||
<div class="bg-green-50 border border-green-200 rounded-lg p-4 mb-4 dark:bg-green-900/30 dark:border-green-700">
|
||||
<div class="flex items-center">
|
||||
<svg class="w-5 h-5 text-green-600 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
<p class="text-sm text-green-800">
|
||||
<p class="text-sm text-green-800 dark:text-green-200">
|
||||
<strong>Passkey detected!</strong> You can sign in without a password.
|
||||
</p>
|
||||
</div>
|
||||
@@ -44,13 +44,13 @@
|
||||
<!-- Password section - shown by default, hidden if WebAuthn is required -->
|
||||
<div id="password-section" data-login-form-target="passwordSection">
|
||||
<div class="my-5">
|
||||
<%= form.label :password, class: "block font-medium text-sm text-gray-700" %>
|
||||
<%= form.label :password, class: "block font-medium text-sm text-gray-700 dark:text-gray-300" %>
|
||||
<%= form.password_field :password,
|
||||
required: true,
|
||||
autocomplete: "current-password",
|
||||
placeholder: "Enter your password",
|
||||
maxlength: 72,
|
||||
class: "block shadow-sm rounded-md border border-gray-400 focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
|
||||
class: "block shadow-sm rounded-md border border-gray-400 focus:outline-blue-600 px-3 py-2 mt-2 w-full dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
@@ -59,14 +59,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-sm text-gray-600 text-center">
|
||||
<div class="mt-4 text-sm text-gray-600 dark:text-gray-400 text-center">
|
||||
<%= link_to "Forgot your password?", new_password_path, class: "text-blue-600 hover:text-blue-500 underline" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Loading overlay -->
|
||||
<div id="loading-overlay" data-login-form-target="loadingOverlay" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
|
||||
<div class="bg-white rounded-lg p-6 flex items-center">
|
||||
<div id="loading-overlay" data-login-form-target="loadingOverlay"
|
||||
data-action="click->login-form#hideLoading"
|
||||
class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 cursor-pointer">
|
||||
<div class="bg-white rounded-lg p-6 flex items-center dark:bg-gray-900">
|
||||
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-blue-600" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="mx-auto max-w-md">
|
||||
<div class="bg-white py-8 px-6 shadow rounded-lg sm:px-10">
|
||||
<div class="bg-white py-8 px-6 shadow rounded-lg sm:px-10 dark:bg-gray-900">
|
||||
<div class="mb-8">
|
||||
<h2 class="text-2xl font-bold text-gray-900">Two-Factor Authentication</h2>
|
||||
<p class="mt-2 text-sm text-gray-600">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-gray-100">Two-Factor Authentication</h2>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
Enter the 6-digit code from your authenticator app to complete sign in.
|
||||
</p>
|
||||
</div>
|
||||
@@ -13,7 +13,7 @@
|
||||
} do |form| %>
|
||||
<%= hidden_field_tag :rd, params[:rd] if params[:rd].present? %>
|
||||
<div>
|
||||
<%= label_tag :code, "Verification Code", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= label_tag :code, "Verification Code", class: "block text-sm font-medium text-gray-700 dark:text-gray-300" %>
|
||||
<%= text_field_tag :code,
|
||||
nil,
|
||||
placeholder: "000000",
|
||||
@@ -21,8 +21,8 @@
|
||||
required: true,
|
||||
autofocus: true,
|
||||
autocomplete: "off",
|
||||
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-center text-2xl tracking-widest font-mono sm:text-sm" %>
|
||||
<p class="mt-2 text-xs text-gray-500">
|
||||
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-center text-2xl tracking-widest font-mono sm:text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100" %>
|
||||
<p class="mt-2 text-xs text-gray-500 dark:text-gray-400">
|
||||
Enter your 6-digit authenticator code or an 8-character backup code
|
||||
</p>
|
||||
</div>
|
||||
@@ -30,7 +30,7 @@
|
||||
<div>
|
||||
<%= form.submit "Verify",
|
||||
data: { form_submit_protection_target: "submit" },
|
||||
class: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" %>
|
||||
class: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 dark:focus:ring-offset-gray-900" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
<div class="mt-4">
|
||||
<div class="relative my-4">
|
||||
<div class="absolute inset-0 flex items-center">
|
||||
<div class="w-full border-t border-gray-300"></div>
|
||||
<div class="w-full border-t border-gray-300 dark:border-gray-600"></div>
|
||||
</div>
|
||||
<div class="relative flex justify-center text-sm">
|
||||
<span class="px-2 bg-white text-gray-500">Or</span>
|
||||
<span class="px-2 bg-white text-gray-500 dark:bg-gray-900 dark:text-gray-400">Or</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button"
|
||||
@@ -62,18 +62,18 @@
|
||||
<div class="mt-6">
|
||||
<div class="relative">
|
||||
<div class="absolute inset-0 flex items-center">
|
||||
<div class="w-full border-t border-gray-300"></div>
|
||||
<div class="w-full border-t border-gray-300 dark:border-gray-600"></div>
|
||||
</div>
|
||||
<div class="relative flex justify-center text-sm">
|
||||
<span class="px-2 bg-white text-gray-500">Need help?</span>
|
||||
<span class="px-2 bg-white text-gray-500 dark:bg-gray-900 dark:text-gray-400">Need help?</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-center">
|
||||
<p class="text-sm text-gray-600">
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">
|
||||
Lost access to your authenticator?
|
||||
</p>
|
||||
<p class="mt-1 text-xs text-gray-500">
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
Contact an administrator for assistance.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user