├── .gitignore ├── Gemfile ├── Gemfile.lock ├── MIT-LICENSE ├── README.md ├── Rakefile ├── bin ├── release └── test ├── lib ├── generators │ └── tailwindcss │ │ ├── controller │ │ ├── controller_generator.rb │ │ └── templates │ │ │ └── view.html.erb.tt │ │ └── scaffold │ │ ├── scaffold_generator.rb │ │ └── templates │ │ ├── _form.html.erb.tt │ │ ├── edit.html.erb.tt │ │ ├── index.html.erb.tt │ │ ├── new.html.erb.tt │ │ ├── partial.html.erb.tt │ │ └── show.html.erb.tt ├── install │ ├── stylesheets │ │ ├── application.scss │ │ └── tailwind.config.js │ └── tailwindcss.rb ├── tailwindcss-rails-webpacker.rb ├── tailwindcss │ ├── engine.rb │ └── version.rb └── tasks │ └── tailwindcss_tasks.rake ├── tailwindcss-rails-webpacker.gemspec └── test ├── lib └── generators │ └── tailwindcss │ ├── controller_generator_test.rb │ └── scaffold_generator_test.rb ├── tailwindcss └── rails │ └── webpacker_test.rb └── test_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /doc/ 3 | /log/*.log 4 | /pkg/ 5 | /tmp/ 6 | /test/dummy/db/*.sqlite3 7 | /test/dummy/db/*.sqlite3-* 8 | /test/dummy/log/*.log 9 | /test/dummy/storage/ 10 | /test/dummy/tmp/ 11 | /node_modules 12 | .byebug_history 13 | *.gem 14 | .idea/ 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | gemspec 5 | 6 | gem 'byebug' 7 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | tailwindcss-rails-webpacker (0.2.1) 5 | rails (>= 6.0.0) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | actioncable (6.1.4.1) 11 | actionpack (= 6.1.4.1) 12 | activesupport (= 6.1.4.1) 13 | nio4r (~> 2.0) 14 | websocket-driver (>= 0.6.1) 15 | actionmailbox (6.1.4.1) 16 | actionpack (= 6.1.4.1) 17 | activejob (= 6.1.4.1) 18 | activerecord (= 6.1.4.1) 19 | activestorage (= 6.1.4.1) 20 | activesupport (= 6.1.4.1) 21 | mail (>= 2.7.1) 22 | actionmailer (6.1.4.1) 23 | actionpack (= 6.1.4.1) 24 | actionview (= 6.1.4.1) 25 | activejob (= 6.1.4.1) 26 | activesupport (= 6.1.4.1) 27 | mail (~> 2.5, >= 2.5.4) 28 | rails-dom-testing (~> 2.0) 29 | actionpack (6.1.4.1) 30 | actionview (= 6.1.4.1) 31 | activesupport (= 6.1.4.1) 32 | rack (~> 2.0, >= 2.0.9) 33 | rack-test (>= 0.6.3) 34 | rails-dom-testing (~> 2.0) 35 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 36 | actiontext (6.1.4.1) 37 | actionpack (= 6.1.4.1) 38 | activerecord (= 6.1.4.1) 39 | activestorage (= 6.1.4.1) 40 | activesupport (= 6.1.4.1) 41 | nokogiri (>= 1.8.5) 42 | actionview (6.1.4.1) 43 | activesupport (= 6.1.4.1) 44 | builder (~> 3.1) 45 | erubi (~> 1.4) 46 | rails-dom-testing (~> 2.0) 47 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 48 | activejob (6.1.4.1) 49 | activesupport (= 6.1.4.1) 50 | globalid (>= 0.3.6) 51 | activemodel (6.1.4.1) 52 | activesupport (= 6.1.4.1) 53 | activerecord (6.1.4.1) 54 | activemodel (= 6.1.4.1) 55 | activesupport (= 6.1.4.1) 56 | activestorage (6.1.4.1) 57 | actionpack (= 6.1.4.1) 58 | activejob (= 6.1.4.1) 59 | activerecord (= 6.1.4.1) 60 | activesupport (= 6.1.4.1) 61 | marcel (~> 1.0.0) 62 | mini_mime (>= 1.1.0) 63 | activesupport (6.1.4.1) 64 | concurrent-ruby (~> 1.0, >= 1.0.2) 65 | i18n (>= 1.6, < 2) 66 | minitest (>= 5.1) 67 | tzinfo (~> 2.0) 68 | zeitwerk (~> 2.3) 69 | builder (3.2.4) 70 | byebug (11.1.3) 71 | concurrent-ruby (1.1.9) 72 | crass (1.0.6) 73 | erubi (1.10.0) 74 | globalid (0.5.2) 75 | activesupport (>= 5.0) 76 | i18n (1.8.10) 77 | concurrent-ruby (~> 1.0) 78 | loofah (2.12.0) 79 | crass (~> 1.0.2) 80 | nokogiri (>= 1.5.9) 81 | mail (2.7.1) 82 | mini_mime (>= 0.1.1) 83 | marcel (1.0.2) 84 | method_source (1.0.0) 85 | mini_mime (1.1.1) 86 | mini_portile2 (2.6.1) 87 | minitest (5.14.4) 88 | nio4r (2.5.8) 89 | nokogiri (1.12.5) 90 | mini_portile2 (~> 2.6.1) 91 | racc (~> 1.4) 92 | racc (1.5.2) 93 | rack (2.2.3) 94 | rack-test (1.1.0) 95 | rack (>= 1.0, < 3) 96 | rails (6.1.4.1) 97 | actioncable (= 6.1.4.1) 98 | actionmailbox (= 6.1.4.1) 99 | actionmailer (= 6.1.4.1) 100 | actionpack (= 6.1.4.1) 101 | actiontext (= 6.1.4.1) 102 | actionview (= 6.1.4.1) 103 | activejob (= 6.1.4.1) 104 | activemodel (= 6.1.4.1) 105 | activerecord (= 6.1.4.1) 106 | activestorage (= 6.1.4.1) 107 | activesupport (= 6.1.4.1) 108 | bundler (>= 1.15.0) 109 | railties (= 6.1.4.1) 110 | sprockets-rails (>= 2.0.0) 111 | rails-dom-testing (2.0.3) 112 | activesupport (>= 4.2.0) 113 | nokogiri (>= 1.6) 114 | rails-html-sanitizer (1.4.2) 115 | loofah (~> 2.3) 116 | railties (6.1.4.1) 117 | actionpack (= 6.1.4.1) 118 | activesupport (= 6.1.4.1) 119 | method_source 120 | rake (>= 0.13) 121 | thor (~> 1.0) 122 | rake (13.0.6) 123 | sprockets (4.0.2) 124 | concurrent-ruby (~> 1.0) 125 | rack (> 1, < 3) 126 | sprockets-rails (3.2.2) 127 | actionpack (>= 4.0) 128 | activesupport (>= 4.0) 129 | sprockets (>= 3.0.0) 130 | thor (1.1.0) 131 | tzinfo (2.0.4) 132 | concurrent-ruby (~> 1.0) 133 | websocket-driver (0.7.5) 134 | websocket-extensions (>= 0.1.0) 135 | websocket-extensions (0.1.5) 136 | zeitwerk (2.4.2) 137 | 138 | PLATFORMS 139 | ruby 140 | 141 | DEPENDENCIES 142 | byebug 143 | tailwindcss-rails-webpacker! 144 | 145 | BUNDLED WITH 146 | 2.1.4 147 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Dino Maric 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tailwind CSS for Rails webpacker 2 | 3 | [Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup. 4 | 5 | This gem gives access to the standard Tailwind CSS framework configured for Rails webpacker. 6 | 7 | This is extraction originally created inside the [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) gem. 8 | 9 | Gem overrides default Rails scaffold generators in favour of Tailwind 10 | designed templates by Adam Wathan and the Tailwind team. 11 | 12 | 13 | ## Installation 14 | 15 | 1. Run `./bin/bundle add tailwindcss-rails-webpacker` 16 | 2. Run `./bin/rails tailwindcss:install` 17 | 18 | 19 | ## Purging in production 20 | 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. 22 | 23 | This gem will automatically purge those unused classes in production. 24 | 25 | ## License 26 | 27 | Tailwind for Rails Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT). 28 | Tailwind CSS is released under the [MIT License](https://opensource.org/licenses/MIT). 29 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | 3 | require "bundler/gem_tasks" 4 | 5 | require "rake/testtask" 6 | 7 | Rake::TestTask.new(:test) do |t| 8 | t.libs << 'test' 9 | t.pattern = 'test/**/*_test.rb' 10 | t.verbose = false 11 | end 12 | 13 | task default: :test 14 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=$1 4 | 5 | printf "module Tailwindcss\n VERSION = \"$VERSION\"\nend\n" > ./lib/tailwindcss/version.rb 6 | bundle 7 | git add Gemfile.lock lib/tailwindcss/version.rb 8 | git commit -m "Bump version for $VERSION" 9 | git push 10 | git tag v$VERSION 11 | git push --tags 12 | gem build tailwindcss-rails-webpacker.gemspec 13 | gem push "tailwindcss-rails-webpacker-$VERSION.gem" -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $: << File.expand_path("../test", __dir__) 3 | 4 | require "bundler/setup" 5 | require "rails/plugin/test" 6 | -------------------------------------------------------------------------------- /lib/generators/tailwindcss/controller/controller_generator.rb: -------------------------------------------------------------------------------- 1 | require "rails/generators/erb/controller/controller_generator" 2 | 3 | module Tailwindcss 4 | module Generators 5 | class ControllerGenerator < Erb::Generators::ControllerGenerator 6 | source_root File.expand_path("../templates", __FILE__) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/generators/tailwindcss/controller/templates/view.html.erb.tt: -------------------------------------------------------------------------------- 1 |
Find me in <%= @path %>
4 |<%%= notice %>
4 | <%% end %> 5 | 6 |4 | <%= attribute.human_name %>: 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 |
<%%= notice %>
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 |