view_component-contrib 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 837ad4bbcf45a025383e628eb59f57b1aa9463468045d843eabd061cb3134f2c
4
- data.tar.gz: c8e9169d866f92ba5c5a67a1214c2909dd6704f340eb8b3f1404ca8efb478bc3
3
+ metadata.gz: b7cf65bd25a29819f2a1337d7590e6c2274a9e0d0642b52a34606bde33140a76
4
+ data.tar.gz: 54131be9ed2d51cd9dc688a7ca6010219f7b9b98c937ca84ef84c68890abfd52
5
5
  SHA512:
6
- metadata.gz: d418a0bd1a8cf862f88dd9f4b9bb8d51252e6d5705fb3240fce51d5e014be0c37f06196d8c281845f256d8773d8f558bcd761ffda550b72a7f3bcdb9eeef04c7
7
- data.tar.gz: 5094714a83ed34e41b2fd2631db68c1ef09d03ffcdb10d2620acac0265771233402f262452bf14932a18587d8877a694b631259d0835a9c2afc8766e3f77cf8b
6
+ metadata.gz: ed6a4aed6af147f1e768ddfbffbda467c31ff54395e4dfdebb26fc12ab214c6a9740e4c3b7aec5dac7a5dcb5c2b0e637298e32f6803fa5f07045a73e6d781f73
7
+ data.tar.gz: 25d7f12795c9e871439f7aa8f5990b97891de16b08c7ff2a7c571e5cc7bd03481ed943492c37be65252bcb264e6c20e8c245e141ddc0be71d388967db51a0f35
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.3 (2023-02-02)
6
+
7
+ - Fix release dependencies ([@palkan][])
8
+
9
+ ## 0.1.2 (2023-01-13)
10
+
11
+ - Fix compatibility with sidecar translations. ([@palkan][])
12
+
13
+ - Detect Webpack when using Rails 7 + jsbundling-rails. ([@unikitty37][])
14
+
15
+ - Skip autoloading of Preview files when viewing previews is disabled. ([@dhnaranjo][])
16
+
17
+ - Automatic publish to RailsBytes in CI. ([@fargelus][])
18
+
5
19
  ## 0.1.1 (2022-03-14)
6
20
 
7
21
  - Fix adding gem's previews to the app's path. ([@palkan][])
@@ -13,3 +27,5 @@
13
27
  - Initial release.
14
28
 
15
29
  [@palkan]: https://github.com/palkan
30
+ [@fargelus]: https://github.com/fargelus
31
+ [@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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: view_component
@@ -180,7 +180,7 @@ metadata:
180
180
  documentation_uri: http://github.com/palkan/view_component-contrib
181
181
  homepage_uri: http://github.com/palkan/view_component-contrib
182
182
  source_code_uri: http://github.com/palkan/view_component-contrib
183
- post_install_message:
183
+ post_install_message:
184
184
  rdoc_options: []
185
185
  require_paths:
186
186
  - lib
@@ -195,8 +195,8 @@ 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
199
- signing_key:
198
+ rubygems_version: 3.3.26
199
+ signing_key:
200
200
  specification_version: 4
201
201
  summary: A collection of extensions and developer tools for ViewComponent
202
202
  test_files: []