Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f92f025

Browse files
committedJul 30, 2024··
introduce specialized view for rails 8 authentication generator
1 parent 84c08f8 commit f92f025

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "rails/generators/erb/authentication/authentication_generator"
2+
3+
module Tailwindcss
4+
module Generators
5+
class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator
6+
source_root File.expand_path("templates", __dir__)
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="mx-auto md:w-2/3 w-full">
2+
<h1 class="font-bold text-4xl">Sign in</h1>
3+
4+
<%% if alert = flash[:alert] %>
5+
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%%= alert %></p>
6+
<%% end %>
7+
8+
<%%= form_with url: session_url, class: "contents" do |form| %>
9+
<div class="my-5">
10+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address], class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
11+
</div>
12+
13+
<div class="my-5">
14+
<%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
15+
</div>
16+
17+
<div class="inline">
18+
<%%= form.submit "Sign in", class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
19+
</div>
20+
<%% end %>
21+
</div>
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require "test_helper"
2+
3+
if Rails::VERSION::MAJOR >= 8
4+
require "generators/tailwindcss/authentication/authentication_generator"
5+
6+
class Tailwindcss::Generators::AuthenticationGeneratorTest < Rails::Generators::TestCase
7+
tests Tailwindcss::Generators::AuthenticationGenerator
8+
destination TAILWINDCSS_TEST_APP_ROOT
9+
10+
test "generates the new session template" do
11+
run_generator
12+
13+
assert_file "app/views/sessions/new.html.erb"
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)
Please sign in to comment.