Skip to content

Commit acdd45a

Browse files
committed
introduce specialized view for rails 8 authentication generator
1 parent 31ee0f7 commit acdd45a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 9 additions & 0 deletions
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
Lines changed: 22 additions & 0 deletions
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+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require "test_helper"
2+
require "generators/tailwindcss/authentication/authentication_generator"
3+
4+
class Tailwindcss::Generators::AuthenticationGeneratorTest < Rails::Generators::TestCase
5+
tests Tailwindcss::Generators::AuthenticationGenerator
6+
destination TAILWINDCSS_TEST_APP_ROOT
7+
8+
test "generates the new session template" do
9+
run_generator
10+
11+
assert_file "app/views/sessions/new.html.erb"
12+
end
13+
end

0 commit comments

Comments
 (0)