view_component-contrib 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -3
- data/app/templates/install/template.rb +2 -2
- data/lib/view_component_contrib/preview/default_template.rb +11 -3
- data/lib/view_component_contrib/railtie.rb +9 -0
- data/lib/view_component_contrib/translation_helper.rb +5 -5
- data/lib/view_component_contrib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f439e065cd49e9a08753fbcdfda2fbccc3b96f2a72f5d0ccb6896cd3da7b74e
|
4
|
+
data.tar.gz: 211ea998a9033327fdf57cc6094dcea1a269bb9022f539b2f182aece95fd6eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`
|
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", "
|
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
|
-
|
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
|
-
|
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
|
26
|
-
return @
|
25
|
+
def contrib_i18n_scope
|
26
|
+
return @contrib_i18n_scope if defined?(@contrib_i18n_scope)
|
27
27
|
|
28
|
-
@
|
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
|
-
@
|
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
|
-
*
|
40
|
+
*contrib_i18n_scope
|
41
41
|
].join(".")
|
42
42
|
end
|
43
43
|
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.
|
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:
|
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
|
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.
|
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
|