turbo_material 0.2.16 → 0.2.18

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.
@@ -6,20 +6,22 @@ module.exports = {
6
6
  pattern: /prose/,
7
7
  },
8
8
  ],
9
- content: [
10
- './app/assets/stylesheets/**/*.css',
11
- './app/views/**/*.html.erb'
12
- ],
13
- theme: {
14
- extend: {
15
- fontFamily: {
16
- sans: ['Inter var', ...defaultTheme.fontFamily.sans],
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
- plugins: [
21
- require('@tailwindcss/aspect-ratio'),
22
- require('@tailwindcss/typography'),
23
- require('@tailwindcss/container-queries'),
24
- ]
21
+ },
22
+ plugins: [
23
+ require('@tailwindcss/aspect-ratio'),
24
+ require('@tailwindcss/typography'),
25
+ require('@tailwindcss/container-queries'),
26
+ ]
25
27
  }
@@ -0,0 +1,82 @@
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!('>:not([hidden])~:not([hidden])', '')
23
+ css_content.gsub!(/\\\[/, '[')
24
+ css_content.gsub!( /\\\]/, ']')
25
+ css_content.gsub!( /\\\//, '/')
26
+ css_content.gsub!( /\\:/, ':')
27
+
28
+ class_regex = /\.\\?(!?[-_a-zA-Z0-9\[\]\/:]+)(?=[^}]*\{)/
29
+ classes = css_content.scan(class_regex).flatten.uniq.sort
30
+
31
+ tailwind_config_path = Rails.root.join('config/tailwind.config.js')
32
+
33
+ if tailwind_config_path.exist?
34
+ content_config = <<~CONFIG.strip_heredoc
35
+ #{START_MARKER}
36
+ { raw: '<div class="#{classes.join(' ')}"></div>', extension: 'html' },
37
+ #{END_MARKER} #{TurboMaterial::VERSION}
38
+ CONFIG
39
+
40
+ if File.read(tailwind_config_path.to_s).include?(START_MARKER)
41
+ gsub_file tailwind_config_path, /#{Regexp.escape(START_MARKER)}.*?#{Regexp.escape(END_MARKER)}.*?$/m do |match|
42
+ content_config.strip
43
+ end
44
+ else
45
+ insert_into_file tailwind_config_path, after: "content: [" do
46
+ "\n" + content_config.strip
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def add_turbo_material_js_controllers
53
+ controllers_path = Rails.root.join('app/javascript/controllers/index.js')
54
+ if controllers_path.exist? && controllers_path.read.include?('eagerLoadControllersFrom("controllers", application)')
55
+ if controllers_path.read.include?('eagerLoadControllersFrom("turbo_material", application)')
56
+ puts "`app/javascript/controllers/index.js` already contains `eagerLoadControllersFrom(\"turbo_material\", application)`"
57
+ else
58
+ insert_into_file controllers_path, after: 'eagerLoadControllersFrom("controllers", application)' do
59
+ "\neagerLoadControllersFrom(\"turbo_material\", application)\n"
60
+ end
61
+ end
62
+ else
63
+ puts "`app/javascript/controllers/index.js` does not exist or does not contain `eagerLoadControllersFrom(\"controllers\", application)`"
64
+ end
65
+ end
66
+
67
+ def add_material_components_web_to_app_layout
68
+ layout_path = Rails.root.join('app/views/layouts/application.html.erb')
69
+ if layout_path.exist? && layout_path.read.include?('<%= csp_meta_tag %>')
70
+ if layout_path.read.include?('<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">')
71
+ puts "`app/views/layouts/application.html.erb` head already contains material components web links"
72
+ else
73
+ insert_into_file layout_path, after: '<%= csp_meta_tag %>' do
74
+ HEAD_LINKS
75
+ end
76
+ end
77
+ else
78
+ raise "`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`"
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :turbo_material do
4
+ desc 'Installs TurboMaterial'
5
+ task install: :environment do
6
+ Rails::Command.invoke :generate, ['turbo_material:install']
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module TurboMaterial
2
+ class Configuration
3
+
4
+ def initialize
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module TurboMaterial
2
- VERSION = "0.2.16"
2
+ VERSION = "0.2.18"
3
3
  end
@@ -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
- # Your code goes here...
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.16
4
+ version: 0.2.18
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-03 00:00:00.000000000 Z
11
+ date: 2024-09-12 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
@@ -191,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
194
  - !ruby/object:Gem::Version
192
195
  version: '0'
193
196
  requirements: []
194
- rubygems_version: 3.5.3
197
+ rubygems_version: 3.4.12
195
198
  signing_key:
196
199
  specification_version: 4
197
200
  summary: Material Web Components for Hotwire Turbo.