view_component-contrib 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +16 -3
- data/app/templates/install/index.stimulus.js +1 -1
- data/app/templates/install/postcss-modules.js +1 -1
- data/app/templates/install/template.rb +4 -0
- data/lib/view_component_contrib/preview/abstract.rb +2 -1
- data/lib/view_component_contrib/preview/default_template.rb +1 -5
- data/lib/view_component_contrib/railtie.rb +7 -0
- data/lib/view_component_contrib/version.rb +1 -1
- data/lib/view_component_contrib.rb +3 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 837ad4bbcf45a025383e628eb59f57b1aa9463468045d843eabd061cb3134f2c
|
4
|
+
data.tar.gz: c8e9169d866f92ba5c5a67a1214c2909dd6704f340eb8b3f1404ca8efb478bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d418a0bd1a8cf862f88dd9f4b9bb8d51252e6d5705fb3240fce51d5e014be0c37f06196d8c281845f256d8773d8f558bcd761ffda550b72a7f3bcdb9eeef04c7
|
7
|
+
data.tar.gz: 5094714a83ed34e41b2fd2631db68c1ef09d03ffcdb10d2620acac0265771233402f262452bf14932a18587d8877a694b631259d0835a9c2afc8766e3f77cf8b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -98,12 +98,25 @@ We provide a `ViewComponentContrib::Preview` class, which helps to reduce the bo
|
|
98
98
|
|
99
99
|
The default template shipped with the gem is as follows:
|
100
100
|
|
101
|
-
```
|
101
|
+
```erb
|
102
102
|
<div class="<%= container_class %>">
|
103
|
-
|
103
|
+
<%- if component -%>
|
104
|
+
<%= render component %>
|
105
|
+
<%- else -%>
|
106
|
+
Failed to infer a component from the preview: <%= error %>
|
107
|
+
<%- end -%>
|
104
108
|
</div>
|
105
109
|
```
|
106
110
|
|
111
|
+
To define your own default template:
|
112
|
+
```ruby
|
113
|
+
class ApplicationViewComponentPreview < ViewComponentContrib::Preview::Base
|
114
|
+
# ...
|
115
|
+
self.default_preview_template = "path/to/your/template.html.{erb,haml,slim}"
|
116
|
+
# ...
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
107
120
|
Let's assume that you have the following `ApplicationViewComponentPreview`:
|
108
121
|
|
109
122
|
```ruby
|
@@ -228,7 +241,7 @@ context.keys().forEach((path) => {
|
|
228
241
|
// nav/user_info/index.js -> nav--user-info
|
229
242
|
const identifier = path.replace(/^\.\//, '')
|
230
243
|
.replace(/\/index\.js$/, '')
|
231
|
-
.replace(
|
244
|
+
.replace(/\//g, '--');
|
232
245
|
|
233
246
|
application.register(identifier, mod.Controller);
|
234
247
|
});
|
@@ -14,7 +14,7 @@ context.keys().forEach((path) => {
|
|
14
14
|
// nav/user_info/index.js -> nav--user-info
|
15
15
|
const identifier = path.replace(/^\\.\\//, '')
|
16
16
|
.replace(/\\/index\\.js$/, '')
|
17
|
-
.replace(
|
17
|
+
.replace(/\\//g, '--');
|
18
18
|
|
19
19
|
application.register(identifier, mod.Controller);
|
20
20
|
});
|
@@ -4,7 +4,7 @@
|
|
4
4
|
if (!matches) return name;
|
5
5
|
|
6
6
|
// identifier here is the same identifier we used for Stimulus controller (see above)
|
7
|
-
const identifier = matches[1].replace(
|
7
|
+
const identifier = matches[1].replace(/\\//g, "--");
|
8
8
|
|
9
9
|
// We also add the `c-` prefix to all components classes
|
10
10
|
return `c-${identifier}-${name}`;
|
@@ -85,6 +85,8 @@ if USE_WEBPACK
|
|
85
85
|
say_status :info, "✅ Added index.js to load components JS/CSS"
|
86
86
|
say "⚠️ Don't forget to import component JS/CSS (#{ROOT_PATH}/index.js) from your application.js entrypoint"
|
87
87
|
|
88
|
+
say "⚠️ Don't forget to add #{ROOT_PATH} to `additional_paths` in your `webpacker.yml` (unless your `source_path` already includes it)"
|
89
|
+
|
88
90
|
USE_POSTCSS_MODULES = yes? "Would you like to use postcss-modules to isolate component styles?"
|
89
91
|
|
90
92
|
if USE_POSTCSS_MODULES
|
@@ -122,6 +124,8 @@ if USE_WEBPACK
|
|
122
124
|
|
123
125
|
say_status :info, "✅ postcss-modules configured"
|
124
126
|
end
|
127
|
+
else
|
128
|
+
say "⚠️ See the discussion on how to configure non-Wepback JS/CSS installations: https://github.com/palkan/view_component-contrib/discussions/14"
|
125
129
|
end
|
126
130
|
|
127
131
|
<%= embed("./generator.rb") %>
|
@@ -30,13 +30,9 @@ module ViewComponentContrib
|
|
30
30
|
Dir.glob(File.join(path, preview_name, "preview.html.*")).any?
|
31
31
|
end
|
32
32
|
|
33
|
-
has_preview_template ? File.join(preview_name, "preview") :
|
33
|
+
has_preview_template ? File.join(preview_name, "preview") : default_preview_template
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
ActiveSupport.on_load(:view_component) do
|
41
|
-
ViewComponent::Base.preview_paths << File.join(ViewComponentContrib::APP_PATH, "views")
|
42
|
-
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require "ruby-next/language/setup"
|
4
4
|
RubyNext::Language.setup_gem_load_path
|
5
5
|
|
6
|
+
require "view_component"
|
7
|
+
|
6
8
|
module ViewComponentContrib
|
7
9
|
APP_PATH = File.expand_path(File.join(__dir__, "../app"))
|
8
10
|
|
@@ -14,4 +16,5 @@ module ViewComponentContrib
|
|
14
16
|
autoload :Preview, "view_component_contrib/preview"
|
15
17
|
end
|
16
18
|
|
19
|
+
require "view_component_contrib/railtie" if defined?(::Rails::Railtie)
|
17
20
|
require "view_component_contrib/version"
|
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.1
|
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:
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: view_component
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/view_component_contrib/preview/base.rb
|
167
167
|
- lib/view_component_contrib/preview/default_template.rb
|
168
168
|
- lib/view_component_contrib/preview/sidecarable.rb
|
169
|
+
- lib/view_component_contrib/railtie.rb
|
169
170
|
- lib/view_component_contrib/translation_helper.rb
|
170
171
|
- lib/view_component_contrib/version.rb
|
171
172
|
- lib/view_component_contrib/wrapped_helper.rb
|
@@ -179,7 +180,7 @@ metadata:
|
|
179
180
|
documentation_uri: http://github.com/palkan/view_component-contrib
|
180
181
|
homepage_uri: http://github.com/palkan/view_component-contrib
|
181
182
|
source_code_uri: http://github.com/palkan/view_component-contrib
|
182
|
-
post_install_message:
|
183
|
+
post_install_message:
|
183
184
|
rdoc_options: []
|
184
185
|
require_paths:
|
185
186
|
- lib
|
@@ -187,15 +188,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
188
|
requirements:
|
188
189
|
- - ">="
|
189
190
|
- !ruby/object:Gem::Version
|
190
|
-
version: '2.
|
191
|
+
version: '2.6'
|
191
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
193
|
requirements:
|
193
194
|
- - ">="
|
194
195
|
- !ruby/object:Gem::Version
|
195
196
|
version: '0'
|
196
197
|
requirements: []
|
197
|
-
rubygems_version: 3.
|
198
|
-
signing_key:
|
198
|
+
rubygems_version: 3.2.22
|
199
|
+
signing_key:
|
199
200
|
specification_version: 4
|
200
201
|
summary: A collection of extensions and developer tools for ViewComponent
|
201
202
|
test_files: []
|