turbo_material 0.2.17 → 0.2.19

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -5
  3. data/app/controllers/turbo_material/application_controller.rb +2 -0
  4. data/app/helpers/turbo_material/application_helper.rb +2 -0
  5. data/app/helpers/turbo_material/checkbox_helper.rb +3 -1
  6. data/app/helpers/turbo_material/chip_set_helper.rb +4 -2
  7. data/app/helpers/turbo_material/chips_input_helper.rb +3 -1
  8. data/app/helpers/turbo_material/chips_input_options_helper.rb +3 -1
  9. data/app/helpers/turbo_material/chips_select_helper.rb +3 -1
  10. data/app/helpers/turbo_material/data_table_helper.rb +2 -0
  11. data/app/helpers/turbo_material/input_helper.rb +4 -2
  12. data/app/helpers/turbo_material/menu_button_helper.rb +3 -1
  13. data/app/helpers/turbo_material/modal_helper.rb +3 -1
  14. data/app/helpers/turbo_material/radio_helper.rb +3 -1
  15. data/app/helpers/turbo_material/select_helper.rb +3 -1
  16. data/app/helpers/turbo_material/switch_helper.rb +3 -1
  17. data/app/helpers/turbo_material/textarea_helper.rb +3 -1
  18. data/app/helpers/turbo_material/tooltip_helper.rb +3 -1
  19. data/app/jobs/turbo_material/application_job.rb +2 -0
  20. data/app/mailers/turbo_material/application_mailer.rb +4 -2
  21. data/app/models/turbo_material/application_record.rb +2 -0
  22. data/config/importmap.rb +6 -4
  23. data/config/routes.rb +2 -0
  24. data/lib/generators/turbo_material/install_generator.rb +67 -38
  25. data/lib/lookbook/checkbox_preview.rb +4 -2
  26. data/lib/lookbook/chips_select_preview.rb +8 -7
  27. data/lib/lookbook/input_preview.rb +4 -2
  28. data/lib/lookbook/radio_preview.rb +4 -2
  29. data/lib/lookbook/select_preview.rb +2 -1
  30. data/lib/lookbook/switch_preview.rb +4 -2
  31. data/lib/lookbook/textarea_preview.rb +4 -2
  32. data/lib/tasks/install.rake +5 -0
  33. data/lib/tasks/turbo_material_tasks.rake +2 -0
  34. data/lib/turbo_material/configuration.rb +3 -3
  35. data/lib/turbo_material/engine.rb +10 -10
  36. data/lib/turbo_material/post_install.rb +10 -0
  37. data/lib/turbo_material/version.rb +3 -1
  38. data/lib/turbo_material.rb +5 -3
  39. metadata +21 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1623b6bf21bbdba8af1e54604ded65c4ea4b9181fbc39fa5b0e9ebb0c45c3b2b
4
- data.tar.gz: f29b6252a029be2dfdd728f88646392f5b34edd6fee7539d9251218aa2b2f8d1
3
+ metadata.gz: fbceaa36f447d1f2c7c2ebd92923b28a9973ac5129768c53da94f5bbcf3a3a3c
4
+ data.tar.gz: b303476e7e72c5d1a96761b12cde4a01a8262a71181babe0841d1e416594f91e
5
5
  SHA512:
6
- metadata.gz: 2c195f9fd7d326e357336992f04fd88751a74546e79675b3aac0a7bf0b7216bae0ec17084051b04de9ea35efed00337c9d274704a1b3ae9d97401f7ba29e70a6
7
- data.tar.gz: 77682dd076906ff49f90fd7fef92e7bb81b55467a54e8549248bf841bc213d67a089e8f7ea845176f008b8b2f340d97dda34e3aa6a84b8dc2479eccaf96a7af4
6
+ metadata.gz: 31ef5cec5146f44354ffcc912dd772efd9b92c69f666646073005186a87746b953c2039899b2fc5a31ad78fffe5b2d448458a231fc92733bcec8ff8ddc10cc8f
7
+ data.tar.gz: a3f6ca5281ff7d61282ba1ec72439c1cfd8a377096982ad6dd34fdb5f513b3e0c750113aa4a65eae5ef69cd0864c38c8193f33693b2ebe8d09e9656fa38c2d0d
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
- require "bundler/setup"
1
+ # frozen_string_literal: true
2
2
 
3
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
- load "rails/tasks/engine.rake"
3
+ require 'bundler/setup'
5
4
 
6
- load "rails/tasks/statistics.rake"
5
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
6
+ load 'rails/tasks/engine.rake'
7
7
 
8
- require "bundler/gem_tasks"
8
+ load 'rails/tasks/statistics.rake'
9
+
10
+ require 'bundler/gem_tasks'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  class ApplicationController < ActionController::Base
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ApplicationHelper
3
5
  def cast_boolean(param)
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module CheckboxHelper
3
5
  def material_checkbox(kwargs = {})
4
- render "components/checkbox", **kwargs
6
+ render 'components/checkbox', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ChipSetHelper
3
5
  def material_chip_set(kwargs = {})
4
- render "components/chip_set", **kwargs
6
+ render 'components/chip_set', **kwargs
5
7
  end
6
8
 
7
9
  def material_chip(kwargs = {})
8
- render "components/chip", **kwargs
10
+ render 'components/chip', **kwargs
9
11
  end
10
12
  end
11
13
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ChipsInputHelper
3
5
  def material_chips_input(kwargs = {})
4
- render "components/chips_input", **kwargs
6
+ render 'components/chips_input', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ChipsInputOptionsHelper
3
5
  def material_chips_input_options(kwargs = {})
4
- render "components/chips_input_options", **kwargs
6
+ render 'components/chips_input_options', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ChipsSelectHelper
3
5
  def material_chips_select(kwargs = {})
4
- render "components/chips_select", **kwargs
6
+ render 'components/chips_select', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module DataTableHelper
3
5
  def material_data_table(kwargs = {})
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
- module InputHelper
4
+ module InputHelper
3
5
  def material_input(kwargs = {})
4
- render "components/input", **kwargs
6
+ render 'components/input', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module MenuButtonHelper
3
5
  def material_menu_button(kwargs = {}, &block)
4
- render "components/menu_button", **kwargs do
6
+ render 'components/menu_button', **kwargs do
5
7
  capture(&block) if block_given?
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module ModalHelper
3
5
  def material_modal(kwargs = {}, &block)
4
- render "components/modal", **kwargs do
6
+ render 'components/modal', **kwargs do
5
7
  capture(&block) if block_given?
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module RadioHelper
3
5
  def material_radio(kwargs = {})
4
- render "components/radio", **kwargs
6
+ render 'components/radio', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module SelectHelper
3
5
  def material_select(kwargs = {})
4
- render "components/select", **kwargs
6
+ render 'components/select', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module SwitchHelper
3
5
  def material_switch(kwargs = {})
4
- render "components/switch", **kwargs
6
+ render 'components/switch', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module TextareaHelper
3
5
  def material_textarea(kwargs = {})
4
- render "components/textarea", **kwargs
6
+ render 'components/textarea', **kwargs
5
7
  end
6
8
  end
7
9
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  module TooltipHelper
3
5
  def material_tooltip(kwargs = {}, &block)
4
6
  content = block_given? ? capture(&block) : nil
5
- render "components/tooltip", **kwargs, content: content
7
+ render 'components/tooltip', **kwargs, content: content
6
8
  end
7
9
  end
8
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  class ApplicationJob < ActiveJob::Base
3
5
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
4
- layout "mailer"
5
+ default from: 'from@example.com'
6
+ layout 'mailer'
5
7
  end
6
8
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  class ApplicationRecord < ActiveRecord::Base
3
5
  self.abstract_class = true
data/config/importmap.rb CHANGED
@@ -1,4 +1,6 @@
1
- pin_all_from File.expand_path("../app/assets/javascripts", __dir__)
2
- pin "@rails/request.js", to: "https://ga.jspm.io/npm:@rails/request.js@0.0.9/src/index.js"
3
- pin "stimulus-use", to: "https://ga.jspm.io/npm:stimulus-use@0.51.3/dist/index.js"
4
- pin "hotkeys-js", to: "https://ga.jspm.io/npm:hotkeys-js@3.10.2/dist/hotkeys.esm.js"
1
+ # frozen_string_literal: true
2
+
3
+ pin_all_from File.expand_path('../app/assets/javascripts', __dir__)
4
+ pin '@rails/request.js', to: 'https://ga.jspm.io/npm:@rails/request.js@0.0.9/src/index.js'
5
+ pin 'stimulus-use', to: 'https://ga.jspm.io/npm:stimulus-use@0.51.3/dist/index.js'
6
+ pin 'hotkeys-js', to: 'https://ga.jspm.io/npm:hotkeys-js@3.10.2/dist/hotkeys.esm.js'
data/config/routes.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  TurboMaterial::Engine.routes.draw do
2
4
  end
@@ -2,78 +2,107 @@
2
2
 
3
3
  module TurboMaterial
4
4
  class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
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
7
+ START_MARKER = "// #{Engine.name} raw CSS. This section is auto-generated by the turbo_material installer."
8
+ END_MARKER = "// End of auto-generated #{Engine.name} raw CSS. Version:"
9
9
  HEAD_LINKS = <<-HTML.rstrip.freeze
10
10
 
11
11
 
12
12
  <link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">
13
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">
14
+ <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">#{' '}
15
15
  HTML
16
+ CLASS_REGEX = %r(\.\\?(!?[-_a-zA-Z0-9\[\]/:]+)(?=[^}]*\{)).freeze
17
+ TAILWIND_CONFIG_PATH = Rails.root.join('config/tailwind.config.js')
18
+
19
+ class_option :update_tailwind_only,
20
+ type: :boolean,
21
+ default: false,
22
+ desc: 'Only update Tailwind configuration'
16
23
 
17
24
  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!( /\\\]/, ']')
25
+ return unless TAILWIND_CONFIG_PATH.exist?
24
26
 
25
- class_regex = /\.\\?(!?[-_a-zA-Z0-9\[\]]+)(?=[^}]*\{)/
26
- classes = css_content.scan(class_regex).flatten.uniq.sort
27
+ if tailwind_config_up_to_date?
28
+ puts 'Tailwind config is up to date'
29
+ return
30
+ end
27
31
 
28
- tailwind_config_path = Rails.root.join('config/tailwind.config.js')
32
+ classes = extract_tailwind_classes
29
33
 
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
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
36
39
 
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
40
+ if File.read(TAILWIND_CONFIG_PATH.to_s).include?(START_MARKER)
41
+ gsub_file TAILWIND_CONFIG_PATH,
42
+ /#{Regexp.escape(START_MARKER)}.*?#{Regexp.escape(END_MARKER)}.*?$/m do |_match|
43
+ content_config.strip
44
+ end
45
+ else
46
+ insert_into_file TAILWIND_CONFIG_PATH, after: 'content: [' do
47
+ "\n#{content_config.strip}"
45
48
  end
46
49
  end
47
50
  end
48
51
 
49
52
  def add_turbo_material_js_controllers
53
+ return if options[:update_tailwind_only]
54
+
50
55
  controllers_path = Rails.root.join('app/javascript/controllers/index.js')
51
56
  if controllers_path.exist? && controllers_path.read.include?('eagerLoadControllersFrom("controllers", application)')
52
57
  if controllers_path.read.include?('eagerLoadControllersFrom("turbo_material", application)')
53
- puts "`app/javascript/controllers/index.js` already contains `eagerLoadControllersFrom(\"turbo_material\", application)`"
58
+ puts '`app/javascript/controllers/index.js` already contains `eagerLoadControllersFrom("turbo_material", application)`'
54
59
  else
55
60
  insert_into_file controllers_path, after: 'eagerLoadControllersFrom("controllers", application)' do
56
61
  "\neagerLoadControllersFrom(\"turbo_material\", application)\n"
57
62
  end
58
63
  end
59
64
  else
60
- puts "`app/javascript/controllers/index.js` does not exist or does not contain `eagerLoadControllersFrom(\"controllers\", application)`"
65
+ puts '`app/javascript/controllers/index.js` does not exist or does not contain `eagerLoadControllersFrom("controllers", application)`'
61
66
  end
62
67
  end
63
68
 
64
69
  def add_material_components_web_to_app_layout
70
+ return if options[:update_tailwind_only]
71
+
65
72
  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
73
+ unless layout_path.exist? && layout_path.read.include?('<%= csp_meta_tag %>')
74
+ raise '`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`'
75
+ end
76
+
77
+ if layout_path.read.include?('<link href="//cdn.jsdelivr.net/npm/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">')
78
+ puts '`app/views/layouts/application.html.erb` head already contains material components web links'
74
79
  else
75
- raise "`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`"
80
+ insert_into_file layout_path, after: '<%= csp_meta_tag %>' do
81
+ HEAD_LINKS
82
+ end
76
83
  end
77
84
  end
85
+
86
+ private
87
+
88
+ def tailwind_config_up_to_date?
89
+ return false unless TAILWIND_CONFIG_PATH.exist?
90
+
91
+ content = File.read(TAILWIND_CONFIG_PATH)
92
+ content.include?("#{END_MARKER} #{TurboMaterial::VERSION}")
93
+ end
94
+
95
+ def extract_tailwind_classes
96
+ tailwind_css_path = Engine.root.join('app/assets/dist/turbo_material/tailwind.css')
97
+ css_content = File.read(tailwind_css_path)
98
+ css_content.gsub!(%r{/\*.*?\*/}m, '')
99
+ css_content.gsub!(/\{[^}]*}/m, '{}')
100
+ css_content.gsub!('>:not([hidden])~:not([hidden])', '')
101
+ css_content.gsub!(/\\\[/, '[')
102
+ css_content.gsub!(/\\\]/, ']')
103
+ css_content.gsub!(%r{\\/}, '/')
104
+ css_content.gsub!(/\\:/, ':')
105
+ css_content.scan(CLASS_REGEX).flatten.uniq.sort
106
+ end
78
107
  end
79
108
  end
@@ -1,8 +1,10 @@
1
- class CheckboxPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class CheckboxPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  def default(label: 'Checkbox', disabled: false)
6
- render 'common/form', helper_name: 'material_checkbox', label: label, name: 'checkbox', id: 'Checkbox', disabled: disabled
7
+ render 'common/form', helper_name: 'material_checkbox', label: label, name: 'checkbox', id: 'Checkbox',
8
+ disabled: disabled
7
9
  end
8
10
  end
@@ -1,15 +1,16 @@
1
- class ChipsSelectPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class ChipsSelectPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  # @param required toggle
6
7
  def default(label: 'Chips Select', disabled: false, required: false)
7
8
  render 'common/form', helper_name: 'material_chips_select', label: label, name: 'checkbox',
8
- id: 'Input', disabled: disabled, value: [],
9
- options: [
10
- { value: '1', label: 'Option 1' },
11
- { value: '2', label: 'Option 2' },
12
- { value: '3', label: 'Option 3' }
13
- ]
9
+ id: 'Input', disabled: disabled, value: [],
10
+ options: [
11
+ { value: '1', label: 'Option 1' },
12
+ { value: '2', label: 'Option 2' },
13
+ { value: '3', label: 'Option 3' }
14
+ ]
14
15
  end
15
16
  end
@@ -1,10 +1,12 @@
1
- class InputPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class InputPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  # @param required toggle
6
7
  # @param style select { choices: [filled, outlined] }
7
8
  def default(label: 'Input', disabled: false, required: false, style: 'filled')
8
- render 'common/form', helper_name: 'material_input', label: label, name: 'checkbox', id: 'Input', disabled: disabled, required: required, style: style
9
+ render 'common/form', helper_name: 'material_input', label: label, name: 'checkbox', id: 'Input',
10
+ disabled: disabled, required: required, style: style
9
11
  end
10
12
  end
@@ -1,9 +1,11 @@
1
- class RadioPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class RadioPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  # @param required toggle
6
7
  def default(label: 'Radio', disabled: false, required: false)
7
- render 'common/form', helper_name: 'material_radio', label: label, name: 'checkbox', id: 'Input', disabled: disabled, required: required
8
+ render 'common/form', helper_name: 'material_radio', label: label, name: 'checkbox', id: 'Input',
9
+ disabled: disabled, required: required
8
10
  end
9
11
  end
@@ -1,5 +1,6 @@
1
- class SelectPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class SelectPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  # @param required toggle
@@ -1,10 +1,12 @@
1
- class SwitchPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class SwitchPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param true_label text
5
6
  # @param false_label text
6
7
  # @param disabled toggle
7
8
  def default(label: 'Switch', disabled: false, required: false, true_label: nil, false_label: nil)
8
- render 'common/form', helper_name: 'material_switch', label: label, name: 'checkbox', id: 'Input', disabled: disabled, true_label: true_label, false_label: false_label
9
+ render 'common/form', helper_name: 'material_switch', label: label, name: 'checkbox', id: 'Input',
10
+ disabled: disabled, true_label: true_label, false_label: false_label
9
11
  end
10
12
  end
@@ -1,9 +1,11 @@
1
- class TextareaPreview < Lookbook::Preview
1
+ # frozen_string_literal: true
2
2
 
3
+ class TextareaPreview < Lookbook::Preview
3
4
  # @param label text
4
5
  # @param disabled toggle
5
6
  # @param required toggle
6
7
  def default(label: 'Textarea', disabled: false, required: false)
7
- render 'common/form', helper_name: 'material_textarea', label: label, name: 'textarea', id: 'Text', disabled: disabled, required: required
8
+ render 'common/form', helper_name: 'material_textarea', label: label, name: 'textarea', id: 'Text',
9
+ disabled: disabled, required: required
8
10
  end
9
11
  end
@@ -5,4 +5,9 @@ namespace :turbo_material do
5
5
  task install: :environment do
6
6
  Rails::Command.invoke :generate, ['turbo_material:install']
7
7
  end
8
+
9
+ desc 'Updates Tailwind configuration'
10
+ task update_tailwind: :environment do
11
+ Rails::Command.invoke :generate, %w[turbo_material:install --update-tailwind-only]
12
+ end
8
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :turbo_material do
3
5
  # # Task goes here
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
4
  class Configuration
3
-
4
- def initialize
5
- end
5
+ def initialize; end
6
6
  end
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "importmap-rails"
3
+ require 'importmap-rails'
4
4
 
5
5
  module TurboMaterial
6
6
  class Engine < ::Rails::Engine
@@ -26,26 +26,26 @@ module TurboMaterial
26
26
  end
27
27
  end
28
28
 
29
- initializer "turbo_material.importmap", before: "importmap" do |app|
29
+ initializer 'turbo_material.importmap', before: 'importmap' do |app|
30
30
  # NOTE: this will add pins from this engine to the main app
31
31
  # https://github.com/rails/importmap-rails#composing-import-maps
32
- app.config.importmap.paths << root.join("config/importmap.rb")
32
+ app.config.importmap.paths << root.join('config/importmap.rb')
33
33
 
34
34
  # NOTE: something about cache; I did not look into it.
35
35
  # https://github.com/rails/importmap-rails#sweeping-the-cache-in-development-and-test
36
- app.config.importmap.cache_sweepers << root.join("app/assets/javascripts")
36
+ app.config.importmap.cache_sweepers << root.join('app/assets/javascripts')
37
37
  end
38
38
 
39
39
  # NOTE: add engine manifest to precompile assets in production
40
- initializer "turbo_material.assets" do |app|
40
+ initializer 'turbo_material.assets' do |app|
41
41
  app.config.assets.precompile += %w[turbo_material_manifest]
42
42
  end
43
43
 
44
- initializer "turbo_material.precompile" do |app|
45
- app.config.assets.paths << root.join("app/assets/javascripts")
46
- app.config.assets.precompile << "turbo_material/application.js"
47
- app.config.assets.paths << root.join("app/assets/dist")
48
- app.config.assets.precompile << "turbo_material/tailwind.css"
44
+ initializer 'turbo_material.precompile' do |app|
45
+ app.config.assets.paths << root.join('app/assets/javascripts')
46
+ app.config.assets.precompile << 'turbo_material/application.js'
47
+ app.config.assets.paths << root.join('app/assets/dist')
48
+ app.config.assets.precompile << 'turbo_material/tailwind.css'
49
49
  end
50
50
  end
51
51
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurboMaterial
4
+ def self.post_install
5
+ puts 'TurboMaterial: Running post install tasks...'
6
+ rescue StandardError => e
7
+ puts "TurboMaterial: Failed to update Tailwind configuration. Error: #{e.message}"
8
+ puts "You may need to run 'bin/rails turbo_material:install' manually to complete the setup."
9
+ end
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TurboMaterial
2
- VERSION = "0.2.17"
4
+ VERSION = '0.2.19'
3
5
  end
@@ -1,6 +1,8 @@
1
- require "turbo_material/version"
2
- require "turbo_material/engine"
3
- require "turbo_material/configuration"
1
+ # frozen_string_literal: true
2
+
3
+ require 'turbo_material/version'
4
+ require 'turbo_material/engine'
5
+ require 'turbo_material/configuration'
4
6
 
5
7
  module TurboMaterial
6
8
  class << self
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_material
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.17
4
+ version: 0.2.19
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 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: importmap-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.1'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 7.1.2
19
+ version: 2.0.1
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '7.1'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 7.1.2
26
+ version: 2.0.1
33
27
  - !ruby/object:Gem::Dependency
34
- name: importmap-rails
28
+ name: rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - "~>"
31
+ - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: 2.0.1
33
+ version: 7.1.2
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '9.0'
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
43
40
  requirements:
44
- - - "~>"
41
+ - - ">="
45
42
  - !ruby/object:Gem::Version
46
- version: 2.0.1
43
+ version: 7.1.2
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '9.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: stimulus-rails
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,7 @@ files:
171
171
  - lib/turbo_material.rb
172
172
  - lib/turbo_material/configuration.rb
173
173
  - lib/turbo_material/engine.rb
174
+ - lib/turbo_material/post_install.rb
174
175
  - lib/turbo_material/version.rb
175
176
  homepage: https://github.com/full-stack-biz/turbo_material
176
177
  licenses:
@@ -179,7 +180,10 @@ metadata:
179
180
  allowed_push_host: https://rubygems.org
180
181
  homepage_uri: https://github.com/full-stack-biz/turbo_material
181
182
  source_code_uri: https://github.com/full-stack-biz/turbo_material
182
- post_install_message:
183
+ post_install_message: |
184
+ Installing `turbo_material` gem. Please, follow the instructions in the README.md file.
185
+
186
+ After that, please, run `bin/rails turbo_material:install` to install the gem and add necessary files and configurations to your project.
183
187
  rdoc_options: []
184
188
  require_paths:
185
189
  - lib