From 573855951ca13ebf5348372858ae0505b8a4f2cb Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Mon, 20 Jan 2025 12:14:05 -0300 Subject: [PATCH 01/37] improve partial: correct use of tags + attachment links styling --- .../tailwindcss/scaffold/templates/partial.html.erb.tt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt index 88dc3eda..ed89fc34 100644 --- a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt @@ -1,16 +1,16 @@ -
+
<% attributes.reject(&:password_digest?).each do |attribute| -%> -

+

<%= attribute.human_name %>: <% if attribute.attachment? -%> - <%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %> + <%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %>, class: "text-gray-700 underline hover:no-underline" if <%= singular_name %>.<%= attribute.column_name %>.attached? %> <% elsif attribute.attachments? -%> <%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %> -
<%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %>
+
<%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>, class: "text-gray-700 underline hover:no-underline" %>
<%% end %> <% else -%> <%%= <%= singular_name %>.<%= attribute.column_name %> %> <% end -%> -

+
<% end -%>
From 5b478e7c5b900534962c0a563060bd7a5228005e Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Fri, 10 Jan 2025 18:23:04 -0300 Subject: [PATCH 02/37] Improve boolean fields --- .../tailwindcss/scaffold/templates/_form.html.erb.tt | 4 ++-- .../tailwindcss/scaffold/templates/partial.html.erb.tt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt index 9e392609..43d06cb2 100644 --- a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt @@ -12,7 +12,7 @@ <%% end %> <% attributes.each do |attribute| -%> -
+
"> <% if attribute.password_digest? -%> <%%= form.label :password %> <%%= form.password_field :password, class: ["block shadow-sm rounded-md border outline-hidden px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password].any?}] %> @@ -29,7 +29,7 @@ <% if attribute.field_type == :textarea || attribute.field_type == :text_area -%> <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, rows: 4, class: ["block shadow-sm rounded-md border outline-hidden px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> <% elsif attribute.field_type == :checkbox || attribute.field_type == :check_box -%> - <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border outline-hidden mt-2 h-5 w-5", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> + <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border outline-hidden order-first h-5 w-5", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> <% else -%> <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border outline-hidden px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> <% end -%> diff --git a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt index 88dc3eda..6062db24 100644 --- a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt @@ -8,6 +8,8 @@ <%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
<%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %>
<%% end %> +<% elsif attribute.type == :boolean -%> + <%%= <%= singular_name %>.<%= attribute.column_name %>? ? "Yes" : "No" %> <% else -%> <%%= <%= singular_name %>.<%= attribute.column_name %> %> <% end -%> From cdafb1b5d8eb6c207cd2321be35dab827b1df08c Mon Sep 17 00:00:00 2001 From: hachi8833 Date: Mon, 17 Feb 2025 13:07:16 +0900 Subject: [PATCH 03/37] Update Readme link for fingerprinting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 649feb2b..7fa18145 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ See https://github.com/flavorjones/tailwindcss-ruby for help. ### Using asset-pipeline assets -In Rails, you want to use [assets from the asset pipeline to get fingerprinting](https://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark). However, Tailwind isn't aware of those assets. +In Rails, you want to use [assets from the asset pipeline to get fingerprinting](https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls). However, Tailwind isn't aware of those assets. To use assets from the pipeline, use `url(image.svg)`. [Since Sprockets v3.3.0](https://github.com/rails/sprockets-rails/pull/476) `url(image.svg)` is rewritten to `/path/to/assets/image-7801e7538c6f1cc57aa75a5876ab0cac.svg` so output CSS will have the correct path to those assets. From dc8251df17086995686e85fdb9bfa9fde731997a Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Mon, 20 Jan 2025 22:50:44 -0300 Subject: [PATCH 04/37] index: show the actions to the right of the partial and add a division between objects --- .../scaffold/templates/index.html.erb.tt | 16 +++++++++++----- test/integration/user_install_test.sh | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 3d337f95..71b7ec23 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -10,13 +10,19 @@ <%%= link_to "New <%= human_name.downcase %>", new_<%= singular_route_name %>_path, class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white block font-medium" %>
-
+
<%% if @<%= plural_table_name %>.any? %> <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> - <%%= render <%= singular_table_name %> %> -

- <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -

+
+ <%%= render <%= singular_table_name %> %> +
+ <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> +
+ <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %> +
+
+
<%% end %> <%% else %>

No <%= human_name.downcase.pluralize %> found.

diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index df3aa8f2..6f4ca301 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -61,7 +61,7 @@ fi # TEST: presence of the generated file bin/rails generate scaffold post title:string body:text published:boolean -grep -q "Show this post" app/views/posts/index.html.erb +grep -q "Show" app/views/posts/index.html.erb # TEST: contents of the css file bin/rails tailwindcss:build[verbose] From ad98417f261dee5a6538489f2e48a083c60fcd7d Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Feb 2025 10:41:30 -0500 Subject: [PATCH 05/37] Simplify index page edit button to use edit_helper --- lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 71b7ec23..7e9b26af 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -17,7 +17,7 @@ <%%= render <%= singular_table_name %> %>
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> - <%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
<%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %>
From db51cda12e187d53c4ade34526b35451591b194a Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Feb 2025 11:07:17 -0500 Subject: [PATCH 06/37] doc: update CHANGELOG [skip ci] --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b1737c..7030e848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Style changes to templates: * Field outlines are no longer hidden, and the focus border is brighter. #489 @rubys +* Boolean fields are improved (checkbox labels aligned, "Yes"/"No" instead of "true"/"false"). #454 @patriciomacadden +* Attachment links are consistently spaced and styled. #460 @patriciomacadden +* Index page links to Show, Edit, and Destroy for each resource. #460 @patriciomacadden @flavorjones ## v4.0.0 / 2025-02-01 From bf0b18fd28c07da6391b6b1808ee800371561967 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Wed, 12 Feb 2025 11:25:52 -0300 Subject: [PATCH 07/37] Add turbo confirm prompt --- lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt | 2 +- lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 7e9b26af..83d2b1ec 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -19,7 +19,7 @@ <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
- <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %> + <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
diff --git a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt index 3a49e9a0..b3057f99 100644 --- a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt @@ -12,6 +12,6 @@ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "mt-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
- <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "mt-2 rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %> + <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "mt-2 rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
From 215b54bf9a6d62634a7523f853639f108b9c6a34 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Feb 2025 12:50:48 -0500 Subject: [PATCH 08/37] version bump to v4.1.0 --- CHANGELOG.md | 5 +++-- lib/tailwindcss/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7030e848..e75b884b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ # `tailwindcss-rails` Changelog -## next / unreleased +## v4.1.0 / 2025-02-19 -Style changes to templates: +### View template improvements * Field outlines are no longer hidden, and the focus border is brighter. #489 @rubys * Boolean fields are improved (checkbox labels aligned, "Yes"/"No" instead of "true"/"false"). #454 @patriciomacadden * Attachment links are consistently spaced and styled. #460 @patriciomacadden * Index page links to Show, Edit, and Destroy for each resource. #460 @patriciomacadden @flavorjones +* Turbo confirm prompt added to Destroy links. #498 @patriciomacadden ## v4.0.0 / 2025-02-01 diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 144cea79..7a096603 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.0.0" + VERSION = "4.1.0" end From 2db5427ac6c086a74ad93752c1ee91990a6f7eda Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Feb 2025 12:52:00 -0500 Subject: [PATCH 09/37] dep: bundle update --- Gemfile.lock | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1e88abcd..730f94fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.0.0) + tailwindcss-rails (4.1.0) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) @@ -69,7 +69,7 @@ GEM pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - logger (1.6.5) + logger (1.6.6) loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -81,26 +81,27 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.8) minitest (5.25.4) - net-imap (0.5.5) + net-imap (0.5.6) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) - nokogiri (1.18.2) + net-smtp (0.5.1) + net-protocol + nokogiri (1.18.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.2-aarch64-linux-gnu) + nokogiri (1.18.3-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.2-arm-linux-gnu) + nokogiri (1.18.3-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.2-arm64-darwin) + nokogiri (1.18.3-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.2-x86_64-darwin) + nokogiri (1.18.3-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.2-x86_64-linux-gnu) + nokogiri (1.18.3-x86_64-linux-gnu) racc (~> 1.4) pp (0.6.2) prettyprint @@ -109,7 +110,7 @@ GEM date stringio racc (1.8.1) - rack (3.1.8) + rack (3.1.10) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -133,24 +134,24 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.2.1) - rdoc (6.11.0) + rdoc (6.12.0) psych (>= 4.0.0) reline (0.6.0) io-console (~> 0.5) securerandom (0.4.1) - stringio (3.1.2) - tailwindcss-ruby (4.0.6) - tailwindcss-ruby (4.0.6-aarch64-linux-gnu) - tailwindcss-ruby (4.0.6-arm64-darwin) - tailwindcss-ruby (4.0.6-x86_64-darwin) - tailwindcss-ruby (4.0.6-x86_64-linux-gnu) + stringio (3.1.3) + tailwindcss-ruby (4.0.7) + tailwindcss-ruby (4.0.7-aarch64-linux-gnu) + tailwindcss-ruby (4.0.7-arm64-darwin) + tailwindcss-ruby (4.0.7-x86_64-darwin) + tailwindcss-ruby (4.0.7-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uri (1.0.2) useragent (0.16.11) - zeitwerk (2.7.1) + zeitwerk (2.7.2) PLATFORMS aarch64-linux From 51f6aba9f37410e09f2b23b0dead3b61c3dc4278 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Thu, 20 Feb 2025 12:56:16 -0300 Subject: [PATCH 10/37] Improve views for mobile devices --- .../templates/app/views/passwords/edit.html.erb | 2 +- .../templates/app/views/passwords/new.html.erb | 2 +- .../templates/app/views/sessions/new.html.erb | 2 +- .../tailwindcss/scaffold/templates/_form.html.erb.tt | 2 +- .../tailwindcss/scaffold/templates/edit.html.erb.tt | 4 ++-- .../tailwindcss/scaffold/templates/index.html.erb.tt | 12 ++++++------ .../tailwindcss/scaffold/templates/new.html.erb.tt | 2 +- .../scaffold/templates/partial.html.erb.tt | 2 +- .../tailwindcss/scaffold/templates/show.html.erb.tt | 8 ++++---- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb index 1296be6f..7096a5bc 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb @@ -15,7 +15,7 @@
- <%%= form.submit "Save", class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %> + <%%= form.submit "Save", class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
<%% end %>
diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb index c37333e6..36dff837 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb @@ -11,7 +11,7 @@
- <%%= form.submit "Email reset instructions", class: "rounded-lg px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %> + <%%= form.submit "Email reset instructions", class: "w-full sm:w-auto text-center rounded-lg px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
<%% end %> diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb index 64c145c0..30fb0d91 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb @@ -20,7 +20,7 @@
- <%%= form.submit "Sign in", class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %> + <%%= form.submit "Sign in", class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
diff --git a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt index 0ddb9735..e50790ce 100644 --- a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt @@ -38,6 +38,6 @@ <% end -%>
- <%%= form.submit class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %> + <%%= form.submit class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
<%% end %> diff --git a/lib/generators/tailwindcss/scaffold/templates/edit.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/edit.html.erb.tt index 74edd3de..08d92d3a 100644 --- a/lib/generators/tailwindcss/scaffold/templates/edit.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/edit.html.erb.tt @@ -5,6 +5,6 @@ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %> - <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> - <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 83d2b1ec..848c97fb 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -13,13 +13,13 @@
<%% if @<%= plural_table_name %>.any? %> <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> -
+
<%%= render <%= singular_table_name %> %> -
- <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> - <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> +
+ <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> +
+ <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
diff --git a/lib/generators/tailwindcss/scaffold/templates/new.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/new.html.erb.tt index 0a10d967..32ad9b83 100644 --- a/lib/generators/tailwindcss/scaffold/templates/new.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/new.html.erb.tt @@ -5,5 +5,5 @@ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %> - <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
diff --git a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt index 68a73fcd..433b7a33 100644 --- a/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt @@ -1,4 +1,4 @@ -
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<%= attribute.human_name %>: diff --git a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt index b3057f99..b6f153c2 100644 --- a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt @@ -9,9 +9,9 @@ <%%= render @<%= singular_table_name %> %> - <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "mt-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> - <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "mt-2 rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> + <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> +
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "w-full rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
From 3dab6d3a64c9ee8f86f7d3e49fdee14f2c2dcd2f Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Sat, 22 Feb 2025 10:37:57 +0100 Subject: [PATCH 11/37] Explain plugins in readme --- README.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7fa18145..113c5130 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ With some additional manual work the upstream upgrade tool will update your appl /node_modules ``` -**Create** a `package.json` in the root of the project: +**Create** or **update** a `package.json` in the root of the project: ```jsonc { @@ -232,7 +232,9 @@ With some additional manual work the upstream upgrade tool will update your appl Then, once you've run that successfully, clean up: -- **Delete** `package.json`, `node_modules/` and `package-lock.json` (or `yarn.lock`), plus remove `/node_modules` from `.gitignore`. +- **Review** `package.json` to remove unnecessary modules. + - This includes modules added for the period of upgrade. + - If you don't need any modules besides `tailwindcss` itself, **delete** `package.json`, `node_modules/` and `package-lock.json` (or `yarn.lock`), plus remove `/node_modules` from `.gitignore`. - **Go** to your CSS file and remove the following line (if present): ```css @plugin '@tailwindcss/container-queries'; @@ -273,6 +275,30 @@ This gem also makes available a Puma plugin to manage a live rebuild process whe This gem also generates a `Procfile.dev` file which will run both the rails server and a live rebuild process (see "Live Rebuild" section below). +#### Install plugins + +Tailwind plugins can be installed using `package.json`. + +Using Yarn: + +``` sh +[ ! -f package.json ] && yarn init +yarn add daisyui # example +``` + +Using npm: + +``` sh +npm init +npm add daisyui # example +``` + +Than use `@plugin` annotation in `app/assets/tailwind/application.css`: + +``` css +@import "tailwindcss"; +@plugin "daisyui"; +``` ### Building for production From c1e52588114619180790869c571c38f1822bcbe2 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 23 Feb 2025 17:03:02 -0500 Subject: [PATCH 12/37] Bump the "tailwind plugins" section up to H3 and move it to after the basic build/rebuild commands unrelated, rename the upgrade-troubleshooting section to disambiguate from the generate-troubleshooting section. --- README.md | 58 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 113c5130..10c08036 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ - [Upgrading your application from Tailwind v3 to v4](#upgrading-your-application-from-tailwind-v3-to-v4) * [You don't _have_ to upgrade](#you-dont-_have_-to-upgrade) * [Upgrade steps](#upgrade-steps) - * [Troubleshooting](#troubleshooting) + * [Troubleshooting a v4 upgrade](#troubleshooting-a-v4-upgrade) * [Updating CSS class names for v4](#updating-css-class-names-for-v4) - [Developing with Tailwindcss](#developing-with-tailwindcss) * [Configuration and commands](#configuration-and-commands) @@ -20,9 +20,10 @@ * [Building for testing](#building-for-testing) * [Building unminified assets](#building-unminified-assets) * [Live rebuild](#live-rebuild) + * [Using Tailwind plugins](#using-tailwind-plugins) * [Using with PostCSS](#using-with-postcss) * [Custom inputs or outputs](#custom-inputs-or-outputs) -- [Troubleshooting](#troubleshooting-1) +- [Troubleshooting](#troubleshooting) * [Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin](#lost-keystrokes-or-hanging-when-using-terminal-based-debugging-tools-eg-irb-pry-rubydebugetc-with-the-puma-plugin) * [Running in a docker container exits prematurely](#running-in-a-docker-container-exits-prematurely) * [Conflict with sassc-rails](#conflict-with-sassc-rails) @@ -171,7 +172,7 @@ Done in 56ms If this doesn't succeed, it's likely that you've customized your Tailwind configuration and you'll need to do some work to make sure your application upgrades. Please read the [official upgrade guide](https://tailwindcss.com/docs/upgrade-guide) and try following the additional steps in [Updating CSS class names for v4](#updating-css-class-names-for-v4). -### Troubleshooting +### Troubleshooting a v4 upgrade You may want to check out [TailwindCSS v4 - upgrade experience report · rails/tailwindcss-rails · Discussion #450](https://github.com/rails/tailwindcss-rails/discussions/450) if you're having trouble upgrading. @@ -275,31 +276,6 @@ This gem also makes available a Puma plugin to manage a live rebuild process whe This gem also generates a `Procfile.dev` file which will run both the rails server and a live rebuild process (see "Live Rebuild" section below). -#### Install plugins - -Tailwind plugins can be installed using `package.json`. - -Using Yarn: - -``` sh -[ ! -f package.json ] && yarn init -yarn add daisyui # example -``` - -Using npm: - -``` sh -npm init -npm add daisyui # example -``` - -Than use `@plugin` annotation in `app/assets/tailwind/application.css`: - -``` css -@import "tailwindcss"; -@plugin "daisyui"; -``` - ### Building for production The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated. @@ -357,6 +333,32 @@ If you are running `rails tailwindcss:watch` in a docker container without a tty Running `bin/dev` invokes Foreman to start both the Tailwind watch process and the rails server in development mode based on your `Procfile.dev` file. +### Using Tailwind plugins + +If you want to use Tailwind plugins, they can be installed using `package.json`. + +Using Yarn: + +``` sh +[ ! -f package.json ] && yarn init +yarn add daisyui # example +``` + +Using npm: + +``` sh +npm init +npm add daisyui # example +``` + +Than use `@plugin` annotation in `app/assets/tailwind/application.css`: + +``` css +@import "tailwindcss"; +@plugin "daisyui"; +``` + + ### Using with PostCSS If you want to use PostCSS as a preprocessor, create a custom `postcss.config.js` in your project root directory, and that file will be loaded by Tailwind automatically. From 5ecd3a0ce0f0d109cdb22699096bc87ea811277d Mon Sep 17 00:00:00 2001 From: Roberto Date: Tue, 25 Feb 2025 14:28:10 -0300 Subject: [PATCH 13/37] Tailwindcss debug environment variable (#504) * Add TAILWINDCSS_DEBUG environment variable * Update README * ENV var should take precedence over command argument * prefer Hash.key? to !Hash[].nil? --------- Co-authored-by: Mike Dalessio --- README.md | 6 +++++- lib/tailwindcss/commands.rb | 1 + test/lib/tailwindcss/commands_test.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10c08036..f7afe7a8 100644 --- a/README.md +++ b/README.md @@ -288,8 +288,12 @@ The `tailwindcss:build` task is automatically attached to the `test:prepare` Rak ### Building unminified assets -If you want unminified assets, you can pass a `debug` argument to the rake task, i.e. `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`. +If you want unminified assets, you can: +- pass a `debug` argument to the rake task, i.e. `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`. +- set an environment variable named `TAILWINDCSS_DEBUG` with a non-blank value + +If both values are set, the environment variable will take precedence over the rake task argument. ### Live rebuild diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index fb90f4f6..bef42fd2 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -4,6 +4,7 @@ module Tailwindcss module Commands class << self def compile_command(debug: false, **kwargs) + debug = ENV["TAILWINDCSS_DEBUG"].present? if ENV.key?("TAILWINDCSS_DEBUG") rails_root = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd) command = [ diff --git a/test/lib/tailwindcss/commands_test.rb b/test/lib/tailwindcss/commands_test.rb index 3c7e5302..d09481a4 100644 --- a/test/lib/tailwindcss/commands_test.rb +++ b/test/lib/tailwindcss/commands_test.rb @@ -33,6 +33,32 @@ def setup end end + test ".compile_command debug environment variable" do + begin + Rails.stub(:root, File) do # Rails.root won't work in this test suite + ENV["TAILWINDCSS_DEBUG"] = "" + actual = Tailwindcss::Commands.compile_command + assert_kind_of(Array, actual) + assert_includes(actual, "--minify") + + actual = Tailwindcss::Commands.compile_command(debug: true) + assert_kind_of(Array, actual) + assert_includes(actual, "--minify") + + ENV["TAILWINDCSS_DEBUG"] = "any non-blank value" + actual = Tailwindcss::Commands.compile_command + assert_kind_of(Array, actual) + refute_includes(actual, "--minify") + + actual = Tailwindcss::Commands.compile_command(debug: true) + assert_kind_of(Array, actual) + refute_includes(actual, "--minify") + end + ensure + ENV.delete('TAILWINDCSS_DEBUG') + end + end + test ".compile_command when Rails compression is on" do Rails.stub(:root, File) do # Rails.root won't work in this test suite Tailwindcss::Commands.stub(:rails_css_compressor?, true) do From 08486ae14237e7381f3f874e606df1ba432947dc Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 25 Feb 2025 12:28:28 -0500 Subject: [PATCH 14/37] doc: update CHANGELOG for #504 [skip ci] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e75b884b..3d67e9b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## next / unreleased + +### Features + +* Support for environment variable `TAILWINDCSS_DEBUG` to turn off CSS minification. #504 @r-sierra + + ## v4.1.0 / 2025-02-19 ### View template improvements From 0144d00624e2fd3b3058c90877c805b576b4a27a Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 2 Mar 2025 16:47:41 -0500 Subject: [PATCH 15/37] version bump to v4.2.0 --- CHANGELOG.md | 3 ++- lib/tailwindcss/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d67e9b9..9ad013b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # `tailwindcss-rails` Changelog -## next / unreleased +## v4.2.0 / 2025-03-02 ### Features +* Improve the view templates to display better on mobile devices. #503 @patriciomacadden * Support for environment variable `TAILWINDCSS_DEBUG` to turn off CSS minification. #504 @r-sierra diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 7a096603..a172caa0 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.1.0" + VERSION = "4.2.0" end From e670d358212f73340c33b8e3c228394f7a4212e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:44:50 +0000 Subject: [PATCH 16/37] build(deps): bump tailwindcss-ruby from 4.0.7 to 4.0.9 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.7 to 4.0.9. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.7...v4.0.9) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 730f94fb..054f9e8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.3) - tailwindcss-ruby (4.0.7) - tailwindcss-ruby (4.0.7-aarch64-linux-gnu) - tailwindcss-ruby (4.0.7-arm64-darwin) - tailwindcss-ruby (4.0.7-x86_64-darwin) - tailwindcss-ruby (4.0.7-x86_64-linux-gnu) + tailwindcss-ruby (4.0.9) + tailwindcss-ruby (4.0.9-aarch64-linux-gnu) + tailwindcss-ruby (4.0.9-arm64-darwin) + tailwindcss-ruby (4.0.9-x86_64-darwin) + tailwindcss-ruby (4.0.9-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 3fc4b2e26b52325c7bd3437eaf1d1c696fe73f94 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Mar 2025 10:10:09 -0500 Subject: [PATCH 17/37] dep: bundle update --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 054f9e8e..34457850 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.1.0) + tailwindcss-rails (4.2.0) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) @@ -110,7 +110,7 @@ GEM date stringio racc (1.8.1) - rack (3.1.10) + rack (3.1.11) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -139,7 +139,7 @@ GEM reline (0.6.0) io-console (~> 0.5) securerandom (0.4.1) - stringio (3.1.3) + stringio (3.1.5) tailwindcss-ruby (4.0.9) tailwindcss-ruby (4.0.9-aarch64-linux-gnu) tailwindcss-ruby (4.0.9-arm64-darwin) @@ -149,7 +149,7 @@ GEM timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.2) + uri (1.0.3) useragent (0.16.11) zeitwerk (2.7.2) From 14830b75a25271111e61b5d75d71e504527f5f83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:14:17 +0000 Subject: [PATCH 18/37] build(deps): bump tailwindcss-ruby from 4.0.9 to 4.0.12 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.9 to 4.0.12. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.9...v4.0.12) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 34457850..1aa66c0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.9) - tailwindcss-ruby (4.0.9-aarch64-linux-gnu) - tailwindcss-ruby (4.0.9-arm64-darwin) - tailwindcss-ruby (4.0.9-x86_64-darwin) - tailwindcss-ruby (4.0.9-x86_64-linux-gnu) + tailwindcss-ruby (4.0.12) + tailwindcss-ruby (4.0.12-aarch64-linux-gnu) + tailwindcss-ruby (4.0.12-arm64-darwin) + tailwindcss-ruby (4.0.12-x86_64-darwin) + tailwindcss-ruby (4.0.12-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 91a67e904d8b405305c5b59750e8ba0f3b9d39d5 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Mon, 17 Mar 2025 09:37:50 -0300 Subject: [PATCH 19/37] Fix hardcoded attribute in form --- lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt index e50790ce..1821201c 100644 --- a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt @@ -23,7 +23,7 @@ <%%= form.password_field :password_confirmation, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password_confirmation].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password_confirmation].any?}] %> <% elsif attribute.attachments? -%> <%%= form.label :<%= attribute.column_name %> %> - <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password].any?}] %> + <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> <% else -%> <%%= form.label :<%= attribute.column_name %> %> <% if attribute.field_type == :textarea || attribute.field_type == :text_area -%> From 5034ada51e6e31736571e46399d85c97106a0e41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:19:05 +0000 Subject: [PATCH 20/37] build(deps): bump tailwindcss-ruby from 4.0.12 to 4.0.14 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.12 to 4.0.14. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.12...v4.0.14) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1aa66c0f..7480d3ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.12) - tailwindcss-ruby (4.0.12-aarch64-linux-gnu) - tailwindcss-ruby (4.0.12-arm64-darwin) - tailwindcss-ruby (4.0.12-x86_64-darwin) - tailwindcss-ruby (4.0.12-x86_64-linux-gnu) + tailwindcss-ruby (4.0.14) + tailwindcss-ruby (4.0.14-aarch64-linux-gnu) + tailwindcss-ruby (4.0.14-arm64-darwin) + tailwindcss-ruby (4.0.14-x86_64-darwin) + tailwindcss-ruby (4.0.14-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From b70e705e07740be700d7465a3ce684b5188b7748 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:19:14 +0000 Subject: [PATCH 21/37] build(deps): bump railties from 8.0.1 to 8.0.2 Bumps [railties](https://github.com/rails/rails) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.0.2/railties/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v8.0.1...v8.0.2) --- updated-dependencies: - dependency-name: railties dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1aa66c0f..3c305111 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,16 +8,16 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (8.0.1) - actionpack (= 8.0.1) - actionview (= 8.0.1) - activejob (= 8.0.1) - activesupport (= 8.0.1) + actionmailer (8.0.2) + actionpack (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activesupport (= 8.0.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.1) - actionview (= 8.0.1) - activesupport (= 8.0.1) + actionpack (8.0.2) + actionview (= 8.0.2) + activesupport (= 8.0.2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -25,16 +25,16 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actionview (8.0.1) - activesupport (= 8.0.1) + actionview (8.0.2) + activesupport (= 8.0.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.1) - activesupport (= 8.0.1) + activejob (8.0.2) + activesupport (= 8.0.2) globalid (>= 0.3.6) - activesupport (8.0.1) + activesupport (8.0.2) base64 benchmark (>= 0.3) bigdecimal @@ -80,7 +80,7 @@ GEM net-smtp mini_mime (1.1.5) mini_portile2 (2.8.8) - minitest (5.25.4) + minitest (5.25.5) net-imap (0.5.6) date net-protocol @@ -90,18 +90,18 @@ GEM timeout net-smtp (0.5.1) net-protocol - nokogiri (1.18.3) + nokogiri (1.18.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.3-aarch64-linux-gnu) + nokogiri (1.18.4-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm-linux-gnu) + nokogiri (1.18.4-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm64-darwin) + nokogiri (1.18.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-darwin) + nokogiri (1.18.4-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-linux-gnu) + nokogiri (1.18.4-x86_64-linux-gnu) racc (~> 1.4) pp (0.6.2) prettyprint @@ -110,7 +110,7 @@ GEM date stringio racc (1.8.1) - rack (3.1.11) + rack (3.1.12) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -125,9 +125,9 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.1) - actionpack (= 8.0.1) - activesupport (= 8.0.1) + railties (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) From bd57aab639c8ee5202ef7bf5b0fd437f3b05f2f7 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 14:56:10 -0400 Subject: [PATCH 22/37] doc: update CHANGELOG [skip ci] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad013b2..719bc894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## next / unreleased + +### Fixed + +* Fix styles for form errors in some scaffold fields. #513 @patriciomacadden + + ## v4.2.0 / 2025-03-02 ### Features From 84a0d6bf869ade33e450c4b070e5fa7b5d3d7e8a Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Wed, 19 Mar 2025 11:09:43 -0300 Subject: [PATCH 23/37] add accept_confirm if turbo is available so system tests don't fail. fixes #519 --- .../scaffold/scaffold_generator.rb | 1 + .../test_unit/scaffold/scaffold_generator.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 lib/generators/test_unit/scaffold/scaffold_generator.rb diff --git a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb index 39c2da1f..8748210d 100644 --- a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb +++ b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb @@ -1,5 +1,6 @@ require "rails/generators/erb/scaffold/scaffold_generator" require "rails/generators/resource_helpers" +require File.expand_path("../../test_unit/scaffold/scaffold_generator.rb", __dir__) module Tailwindcss module Generators diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb new file mode 100644 index 00000000..b97d74e4 --- /dev/null +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -0,0 +1,19 @@ +require "rails/generators/test_unit/scaffold/scaffold_generator" + +module TestUnit # :nodoc: + module Generators # :nodoc: + class ScaffoldGenerator < Base # :nodoc: + def fix_system_test + if turbo_defined? + gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), "click_on \"Destroy this #{human_name.downcase}\", match: :first", "accept_confirm { click_on \"Destroy this #{human_name.downcase}\", match: :first }" + end + end + + private + + def turbo_defined? + defined?(Turbo) + end + end + end +end From 0653d82770e5c3b5196b882117447213bddd1a03 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:05:49 -0400 Subject: [PATCH 24/37] Make the system test gsub less finicky --- lib/generators/test_unit/scaffold/scaffold_generator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index b97d74e4..ff809b32 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -5,7 +5,9 @@ module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test if turbo_defined? - gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), "click_on \"Destroy this #{human_name.downcase}\", match: :first", "accept_confirm { click_on \"Destroy this #{human_name.downcase}\", match: :first }" + gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), + /(click_on.*Destroy this.*)$/, + "accept_confirm { \\1 }" end end From 37c98c3e95d08c2ddb7f0766222b0840869ef820 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:12:46 -0400 Subject: [PATCH 25/37] Add a simple integration test for the scaffolded system test --- test/integration/user_install_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index 6f4ca301..bfd7a87c 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -63,6 +63,9 @@ fi bin/rails generate scaffold post title:string body:text published:boolean grep -q "Show" app/views/posts/index.html.erb +# TEST: the "accept_confirm" system test change was applied cleanly +grep -q "accept_confirm { click_on \"Destroy this post\"" test/system/posts_test.rb + # TEST: contents of the css file bin/rails tailwindcss:build[verbose] grep -q "py-2" app/assets/builds/tailwind.css From d08ca11298678a4b5128683ab9a3df19d23136d8 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:20:33 -0400 Subject: [PATCH 26/37] version bump to v4.2.1 --- CHANGELOG.md | 3 ++- lib/tailwindcss/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 719bc894..47d080f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # `tailwindcss-rails` Changelog -## next / unreleased +## v4.2.1 / 2025-03-19 ### Fixed * Fix styles for form errors in some scaffold fields. #513 @patriciomacadden +* Update scaffold system tests to handle the "Destroy" confirmation prompt when Turbo is enabled. Fixes #519. #520 @patriciomacadden @flavorjones ## v4.2.0 / 2025-03-02 diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index a172caa0..86e02ae2 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.0" + VERSION = "4.2.1" end From 11e7c3d21739ce1188c080138375a4927d3fe5e6 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Fri, 28 Mar 2025 09:58:15 -0300 Subject: [PATCH 27/37] Simplify markup --- .../tailwindcss/scaffold/templates/index.html.erb.tt | 4 +--- .../tailwindcss/scaffold/templates/show.html.erb.tt | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 848c97fb..12a0db16 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -18,9 +18,7 @@
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> -
+ <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
<%% end %> diff --git a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt index b6f153c2..2b6687d2 100644 --- a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt @@ -11,7 +11,5 @@ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "w-full rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> -
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, form_class: "sm:inline-block mt-2 sm:mt-0 sm:ml-2", class: "w-full rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
From f099ee65f73fefc070a4fa126bfdeb8c6fdcea08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 15:02:14 +0000 Subject: [PATCH 28/37] build(deps): bump tailwindcss-ruby from 4.0.14 to 4.0.17 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.14 to 4.0.17. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.14...v4.0.17) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 459f089e..59dfd05d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.14) - tailwindcss-ruby (4.0.14-aarch64-linux-gnu) - tailwindcss-ruby (4.0.14-arm64-darwin) - tailwindcss-ruby (4.0.14-x86_64-darwin) - tailwindcss-ruby (4.0.14-x86_64-linux-gnu) + tailwindcss-ruby (4.0.17) + tailwindcss-ruby (4.0.17-aarch64-linux-gnu) + tailwindcss-ruby (4.0.17-arm64-darwin) + tailwindcss-ruby (4.0.17-x86_64-darwin) + tailwindcss-ruby (4.0.17-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From b0d41eb5bbcee6c072457f2f06a0720b628ea5ed Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 11:11:08 -0400 Subject: [PATCH 29/37] ci: use the latest @tailwindcss/upgrade package --- README.md | 2 +- lib/install/upgrade_tailwindcss.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7afe7a8..c9982de6 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ $ bin/rails tailwindcss:upgrade remove app/assets/stylesheets/application.tailwind.css 10.9.0 Running the upstream Tailwind CSS upgrader - run npx @tailwindcss/upgrade@next --force --config /home/user/myapp/config/tailwind.config.js from "." + run npx @tailwindcss/upgrade --force --config /home/user/myapp/config/tailwind.config.js from "." ≈ tailwindcss v4.0.0 │ Searching for CSS files in the current directory and its subdirectories… │ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.css` diff --git a/lib/install/upgrade_tailwindcss.rb b/lib/install/upgrade_tailwindcss.rb index 6266583a..004d9a82 100644 --- a/lib/install/upgrade_tailwindcss.rb +++ b/lib/install/upgrade_tailwindcss.rb @@ -46,7 +46,7 @@ if system("npx --version") say "Running the upstream Tailwind CSS upgrader" - command = Shellwords.join(["npx", "@tailwindcss/upgrade@next", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) + command = Shellwords.join(["npx", "@tailwindcss/upgrade", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) success = run(command, abort_on_failure: false) unless success say "The upgrade tool failed!", :red From fd2505954c9a077ae17cee3e55dadd0434272776 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 09:39:13 -0400 Subject: [PATCH 30/37] Improve the state of debugging when things go wrong - The "verbose" flag turns on additional debugging output from tailwindcss - Document the "watchman" problem - Document how to use the "verbose" flag when troubleshooting --- README.md | 35 ++++++++++++++++++++++++++++++++++- lib/tailwindcss/commands.rb | 6 ++++++ lib/tasks/build.rake | 16 ++++++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c9982de6..7188adff 100644 --- a/README.md +++ b/README.md @@ -403,30 +403,63 @@ If you need to use a custom input or output file, you can run `bundle exec tailw ## Troubleshooting -Some common problems experienced by users ... +When having trouble with `tailwindcss:build` or `tailwindcss:watch`, the first thing you should do is collect some diagnostic information by setting the "verbose" flag, which will emit: + +1. the command being run (so you can try running `tailwindcss` yourself without the gem's help) +2. additional debugging output from `tailwindcss` by setting the env var `DEBUG=1` + +Here's what that looks like: + +``` sh +$ bin/rails tailwindcss:build[verbose] + +Running: /path/to/tailwindcss-ruby-4.0.17-x86_64-linux-gnu/exe/x86_64-linux-gnu/tailwindcss -i /home/flavorjones/code/oss/tailwindcss-rails/My Workspace/test-install/app/assets/tailwind/application.css -o /home/flavorjones/code/oss/tailwindcss-rails/My Workspace/test-install/app/assets/builds/tailwind.css --minify +≈ tailwindcss v4.0.17 + +Done in 37ms + +[38.22ms] [@tailwindcss/cli] (initial build) +[11.90ms] ↳ Setup compiler +[ 6.52ms] ↳ Scan for candidates +[10.39ms] ↳ Build CSS +[ 1.69ms] ↳ Optimize CSS +[ 5.80ms] ↳ Write output +``` + +### The `watch` command is hanging + +There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/17246#issuecomment-2753067488) running `tailwindcss -w` (that's the CLI in watch mode) when the utility `watchman` is also installed. + +Please try uninstalling `watchman` and try running the watch task again. + ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin We've addressed the issue and you can avoid the problem by upgrading `tailwindcss-rails` to [v2.4.1](https://github.com/rails/tailwindcss-rails/releases/tag/v2.4.1) or later versions. + ### Running in a docker container exits prematurely If you are running `rails tailwindcss:watch` as a process in a Docker container, set `tty: true` in `docker-compose.yml` for the appropriate container to keep the watch process running. If you are running `rails tailwindcss:watch` in a docker container without a tty, pass the `always` argument to the task to instruct tailwindcss to keep the watcher alive even when `stdin` is closed: `rails tailwindcss:watch[always]`. If you use `bin/dev` then you should modify your `Procfile.dev`. + ### Conflict with sassc-rails Tailwind uses modern CSS features that are not recognized by the `sassc-rails` extension that was included by default in the Gemfile for Rails 6. In order to avoid any errors like `SassC::SyntaxError`, you must remove that gem from your Gemfile. + ### Class names must be spelled out For Tailwind to work, your class names need to be spelled out. If you need to make sure Tailwind generates class names that don't exist in your content files or that are programmatically composed, use the [safelist option](https://tailwindcss.com/docs/content-configuration#safelisting-classes). + ### `ERROR: Cannot find the tailwindcss executable` for supported platform See https://github.com/flavorjones/tailwindcss-ruby for help. + ### Using asset-pipeline assets In Rails, you want to use [assets from the asset pipeline to get fingerprinting](https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls). However, Tailwind isn't aware of those assets. diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index bef42fd2..99ad30e0 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -29,6 +29,12 @@ def watch_command(always: false, poll: false, **kwargs) end end + def command_env(verbose:) + {}.tap do |env| + env["DEBUG"] = "1" if verbose + end + end + def rails_css_compressor? defined?(Rails) && Rails&.application&.config&.assets&.css_compressor.present? end diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index 3044ff05..603c8059 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -2,9 +2,13 @@ namespace :tailwindcss do desc "Build your Tailwind CSS" task build: :environment do |_, args| debug = args.extras.include?("debug") + verbose = args.extras.include?("verbose") + command = Tailwindcss::Commands.compile_command(debug: debug) - puts command.inspect if args.extras.include?("verbose") - system(*command, exception: true) + env = Tailwindcss::Commands.command_env(verbose: verbose) + puts "Running: #{Shellwords.join(command)}" if verbose + + system(env, *command, exception: true) end desc "Watch and build your Tailwind CSS on file changes" @@ -12,9 +16,13 @@ namespace :tailwindcss do debug = args.extras.include?("debug") poll = args.extras.include?("poll") always = args.extras.include?("always") + verbose = args.extras.include?("verbose") + command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll) - puts command.inspect if args.extras.include?("verbose") - system(*command) + env = Tailwindcss::Commands.command_env(verbose: verbose) + puts "Running: #{Shellwords.join(command)}" if verbose + + system(env, *command) rescue Interrupt puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose") end From f722f192de0f4d66d137196fc34e3052e9a3ed6f Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 12:00:19 -0400 Subject: [PATCH 31/37] version bump to v4.2.2 --- CHANGELOG.md | 9 +++++++++ Gemfile.lock | 2 +- lib/tailwindcss/version.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d080f9..e0f90dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # `tailwindcss-rails` Changelog +## v4.2.2 / 2025-04-05 + +### Improved + +* The "tailwindcss:upgrade" task now uses the latest version of the `@tailwindcss/upgrade` tool. #529 @flavorjones +* The "verbose" flag on Rails tasks now emits additional tailwind CLI debugging info (e.g., `bin/rails tailwindcss:build[verbose]`). #530 @flavorjones +* Simplified the scaffold templates, removing unnecessary `div` tags. @523 @patriciomacadden + + ## v4.2.1 / 2025-03-19 ### Fixed diff --git a/Gemfile.lock b/Gemfile.lock index 59dfd05d..08ddee5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.2.0) + tailwindcss-rails (4.2.2) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 86e02ae2..8a0f50d8 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.1" + VERSION = "4.2.2" end From fa9e2caafb7d1258aef576889568600a06e53299 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 15:30:10 +0000 Subject: [PATCH 32/37] build(deps): bump tailwindcss-ruby from 4.0.17 to 4.1.4 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.17 to 4.1.4. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.17...v4.1.4) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 08ddee5a..ec551873 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.17) - tailwindcss-ruby (4.0.17-aarch64-linux-gnu) - tailwindcss-ruby (4.0.17-arm64-darwin) - tailwindcss-ruby (4.0.17-x86_64-darwin) - tailwindcss-ruby (4.0.17-x86_64-linux-gnu) + tailwindcss-ruby (4.1.4) + tailwindcss-ruby (4.1.4-aarch64-linux-gnu) + tailwindcss-ruby (4.1.4-arm64-darwin) + tailwindcss-ruby (4.1.4-x86_64-darwin) + tailwindcss-ruby (4.1.4-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 9c7179008b9c2db11a7908036b06f63dceeeb6db Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 2 May 2025 16:21:52 -0400 Subject: [PATCH 33/37] Pin the npm upgrade task to @tailwindcss/upgrade@4.1.4 because the 4.1.5 upgrade tool introduced a dependency on tailwind that I can't figure out how to resolve. Gah, this entire experience has been entirely frustrating as a downstream maintainer, FML --- README.md | 4 ++-- lib/install/upgrade_tailwindcss.rb | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7188adff..158b1750 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Then, run `bin/rails tailwindcss:upgrade`. Among other things, this will try to - If present, moves `app/assets/stylesheets/application.tailwind.css` to `app/assets/tailwind/application.css`. - Removes unnecessary `stylesheet_link_tag "tailwindcss"` tags from the application layout. - Removes references to the Inter font from the application layout. -- Runs the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended). +- Runs v4.1.4 of the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended). @@ -145,7 +145,7 @@ $ bin/rails tailwindcss:upgrade remove app/assets/stylesheets/application.tailwind.css 10.9.0 Running the upstream Tailwind CSS upgrader - run npx @tailwindcss/upgrade --force --config /home/user/myapp/config/tailwind.config.js from "." + run npx @tailwindcss/upgrade@4.1.4 --force --config /home/user/myapp/config/tailwind.config.js from "." ≈ tailwindcss v4.0.0 │ Searching for CSS files in the current directory and its subdirectories… │ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.css` diff --git a/lib/install/upgrade_tailwindcss.rb b/lib/install/upgrade_tailwindcss.rb index 004d9a82..d6ecadab 100644 --- a/lib/install/upgrade_tailwindcss.rb +++ b/lib/install/upgrade_tailwindcss.rb @@ -45,8 +45,14 @@ end if system("npx --version") + # We're pinning to v4.1.4 because v4.1.5 of the upgrade tool introduces a dependency version check + # on tailwind and I haven't been able to figure out how to get that to work reliably and I am + # extremely frustrated with the whole thing. See #544 + # + # At some point we will probably need to unpin this at which point I am sincerely hoping that + # someone else will do it. say "Running the upstream Tailwind CSS upgrader" - command = Shellwords.join(["npx", "@tailwindcss/upgrade", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) + command = Shellwords.join(["npx", "@tailwindcss/upgrade@4.1.4", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) success = run(command, abort_on_failure: false) unless success say "The upgrade tool failed!", :red From 114fca5b4e235dd9cb14f54161f75032fd247681 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 2 May 2025 16:45:32 -0400 Subject: [PATCH 34/37] version bump to v4.2.3 --- CHANGELOG.md | 7 +++++++ lib/tailwindcss/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f90dac..d662d7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## v4.2.3 / 2025-05-02 + +### Improved + +* The "tailwindcss:upgrade" task now pins to v4.1.4 of the `@tailwindcss/upgrade` tool. #544 @flavorjones + + ## v4.2.2 / 2025-04-05 ### Improved diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 8a0f50d8..7ab2db8d 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.2" + VERSION = "4.2.3" end From 3f6d06d0981435c5cdd37951925e31fe70c6870e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 15:12:32 +0000 Subject: [PATCH 35/37] build(deps): bump tailwindcss-ruby from 4.1.4 to 4.1.5 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.4 to 4.1.5. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.4...v4.1.5) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ec551873..bb16d405 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.4) - tailwindcss-ruby (4.1.4-aarch64-linux-gnu) - tailwindcss-ruby (4.1.4-arm64-darwin) - tailwindcss-ruby (4.1.4-x86_64-darwin) - tailwindcss-ruby (4.1.4-x86_64-linux-gnu) + tailwindcss-ruby (4.1.5) + tailwindcss-ruby (4.1.5-aarch64-linux-gnu) + tailwindcss-ruby (4.1.5-arm64-darwin) + tailwindcss-ruby (4.1.5-x86_64-darwin) + tailwindcss-ruby (4.1.5-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 9d0a9f5e81aac890cbc6476f49515d9d45dc8abe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 14:17:03 +0000 Subject: [PATCH 36/37] build(deps): bump tailwindcss-ruby from 4.1.5 to 4.1.6 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.5 to 4.1.6. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.5...v4.1.6) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bb16d405..f84bada9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.5) - tailwindcss-ruby (4.1.5-aarch64-linux-gnu) - tailwindcss-ruby (4.1.5-arm64-darwin) - tailwindcss-ruby (4.1.5-x86_64-darwin) - tailwindcss-ruby (4.1.5-x86_64-linux-gnu) + tailwindcss-ruby (4.1.6) + tailwindcss-ruby (4.1.6-aarch64-linux-gnu) + tailwindcss-ruby (4.1.6-arm64-darwin) + tailwindcss-ruby (4.1.6-x86_64-darwin) + tailwindcss-ruby (4.1.6-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 401b00b61c78c7dd7dfe33142d9a6660b8f4546c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 14:16:45 +0000 Subject: [PATCH 37/37] build(deps): bump tailwindcss-ruby from 4.1.6 to 4.1.7 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.6...v4.1.7) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f84bada9..9b0500db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.6) - tailwindcss-ruby (4.1.6-aarch64-linux-gnu) - tailwindcss-ruby (4.1.6-arm64-darwin) - tailwindcss-ruby (4.1.6-x86_64-darwin) - tailwindcss-ruby (4.1.6-x86_64-linux-gnu) + tailwindcss-ruby (4.1.7) + tailwindcss-ruby (4.1.7-aarch64-linux-gnu) + tailwindcss-ruby (4.1.7-arm64-darwin) + tailwindcss-ruby (4.1.7-x86_64-darwin) + tailwindcss-ruby (4.1.7-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6)