-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce specialized view for rails 8 authentication generator
- Loading branch information
1 parent
31ee0f7
commit acdd45a
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
lib/generators/tailwindcss/authentication/authentication_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rails/generators/erb/authentication/authentication_generator" | ||
|
||
module Tailwindcss | ||
module Generators | ||
class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator | ||
source_root File.expand_path("templates", __dir__) | ||
end | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
lib/generators/tailwindcss/authentication/templates/views/sessions/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="mx-auto md:w-2/3 w-full"> | ||
<h1 class="font-bold text-4xl">Sign in</h1> | ||
|
||
<%% if alert = flash[:alert] %> | ||
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%%= alert %></p> | ||
<%% end %> | ||
|
||
<%%= form_with url: session_url, class: "contents" do |form| %> | ||
<div class="my-5"> | ||
<%%= 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" %> | ||
</div> | ||
|
||
<div class="my-5"> | ||
<%%= 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" %> | ||
</div> | ||
|
||
<div class="inline"> | ||
<%%= form.submit "Sign in", class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> | ||
</div> | ||
<%% end %> | ||
</div> | ||
|
13 changes: 13 additions & 0 deletions
13
test/lib/generators/tailwindcss/authentication_generator_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "test_helper" | ||
require "generators/tailwindcss/authentication/authentication_generator" | ||
|
||
class Tailwindcss::Generators::AuthenticationGeneratorTest < Rails::Generators::TestCase | ||
tests Tailwindcss::Generators::AuthenticationGenerator | ||
destination TAILWINDCSS_TEST_APP_ROOT | ||
|
||
test "generates the new session template" do | ||
run_generator | ||
|
||
assert_file "app/views/sessions/new.html.erb" | ||
end | ||
end |