mozaic 1.2.2 → 2.0.0
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 +5 -0
- data/README.md +17 -1
- data/lib/generators/mozaic/component_generator.rb +2 -2
- data/lib/generators/mozaic/install_generator.rb +0 -5
- data/lib/generators/templates/component/asset.css.erb +2 -1
- data/lib/generators/templates/component/asset.js.erb +10 -2
- data/lib/generators/templates/install/initializer.rb +7 -0
- data/lib/mozaic/configuration.rb +10 -0
- data/lib/mozaic/version.rb +1 -1
- metadata +2 -3
- data/lib/generators/templates/install/keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f789e2cfc0ac43f92060b4f602951a615faf17479d4e0f61f643578b4ca91189
|
4
|
+
data.tar.gz: 67f3b7234a5cea167aa72212eeccaec651c01428d0679ef8d3159bd2d0459fb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dff84a0aec99816becec95929589677bd4dde1800319a9e41f73d3f233fdd69eeef2301ad023fdc8c69d21cf5d49b51a9144e155985be98b9acd3b81a5e67c74
|
7
|
+
data.tar.gz: 6d1a363cda08180be01e7a3b224052e430c5f18db5b8498ea6d0b03505211f1ea55c68efc6fb9dd47e6f2f4e66a8e0ec976af490657c8141951f7188ec4c2921
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -157,7 +157,20 @@ Here is how to access a block in your component:
|
|
157
157
|
|
158
158
|
### Assets
|
159
159
|
|
160
|
-
|
160
|
+
#### Webpack (ES6)
|
161
|
+
|
162
|
+
The component generator generates asset files in your [configured](#configuration) directories.
|
163
|
+
|
164
|
+
The JavaScript assets use ES6 by default. You can now import a component:
|
165
|
+
|
166
|
+
```javascript
|
167
|
+
import ComponentName from 'mozaic/component/name';
|
168
|
+
let componentName = new ComponentName(document.querySelector('.mozaic-component.document-name'));
|
169
|
+
```
|
170
|
+
|
171
|
+
#### Sprockets
|
172
|
+
|
173
|
+
With Mozaic you can automatically add assets to the asset pipeline by naming them like the component they belong to. Just require Mozaic in your application assets:
|
161
174
|
|
162
175
|
```javascript
|
163
176
|
//= require_tree ./mozaic
|
@@ -185,6 +198,9 @@ end
|
|
185
198
|
```
|
186
199
|
|
187
200
|
* `define_component` Define components
|
201
|
+
* `es6` Whether generated JavaScript assets for components should use ES6 syntax or not. Accepts a boolean. Defaults to `true`.
|
202
|
+
* `javascripts` Directory to place JavaScript assets for components in. Accepts a string. Defaults to `'app/javascript/javascripts'`.
|
203
|
+
* `stylesheets` Directory to place styleshets for components in. Accepts a string. Defaults to `'app/javascript/stylesheets'`.
|
188
204
|
|
189
205
|
---
|
190
206
|
|
@@ -15,8 +15,8 @@ module Mozaic
|
|
15
15
|
names = options[:name].split('/')
|
16
16
|
name = names.pop
|
17
17
|
template 'partial.html.erb', "app/views/mozaic/#{names.join('/')}/_#{name}.html.erb"
|
18
|
-
template 'asset.js.erb', "
|
19
|
-
template 'asset.css.erb', "
|
18
|
+
template 'asset.js.erb', "#{Mozaic.configuration.javascripts}/mozaic/#{options[:name]}.js"
|
19
|
+
template 'asset.css.erb', "#{Mozaic.configuration.stylesheets}/mozaic/#{options[:name]}.css"
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
<% if Mozaic.configuration.es6 %>class <%= options[:name].split("/").map { |s| s.capitalize }.join('') %> {
|
2
|
+
|
3
|
+
constructor(element) {
|
4
|
+
// ...
|
5
|
+
}
|
6
|
+
|
7
|
+
};
|
8
|
+
|
9
|
+
export default <%= options[:name].split("/").map { |s| s.capitalize }.join('') %>;<% else %>document.addEventListener( 'turbolinks:load', function() {
|
2
10
|
if ( $('.mozaic--component.<%= options[:name].split("/").join(".") %>').length > 0 ) {
|
3
11
|
<%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init();
|
4
12
|
};
|
@@ -8,4 +16,4 @@ $(document).on( 'turbolinks:load', function() {
|
|
8
16
|
|
9
17
|
function <%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init() {
|
10
18
|
// ...
|
11
|
-
}
|
19
|
+
};<% end %>
|
@@ -1,5 +1,12 @@
|
|
1
1
|
Mozaic.configure do |config|
|
2
2
|
|
3
|
+
# Use Mozaic with Webpacker
|
4
|
+
# config.es6 = true
|
5
|
+
# Javascript asset directory
|
6
|
+
# config.javascripts = 'app/javascript/javascripts'
|
7
|
+
# Stylesheet asset directory
|
8
|
+
# config.stylesheets = 'app/javascript/stylesheets'
|
9
|
+
|
3
10
|
# Define Mozaic components
|
4
11
|
# config.define_component :name
|
5
12
|
|
data/lib/mozaic/configuration.rb
CHANGED
@@ -11,6 +11,16 @@ module Mozaic
|
|
11
11
|
|
12
12
|
class Configuration
|
13
13
|
|
14
|
+
attr_accessor :es6
|
15
|
+
attr_accessor :javascripts
|
16
|
+
attr_accessor :stylesheets
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@es6 = true
|
20
|
+
@javascripts = 'app/javascript/javascripts'
|
21
|
+
@stylesheets = 'app/javascript/stylesheets'
|
22
|
+
end
|
23
|
+
|
14
24
|
def define_component name, options = {}
|
15
25
|
if block_given?
|
16
26
|
Mozaic::Component.new name.to_sym, options, &Proc.new
|
data/lib/mozaic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mozaic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- lib/generators/templates/component/asset.js.erb
|
100
100
|
- lib/generators/templates/component/partial.html.erb
|
101
101
|
- lib/generators/templates/install/initializer.rb
|
102
|
-
- lib/generators/templates/install/keep
|
103
102
|
- lib/generators/templates/install/layout.html.erb
|
104
103
|
- lib/generators/templates/layout/layout.html.erb
|
105
104
|
- lib/mozaic.rb
|
File without changes
|