tailwindcss-rails-webpacker 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b194df1be2279bca5ff3bfc82ed7b9c6c391a53f52b8ff0c1f439f0c139b9529
4
- data.tar.gz: 59314057129220441d9e2dc37d28e1dc8822ebfba228c36ee98c14045450d686
3
+ metadata.gz: dd057558a2d696d288db5d20ff3686f2f72e2efe14ea1aeba572edadd957da15
4
+ data.tar.gz: 0be73bef1ee45532a856e18095fc3f0ec68fd1ac105254152f8fd7a89faaa806
5
5
  SHA512:
6
- metadata.gz: bbf5fff36f7c7076ffe7ae97e343b8c106cdaf6e5f02edc6126899bcf5767beeb0d67cba665c58fa0241aaf78bf68adfb37d168072b5749ff1029ca902eb2091
7
- data.tar.gz: 40c89d7a27b438c2311cc0ce504229c8bb7a5a55954fb269e9ba3476d93938821d0cd19836223978bc1b8e4a71c96ed00926b62b844d3536035d51c7b650d0e2
6
+ metadata.gz: '0285c063eed50e80b6cae766073d2d2ccfc6bfe00d718c7ea7764657f8338f5ec9699450021348f0fccaf208ca98add84aab784887aa253980aee1dc46565238'
7
+ data.tar.gz: 85cbf1394821a075fc0e529b71ac09a789a70e62fbe23706c5ba4b1949f0de57186976f41c7f3150d2a7646341fb7a7f16c01acb2499a02ae40336d4b0391292
data/README.md CHANGED
@@ -6,12 +6,16 @@ This gem gives access to the standard Tailwind CSS framework configured for Rail
6
6
 
7
7
  This is extraction originally created inside the [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) gem.
8
8
 
9
+ Gem overrides default Rails scaffold generators in favour of Tailwind
10
+ designed templates by Adam Wathan and the Tailwind team.
11
+
9
12
 
10
13
  ## Installation
11
14
 
12
15
  1. Run `./bin/bundle add tailwindcss-rails-webpacker`
13
16
  2. Run `./bin/rails tailwindcss:install`
14
17
 
18
+
15
19
  ## Purging in production
16
20
 
17
21
  The Tailwind CSS framework starts out as a massive file, which gives you all the combinations of utility classes for development, but you wouldn't want to ship all those unused classes in production.
@@ -20,5 +24,5 @@ This gem will automatically purge those unused classes in production.
20
24
 
21
25
  ## License
22
26
 
23
- Tailwind for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
27
+ Tailwind for Rails Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).
24
28
  Tailwind CSS is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require "rails/generators/resource_helpers"
3
+
4
+ module Tailwindcss
5
+ module Generators
6
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
7
+ include Rails::Generators::ResourceHelpers
8
+
9
+ source_root File.expand_path("../templates", __FILE__)
10
+
11
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
12
+
13
+ def create_root_folder
14
+ empty_directory File.join("app/views", controller_file_path)
15
+ end
16
+
17
+ def copy_view_files
18
+ available_views.each do |view|
19
+ formats.each do |format|
20
+ filename = filename_with_extensions(view, format)
21
+ template filename, File.join("app/views", controller_file_path, filename)
22
+ end
23
+ end
24
+
25
+ template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_table_name}.html.erb")
26
+ end
27
+
28
+ private
29
+ def available_views
30
+ %w(index edit show new _form)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,43 @@
1
+ <%%= form_with(model: <%= model_resource_name %>, class: "contents") do |form| %>
2
+ <%% if <%= singular_table_name %>.errors.any? %>
3
+ <div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
4
+ <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% <%= singular_table_name %>.errors.each do |error| %>
8
+ <li><%%= error.full_message %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% attributes.each do |attribute| -%>
15
+ <div class="my-5">
16
+ <% if attribute.password_digest? -%>
17
+ <%%= form.label :password %>
18
+ <%%= form.password_field :password %>
19
+ </div>
20
+
21
+ <div class="my-5">
22
+ <%%= form.label :password_confirmation %>
23
+ <%%= form.password_field :password_confirmation, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
24
+ <% elsif attribute.attachments? -%>
25
+ <%%= form.label :<%= attribute.column_name %> %>
26
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
27
+ <% else -%>
28
+ <%%= form.label :<%= attribute.column_name %> %>
29
+ <% if attribute.field_type == :text_area -%>
30
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, rows: 4, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
31
+ <% elsif attribute.field_type == :check_box -%>
32
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: "block mt-2 h-5 w-5" %>
33
+ <% else -%>
34
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
35
+ <% end -%>
36
+ <% end -%>
37
+ </div>
38
+
39
+ <% end -%>
40
+ <div class="inline">
41
+ <%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium" %>
42
+ </div>
43
+ <%% end %>
@@ -0,0 +1,8 @@
1
+ <div class="mx-auto md:w-2/3 w-full">
2
+ <h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
3
+
4
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
5
+
6
+ <%%= link_to "Show this <%= human_name.downcase %>", @<%= singular_table_name %>, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
7
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
8
+ </div>
@@ -0,0 +1,14 @@
1
+ <div class="w-full">
2
+ <%% if notice.present? %>
3
+ <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%%= notice %></p>
4
+ <%% end %>
5
+
6
+ <div class="flex justify-between items-center">
7
+ <h1 class="text-lg font-bold text-4xl"><%= human_name.pluralize %></h1>
8
+ <%%= link_to 'New <%= human_name.downcase %>', new_<%= singular_route_name %>_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
9
+ </div>
10
+
11
+ <div id="<%= plural_table_name %>" class="min-w-full">
12
+ <%%= render @<%= plural_table_name %> %>
13
+ </div>
14
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="mx-auto md:w-2/3 w-full">
2
+ <h1 class="text-lg font-bold text-4xl">New <%= human_name.downcase %></h1>
3
+
4
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
5
+
6
+ <%%= link_to 'Back to <%= human_name.pluralize.downcase %>', <%= index_helper %>_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
7
+ </div>
@@ -0,0 +1,22 @@
1
+ <div id="<%%= dom_id <%= singular_table_name %> %>">
2
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
3
+ <p class="my-5">
4
+ <strong class="block font-medium mb-1"><%= attribute.human_name %>:</strong>
5
+ <% if attribute.attachment? -%>
6
+ <%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
7
+ <% elsif attribute.attachments? -%>
8
+ <%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
9
+ <div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
10
+ <%% end %>
11
+ <% else -%>
12
+ <%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
13
+ <% end -%>
14
+ </p>
15
+
16
+ <% end -%>
17
+ <%% if action_name != "show" %>
18
+ <%%= link_to "Show this <%= human_name.downcase %>", <%= singular_table_name %>, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
19
+ <%%= link_to 'Edit this <%= human_name.downcase %>', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
20
+ <hr class="mt-6">
21
+ <%% end %>
22
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="mx-auto md:w-2/3 w-full flex">
2
+ <div class="mx-auto">
3
+ <%% if notice.present? %>
4
+ <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%%= notice %></p>
5
+ <%% end %>
6
+
7
+ <%%= render @<%= singular_table_name %> %>
8
+
9
+ <%%= link_to 'Edit this <%= singular_table_name %>', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
10
+ <div class="inline-block ml-2">
11
+ <%%= button_to 'Delete this <%= singular_table_name %>', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, data: { confirm: "Are you sure you want to delete this <%= singular_table_name %>?" }, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
12
+ </div>
13
+ <%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
14
+ </div>
15
+ </div>
@@ -13,8 +13,10 @@ insert_into_file "postcss.config.js", "require('tailwindcss')(\"./app/javascript
13
13
 
14
14
 
15
15
  if APPLICATION_LAYOUT_PATH.exist?
16
- say "Add Tailwindcss include tags in application layout"
16
+ say "Add Tailwindcss include tags and container element in application layout"
17
17
  insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s, %(\n <%= stylesheet_pack_tag "application", "data-turbo-track": "reload" %>), before: /\s*<\/head>/
18
+ insert_into_file APPLICATION_LAYOUT_PATH.to_s, %( <main class="container mx-auto mt-28 px-5 flex">\n ), before: /^\s*<%= yield/
19
+ insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n </main>), after: /^\s*<%= yield %>/
18
20
  else
19
21
  say "Default application.html.erb is missing!", :red
20
22
  say %( Add <%= stylesheet_pack_tag "application", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
@@ -1,4 +1,7 @@
1
1
  module Tailwindcss
2
2
  class Engine < ::Rails::Engine
3
+ config.app_generators do |g|
4
+ g.template_engine :tailwindcss
5
+ end
3
6
  end
4
7
  end
@@ -1,3 +1,3 @@
1
1
  module Tailwindcss
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailwindcss-rails-webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Maric
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-22 00:00:00.000000000 Z
12
+ date: 2021-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -35,6 +35,13 @@ files:
35
35
  - MIT-LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
+ - lib/generators/tailwindcss/scaffold/scaffold_generator.rb
39
+ - lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt
40
+ - lib/generators/tailwindcss/scaffold/templates/edit.html.erb.tt
41
+ - lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt
42
+ - lib/generators/tailwindcss/scaffold/templates/new.html.erb.tt
43
+ - lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt
44
+ - lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt
38
45
  - lib/install/stylesheets/application.scss
39
46
  - lib/install/stylesheets/tailwind.config.js
40
47
  - lib/install/tailwindcss.rb