-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
2,718 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
web: bin/rails server --port 3200 | ||
css: bin/rails app:tailwindcss:watch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env sh | ||
|
||
if ! gem list foreman -i --silent; then | ||
echo "Installing foreman..." | ||
gem install foreman | ||
fi | ||
|
||
# Default to port 3000 if not specified | ||
export PORT="${PORT:-3000}" | ||
|
||
# Let the debug gem allow remote connections, | ||
# but avoid loading until `debugger` is called | ||
export RUBY_DEBUG_OPEN="true" | ||
export RUBY_DEBUG_LAZY="true" | ||
|
||
exec foreman start -f Procfile.dev "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# frozen_string_literal: true | ||
|
||
module TurboMaterial | ||
class InstallGenerator < Rails::Generators::Base | ||
source_root File.expand_path('../templates', __FILE__) | ||
|
||
START_MARKER = "// #{Engine.name} raw CSS. This section is auto-generated by the turbo_material installer.".freeze | ||
END_MARKER = "// End of auto-generated #{Engine.name} raw CSS. Version:".freeze | ||
HEAD_LINKS = <<-HTML.rstrip.freeze | ||
<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet"> | ||
<script src="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.js"></script> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | ||
HTML | ||
|
||
def update_tailwind_config | ||
tailwind_css_path = TurboMaterial::Engine.root.join('app/assets/dist/turbo_material/tailwind.css') | ||
css_content = File.read(tailwind_css_path) | ||
css_content.gsub!(/\/\*.*?\*\//m, '') | ||
css_content.gsub!(/\{[^}]*}/m, '{}') | ||
css_content.gsub!(/\\\[/, '[') | ||
css_content.gsub!( /\\\]/, ']') | ||
|
||
class_regex = /\.\\?(!?[-_a-zA-Z0-9\[\]]+)(?=[^}]*\{)/ | ||
classes = css_content.scan(class_regex).flatten.uniq.sort | ||
|
||
tailwind_config_path = Rails.root.join('config/tailwind.config.js') | ||
|
||
if tailwind_config_path.exist? | ||
content_config = <<~CONFIG.strip_heredoc | ||
#{START_MARKER} | ||
{ raw: '<div class="#{classes.join(' ')}"></div>', extension: 'html' }, | ||
#{END_MARKER} #{TurboMaterial::VERSION} | ||
CONFIG | ||
|
||
if File.read(tailwind_config_path.to_s).include?(START_MARKER) | ||
gsub_file tailwind_config_path, /#{Regexp.escape(START_MARKER)}.*?#{Regexp.escape(END_MARKER)}.*?$/m do |match| | ||
content_config.strip | ||
end | ||
else | ||
insert_into_file tailwind_config_path, after: "content: [" do | ||
"\n" + content_config.strip | ||
end | ||
end | ||
end | ||
end | ||
|
||
def add_turbo_material_js_controllers | ||
controllers_path = Rails.root.join('app/javascript/controllers/index.js') | ||
if controllers_path.exist? && controllers_path.read.include?('eagerLoadControllersFrom("controllers", application)') | ||
if controllers_path.read.include?('eagerLoadControllersFrom("turbo_material", application)') | ||
puts "`app/javascript/controllers/index.js` already contains `eagerLoadControllersFrom(\"turbo_material\", application)`" | ||
else | ||
insert_into_file controllers_path, after: 'eagerLoadControllersFrom("controllers", application)' do | ||
"\neagerLoadControllersFrom(\"turbo_material\", application)\n" | ||
end | ||
end | ||
else | ||
puts "`app/javascript/controllers/index.js` does not exist or does not contain `eagerLoadControllersFrom(\"controllers\", application)`" | ||
end | ||
end | ||
|
||
def add_material_components_web_to_app_layout | ||
layout_path = Rails.root.join('app/views/layouts/application.html.erb') | ||
if layout_path.exist? && layout_path.read.include?('<%= csp_meta_tag %>') | ||
if layout_path.read.include?('<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">') | ||
puts "`app/views/layouts/application.html.erb` head already contains material components web links" | ||
else | ||
insert_into_file layout_path, after: '<%= csp_meta_tag %>' do | ||
HEAD_LINKS | ||
end | ||
end | ||
else | ||
raise "`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`" | ||
end | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :turbo_material do | ||
desc 'Installs TurboMaterial' | ||
task install: :environment do | ||
Rails::Command.invoke :generate, ['turbo_material:install'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
require "turbo_material/version" | ||
require "turbo_material/engine" | ||
require "turbo_material/configuration" | ||
|
||
module TurboMaterial | ||
# Your code goes here... | ||
class << self | ||
attr_accessor :configuration | ||
end | ||
|
||
def self.configuration | ||
@configuration ||= Configuration.new | ||
end | ||
|
||
def self.configure | ||
yield(configuration) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module TurboMaterial | ||
class Configuration | ||
|
||
def initialize | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module TurboMaterial | ||
VERSION = "0.2.16" | ||
VERSION = "0.2.17" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
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], | ||
}, | ||
content: [ | ||
// TurboMaterial::Engine raw CSS. This section is auto-generated by the turbo_material installer. | ||
{ raw: '<div class="!flex-row !flex-wrap !grow !grow-0 !h-fit !h-full !h-max !hidden !max-h-0 !min-h-[14rem] !min-w-[36rem] !pt-8 !relative !text-white !top-6 !w-fit !w-full block capitalize fixed flex flex-col flex-row font-sans grid hidden items-center items-start justify-between max-h-64 max-w-prose mdc-notched-outline__leading mdc-notched-outline__notch mdc-notched-outline__trailing mx-auto overflow-y-auto p-2 pl-2 prose prose-2xl prose-amber prose-base prose-blue prose-cyan prose-emerald prose-fuchsia prose-gray prose-green prose-indigo prose-invert prose-lg prose-lime prose-neutral prose-orange prose-pink prose-purple prose-red prose-rose prose-sky prose-slate prose-sm prose-stone prose-teal prose-violet prose-xl prose-yellow prose-zinc px-6 py-3 rounded-none static table text-red-500 text-sm text-xs w-full"></div>', extension: 'html' }, | ||
// End of auto-generated TurboMaterial::Engine raw CSS. Version: 0.2.16 | ||
'./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/aspect-ratio'), | ||
require('@tailwindcss/typography'), | ||
require('@tailwindcss/container-queries'), | ||
] | ||
plugins: [ | ||
require('@tailwindcss/aspect-ratio'), | ||
require('@tailwindcss/typography'), | ||
require('@tailwindcss/container-queries'), | ||
] | ||
} |