Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor flashes [WIP - Questions] #455

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Tailwindcss
module Generators
class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator
source_root File.expand_path("templates", __dir__)

def copy_view_files
template "../../scaffold/templates/_flashes.html.erb", "app/views/application/_flashes.html.erb"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="mx-auto md:w-2/3 w-full">
<%% 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 %>
<%%= render "flashes" %>

<h1 class="font-bold text-4xl">Update your password</h1>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="mx-auto md:w-2/3 w-full">
<%% 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 %>
<%%= render "flashes" %>

<h1 class="font-bold text-4xl">Forgot your password?</h1>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<div class="mx-auto md:w-2/3 w-full">
<%% 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 %>

<%% if notice = flash[:notice] %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%%= notice %></p>
<%% end %>
<%%= render "flashes" %>

<h1 class="font-bold text-4xl">Sign in</h1>

Expand Down
1 change: 1 addition & 0 deletions lib/generators/tailwindcss/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def copy_view_files
end

template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_name}.html.erb")
template "_flashes.html.erb", "app/views/application/_flashes.html.erb"
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%% if notice.present? %>
<p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-md bg-green-50" id="notice"><%%= notice %></p>
<%% end %>

<%% if alert.present? %>
<p class="inline-block px-3 py-2 mb-5 font-medium text-red-500 rounded-lg bg-red-50" id="alert"><%%= alert %></p>
<%% end %>
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%% content_for :title, "<%= human_name.pluralize %>" %>

<div class="w-full">
<%% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%%= notice %></p>
<%% end %>
<%%= render "flashes" %>

<div class="flex justify-between items-center">
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%% content_for :title, "Showing <%= human_name.downcase %>" %>

<div class="md:w-2/3 w-full">
<%% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%%= notice %></p>
<%% end %>
<%%= render "flashes" %>

<h1 class="font-bold text-4xl">Showing <%= human_name.downcase %></h1>

Expand Down
Loading