turbo_material 0.2.16 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/assets/dist/turbo_material/tailwind.css +2552 -1
- data/config/tailwind.config.js +17 -15
- data/lib/generators/turbo_material/install_generator.rb +79 -0
- data/lib/tasks/install.rake +8 -0
- data/lib/turbo_material/configuration.rb +7 -0
- data/lib/turbo_material/version.rb +1 -1
- data/lib/turbo_material.rb +12 -1
- metadata +5 -2
data/config/tailwind.config.js
CHANGED
@@ -6,20 +6,22 @@ module.exports = {
|
|
6
6
|
pattern: /prose/,
|
7
7
|
},
|
8
8
|
],
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
content: [
|
10
|
+
'./public/*.html',
|
11
|
+
'./app/helpers/**/*.rb',
|
12
|
+
'./app/assets/javascript/**/*.js',
|
13
|
+
'./app/views/**/*.{erb,haml,html,slim}'
|
14
|
+
],
|
15
|
+
theme: {
|
16
|
+
extend: {
|
17
|
+
fontFamily: {
|
18
|
+
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
|
19
|
+
},
|
19
20
|
},
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
},
|
22
|
+
plugins: [
|
23
|
+
require('@tailwindcss/aspect-ratio'),
|
24
|
+
require('@tailwindcss/typography'),
|
25
|
+
require('@tailwindcss/container-queries'),
|
26
|
+
]
|
25
27
|
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TurboMaterial
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
START_MARKER = "// #{Engine.name} raw CSS. This section is auto-generated by the turbo_material installer.".freeze
|
8
|
+
END_MARKER = "// End of auto-generated #{Engine.name} raw CSS. Version:".freeze
|
9
|
+
HEAD_LINKS = <<-HTML.rstrip.freeze
|
10
|
+
|
11
|
+
|
12
|
+
<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">
|
13
|
+
<script src="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.js"></script>
|
14
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
15
|
+
HTML
|
16
|
+
|
17
|
+
def update_tailwind_config
|
18
|
+
tailwind_css_path = TurboMaterial::Engine.root.join('app/assets/dist/turbo_material/tailwind.css')
|
19
|
+
css_content = File.read(tailwind_css_path)
|
20
|
+
css_content.gsub!(/\/\*.*?\*\//m, '')
|
21
|
+
css_content.gsub!(/\{[^}]*}/m, '{}')
|
22
|
+
css_content.gsub!(/\\\[/, '[')
|
23
|
+
css_content.gsub!( /\\\]/, ']')
|
24
|
+
|
25
|
+
class_regex = /\.\\?(!?[-_a-zA-Z0-9\[\]]+)(?=[^}]*\{)/
|
26
|
+
classes = css_content.scan(class_regex).flatten.uniq.sort
|
27
|
+
|
28
|
+
tailwind_config_path = Rails.root.join('config/tailwind.config.js')
|
29
|
+
|
30
|
+
if tailwind_config_path.exist?
|
31
|
+
content_config = <<~CONFIG.strip_heredoc
|
32
|
+
#{START_MARKER}
|
33
|
+
{ raw: '<div class="#{classes.join(' ')}"></div>', extension: 'html' },
|
34
|
+
#{END_MARKER} #{TurboMaterial::VERSION}
|
35
|
+
CONFIG
|
36
|
+
|
37
|
+
if File.read(tailwind_config_path.to_s).include?(START_MARKER)
|
38
|
+
gsub_file tailwind_config_path, /#{Regexp.escape(START_MARKER)}.*?#{Regexp.escape(END_MARKER)}.*?$/m do |match|
|
39
|
+
content_config.strip
|
40
|
+
end
|
41
|
+
else
|
42
|
+
insert_into_file tailwind_config_path, after: "content: [" do
|
43
|
+
"\n" + content_config.strip
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_turbo_material_js_controllers
|
50
|
+
controllers_path = Rails.root.join('app/javascript/controllers/index.js')
|
51
|
+
if controllers_path.exist? && controllers_path.read.include?('eagerLoadControllersFrom("controllers", application)')
|
52
|
+
if controllers_path.read.include?('eagerLoadControllersFrom("turbo_material", application)')
|
53
|
+
puts "`app/javascript/controllers/index.js` already contains `eagerLoadControllersFrom(\"turbo_material\", application)`"
|
54
|
+
else
|
55
|
+
insert_into_file controllers_path, after: 'eagerLoadControllersFrom("controllers", application)' do
|
56
|
+
"\neagerLoadControllersFrom(\"turbo_material\", application)\n"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
puts "`app/javascript/controllers/index.js` does not exist or does not contain `eagerLoadControllersFrom(\"controllers\", application)`"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_material_components_web_to_app_layout
|
65
|
+
layout_path = Rails.root.join('app/views/layouts/application.html.erb')
|
66
|
+
if layout_path.exist? && layout_path.read.include?('<%= csp_meta_tag %>')
|
67
|
+
if layout_path.read.include?('<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">')
|
68
|
+
puts "`app/views/layouts/application.html.erb` head already contains material components web links"
|
69
|
+
else
|
70
|
+
insert_into_file layout_path, after: '<%= csp_meta_tag %>' do
|
71
|
+
HEAD_LINKS
|
72
|
+
end
|
73
|
+
end
|
74
|
+
else
|
75
|
+
raise "`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/turbo_material.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require "turbo_material/version"
|
2
2
|
require "turbo_material/engine"
|
3
|
+
require "turbo_material/configuration"
|
3
4
|
|
4
5
|
module TurboMaterial
|
5
|
-
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configuration
|
11
|
+
@configuration ||= Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield(configuration)
|
16
|
+
end
|
6
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_material
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Moiseev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- config/importmap.rb
|
156
156
|
- config/routes.rb
|
157
157
|
- config/tailwind.config.js
|
158
|
+
- lib/generators/turbo_material/install_generator.rb
|
158
159
|
- lib/lookbook/checkbox_preview.rb
|
159
160
|
- lib/lookbook/chips_input_preview.rb
|
160
161
|
- lib/lookbook/chips_select_preview.rb
|
@@ -165,8 +166,10 @@ files:
|
|
165
166
|
- lib/lookbook/select_preview.rb
|
166
167
|
- lib/lookbook/switch_preview.rb
|
167
168
|
- lib/lookbook/textarea_preview.rb
|
169
|
+
- lib/tasks/install.rake
|
168
170
|
- lib/tasks/turbo_material_tasks.rake
|
169
171
|
- lib/turbo_material.rb
|
172
|
+
- lib/turbo_material/configuration.rb
|
170
173
|
- lib/turbo_material/engine.rb
|
171
174
|
- lib/turbo_material/version.rb
|
172
175
|
homepage: https://github.com/full-stack-biz/turbo_material
|