Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Tailwind CSS #5

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml

/app/assets/builds/*
!/app/assets/builds/.keep
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"tailwindCSS.includeLanguages": {
"javascript": "javascript",
"html": "html",
"erb": "html"
},
"tailwindCSS.emmetCompletions": true,
"files.associations": {
"*.html.erb": "erb"
},
"emmet.includeLanguages": {
"html.erb": "html",
"erb": "html"
}
}
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ gem "kaminari", "1.2.2"
# Cron based periodical jobs
gem "whenever", "1.0.0", require: false

# Tailwind CSS framework
gem "tailwindcss-rails", "2.0.21"

group :development, :test do
# fake data for development and testing
gem "faker", "3.1.0"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ GEM
sprockets (>= 3.0.0)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
tailwindcss-rails (2.0.21-aarch64-linux)
railties (>= 6.0.0)
thor (1.2.1)
timeout (0.3.1)
turbo-rails (1.3.2)
Expand Down Expand Up @@ -332,6 +334,7 @@ DEPENDENCIES
sidekiq (= 7.0.2)
sprockets-rails (= 3.4.2)
stimulus-rails (= 1.2.1)
tailwindcss-rails (= 2.0.21)
turbo-rails (= 1.3.2)
tzinfo-data
web-console (= 4.2.0)
Expand Down
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bin/rails server -p 3000
css: bin/rails tailwindcss:watch
Empty file added app/assets/builds/.keep
Empty file.
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../builds
13 changes: 13 additions & 0 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

/*
@layer components {
.btn-primary {
@apply py-2 px-4 bg-blue-200;
}
}
*/
15 changes: 15 additions & 0 deletions app/views/demo/_tailwind.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<section class="section-function">
<h2 class="header-section">Tailwind CSS Framework</h2>

<div class="section-description">
<p>The content below is made with using Tailwind CSS</p>
</div>

<!--
1. https://spaquet.medium.com/tailwind-css-autocomplete-in-vscode-with-ruby-on-rails-63a5fc24a1a4
2. https://tailwindcss.com/docs/border-width
-->
<h1 class="mt-4 mb-4 ml-0 mr-0 p-5 font-serif text-4xl text-red-500 border-8 border-cyan-500">
Hello world!!
</h1>
</section>
1 change: 1 addition & 0 deletions app/views/demo/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
<%= render partial: 'found_articles', locals: { articles: @found_articles, term: @search_query } %>
<%= render partial: 'articles_without_caching', locals: { articles: @articles } %>
<%= render partial: 'articles_with_caching', locals: { articles: @articles } %>
<%= render partial: 'tailwind' %>
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
Expand Down
8 changes: 8 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

if ! gem list foreman -i --silent; then
echo "Installing foreman..."
gem install foreman
fi

exec foreman start -f Procfile.dev "$@"
7 changes: 7 additions & 0 deletions bin/helpers/tailwind.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def tailwind_start
container_bash_exec('rails', 'bin/rails tailwindcss:watch', detached = true)
end

def tailwind_stop
container_bash_exec('rails', 'pkill -9 -f tailwindcss', detached = true)
end
4 changes: 4 additions & 0 deletions bin/start
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ rails_install_gems
rails_db_migrate

cron_start
puma_start
sidekiq_start
tailwind_start

chewy_index

sidekiq_start
Expand Down
3 changes: 3 additions & 0 deletions bin/stop
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ require_relative "./helpers/helpers.rb"
puma_stop
cron_stop
sidekiq_stop
tailwind_stop

containers_information
22 changes: 22 additions & 0 deletions config/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
content: [
'./public/*.html',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.{erb,haml,html,slim}'
],
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/aspect-ratio'),
require('@tailwindcss/typography'),
]
}