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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b40575904ccf29394649df9c3a8490298cd7e8951480d44485f786ab1aca1293
4
- data.tar.gz: 5548ccaccc83a76649c8daa7d3d9ce47415a696eb67b8523fa291ecaa7d2011a
3
+ metadata.gz: f789e2cfc0ac43f92060b4f602951a615faf17479d4e0f61f643578b4ca91189
4
+ data.tar.gz: 67f3b7234a5cea167aa72212eeccaec651c01428d0679ef8d3159bd2d0459fb0
5
5
  SHA512:
6
- metadata.gz: 2e2a715d2922ff3fe9173c73615a103f3c221022fa07e35aa35a6564f9e149c2a69dcaf25d9b3a2a3acb17775e1f6a85683b93ac0c40fdad4781ff7c1cec46a5
7
- data.tar.gz: 4357d59b79ab839245a3d03a0dec5a4b2e4e170098d6cd28af315e50fb22f6b251fbd303969165a9d48f1c143ddebcf2078a7aacb876bf020491c16d75aed99f
6
+ metadata.gz: dff84a0aec99816becec95929589677bd4dde1800319a9e41f73d3f233fdd69eeef2301ad023fdc8c69d21cf5d49b51a9144e155985be98b9acd3b81a5e67c74
7
+ data.tar.gz: 6d1a363cda08180be01e7a3b224052e430c5f18db5b8498ea6d0b03505211f1ea55c68efc6fb9dd47e6f2f4e66a8e0ec976af490657c8141951f7188ec4c2921
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 2.0.0 - 2018/02/08
8
+
9
+ * features
10
+ * added configuration options to configure webpack/ES6 usage
11
+
7
12
  ### 1.2.2 - 2018/02/05
8
13
 
9
14
  * bugfixes
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
- With Mozaic you can automatically add assets to the asset pipeline just by naming the like the component they belong to. Just require Mozaic in your application assets:
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', "app/assets/javascripts/mozaic/#{options[:name]}.js"
19
- template 'asset.css.erb', "app/assets/stylesheets/mozaic/#{options[:name]}.css"
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
@@ -17,10 +17,5 @@ module Mozaic
17
17
  template 'layout.html.erb', 'app/views/layouts/mozaic.html.erb'
18
18
  end
19
19
 
20
- def create_assets
21
- template 'keep', 'app/assets/javascripts/mozaic/.keep'
22
- template 'keep', 'app/assets/stylesheets/mozaic/.keep'
23
- end
24
-
25
20
  end
26
21
  end
@@ -1,2 +1,3 @@
1
- .mozaic--component.<%= options[:name].split('/').join('.') %>
1
+ .mozaic--component.<%= options[:name].split('/').join('.') %> {
2
2
  /* ... */
3
+ }
@@ -1,4 +1,12 @@
1
- $(document).on( 'turbolinks:load', function() {
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Mozaic
2
2
 
3
- VERSION = '1.2.2'
3
+ VERSION = '2.0.0'
4
4
 
5
5
  end
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: 1.2.2
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-05 00:00:00.000000000 Z
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