view_component-contrib 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 837ad4bbcf45a025383e628eb59f57b1aa9463468045d843eabd061cb3134f2c
4
- data.tar.gz: c8e9169d866f92ba5c5a67a1214c2909dd6704f340eb8b3f1404ca8efb478bc3
3
+ metadata.gz: 1f439e065cd49e9a08753fbcdfda2fbccc3b96f2a72f5d0ccb6896cd3da7b74e
4
+ data.tar.gz: 211ea998a9033327fdf57cc6094dcea1a269bb9022f539b2f182aece95fd6eb1
5
5
  SHA512:
6
- metadata.gz: d418a0bd1a8cf862f88dd9f4b9bb8d51252e6d5705fb3240fce51d5e014be0c37f06196d8c281845f256d8773d8f558bcd761ffda550b72a7f3bcdb9eeef04c7
7
- data.tar.gz: 5094714a83ed34e41b2fd2631db68c1ef09d03ffcdb10d2620acac0265771233402f262452bf14932a18587d8877a694b631259d0835a9c2afc8766e3f77cf8b
6
+ metadata.gz: 8bfa8779d3a7cc39519f92e9d020c325bf0f4f6d8e845dc3de21d1aef129959ebad4a68249b2229d3e49edf19096c73107fff6ffbccee43b8408db217fedf91e
7
+ data.tar.gz: 3add0d31953c16acc07a58637be8f6d5acd4dc7505a7466a635924c5afdddd23b0f6ffbded2e03e3c4195df45c04ba54f0822e58d72413b0aacd4a998469511e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.2 (2023-01-13)
6
+
7
+ - Fix compatibility with sidecar translations. ([@palkan][])
8
+
9
+ - Detect Webpack when using Rails 7 + jsbundling-rails. ([@unikitty37][])
10
+
11
+ - Skip autoloading of Preview files when viewing previews is disabled. ([@dhnaranjo][])
12
+
13
+ - Automatic publish to RailsBytes in CI. ([@fargelus][])
14
+
5
15
  ## 0.1.1 (2022-03-14)
6
16
 
7
17
  - Fix adding gem's previews to the app's path. ([@palkan][])
@@ -13,3 +23,5 @@
13
23
  - Initial release.
14
24
 
15
25
  [@palkan]: https://github.com/palkan
26
+ [@fargelus]: https://github.com/fargelus
27
+ [@dhnaranjo]: https://github.com/dhnaranjo
data/README.md CHANGED
@@ -167,9 +167,7 @@ class Banner::Preview < ApplicationViewComponentPreview
167
167
  end
168
168
  ```
169
169
 
170
- If you need more control over your template, you can add a custom `preview.html.erb` file.
171
- **NOTE:** We assume that all examples uses the same `preview.html`. If it's not the case,
172
- you can use the original `#render_with_template` method.
170
+ If you need more control over your template, you can add a custom `preview.html.*` template (which will be used for all examples in this preview), or even create an example-specific `previews/example.html.*` (e.g. `previews/mobile.html.erb`).
173
171
 
174
172
  ## Organizing assets (JS, CSS)
175
173
 
@@ -3,7 +3,7 @@ say "👋 Welcome to interactive ViewComponent installer and configurator. " \
3
3
 
4
4
  run "bundle add view_component view_component-contrib --skip-install"
5
5
 
6
- inject_into_file "config/application.rb", "require \"view_component/engine\"\n", before: "\nBundler.require(*Rails.groups)"
6
+ inject_into_file "config/application.rb", "\nrequire \"view_component/engine\"\n", before: "\nBundler.require(*Rails.groups)"
7
7
 
8
8
  say_status :info, "✅ ViewComponent gems added"
9
9
 
@@ -65,7 +65,7 @@ end
65
65
 
66
66
  say_status :info, "✅ RSpec configured"
67
67
 
68
- USE_WEBPACK = File.directory?("config/webpack")
68
+ USE_WEBPACK = File.directory?("config/webpack") || File.file?("webpack.config.js")
69
69
 
70
70
  if USE_WEBPACK
71
71
  USE_STIMULUS = yes? "Do you use StimulusJS?"
@@ -23,14 +23,22 @@ module ViewComponentContrib
23
23
  end
24
24
  end
25
25
 
26
- def preview_example_template_path(...)
26
+ def preview_example_template_path(example)
27
27
  super
28
28
  rescue ViewComponent::PreviewTemplateError
29
- has_preview_template = preview_paths.find do |path|
29
+ has_example_preview = preview_paths.find do |path|
30
+ Dir.glob(File.join(path, preview_name, "previews", "#{example}.html.*")).any?
31
+ end
32
+
33
+ return File.join(preview_name, "previews", example) if has_example_preview
34
+
35
+ has_root_preview = preview_paths.find do |path|
30
36
  Dir.glob(File.join(path, preview_name, "preview.html.*")).any?
31
37
  end
32
38
 
33
- has_preview_template ? File.join(preview_name, "preview") : default_preview_template
39
+ return File.join(preview_name, "preview") if has_root_preview
40
+
41
+ default_preview_template
34
42
  end
35
43
  end
36
44
  end
@@ -3,5 +3,14 @@
3
3
  module ViewComponentContrib
4
4
  class Railtie < Rails::Railtie
5
5
  config.view_component.preview_paths << File.join(ViewComponentContrib::APP_PATH, "views")
6
+
7
+ initializer "view_component-contrib.skip_loading_previews_if_disabled" do
8
+ unless Rails.application.config.view_component.show_previews
9
+ previews = Rails.application.config.view_component.preview_paths.flat_map do |path|
10
+ Pathname(path).glob("**/*preview.rb")
11
+ end
12
+ Rails.autoloaders.each { |autoloader| autoloader.ignore(previews) }
13
+ end
14
+ end
6
15
  end
7
16
  end
@@ -22,22 +22,22 @@ module ViewComponentContrib
22
22
  end
23
23
  end
24
24
 
25
- def i18n_scope
26
- return @i18n_scope if defined?(@i18n_scope)
25
+ def contrib_i18n_scope
26
+ return @contrib_i18n_scope if defined?(@contrib_i18n_scope)
27
27
 
28
- @i18n_scope = name.sub("::Component", "").underscore.split("/")
28
+ @contrib_i18n_scope = name.sub("::Component", "").underscore.split("/")
29
29
  end
30
30
 
31
31
  def i18n_scope=(val)
32
32
  raise ArgumentError, "Must be array" unless val.is_a?(Array)
33
33
 
34
- @i18n_scope = val.dup.freeze
34
+ @contrib_i18n_scope = val.dup.freeze
35
35
  end
36
36
 
37
37
  def virtual_path
38
38
  @contrib_virtual_path ||= [
39
39
  i18n_namespace,
40
- *i18n_scope
40
+ *contrib_i18n_scope
41
41
  ].join(".")
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViewComponentContrib # :nodoc:all
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: view_component
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-next-core
28
+ name: ruby-next
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.2.22
198
+ rubygems_version: 3.3.11
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: A collection of extensions and developer tools for ViewComponent