Skip to content

Commit

Permalink
introduce specialized view for rails 8 authentication generator
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Jul 29, 2024
1 parent 31ee0f7 commit acdd45a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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
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 test/lib/generators/tailwindcss/authentication_generator_test.rb
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

0 comments on commit acdd45a

Please sign in to comment.