mozaic 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +18 -1
- data/app/helpers/mozaic/component_helper.rb +1 -1
- data/lib/generators/mozaic/component_generator.rb +2 -0
- data/lib/generators/mozaic/install_generator.rb +5 -0
- data/lib/generators/templates/component/asset.css.erb +2 -0
- data/lib/generators/templates/component/asset.js.erb +11 -0
- data/lib/mozaic/component.rb +1 -1
- data/lib/mozaic/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5fedd5a7bc9101ffd3dc4a762f95382080c62725685850e6277b5ea4d4a275c
|
4
|
+
data.tar.gz: cbdb9d46a98df57b58c5c65603a769076f1b1a96abcec13785d854f72580ecaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f210d79c1edee88761405fb708f4634778c115d939d6e7110bb7404d8c25568697bc34f313d09cf2312070686d323fece89f71471eeb17ed328155bf3dd7f3
|
7
|
+
data.tar.gz: 7ad2e1b53b406d50d52c66d611e45203c447b49c12d4ca6bea39d3ba895d5d110f806fc9c171d3454a566fbba9e008d5f8eb2a084096b6f74e5168918f583e0c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -105,7 +105,7 @@ You can run custom code whenever your component gets rendered:
|
|
105
105
|
|
106
106
|
```ruby
|
107
107
|
Mozaic.configure do |config|
|
108
|
-
config.define_component :name, lovely: true do
|
108
|
+
config.define_component :name, lovely: true do |options|
|
109
109
|
options[:lovely] = !options[:lovely]
|
110
110
|
end
|
111
111
|
end
|
@@ -145,6 +145,23 @@ Here is how to access a block in your component:
|
|
145
145
|
= block
|
146
146
|
```
|
147
147
|
|
148
|
+
### Assets
|
149
|
+
|
150
|
+
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:
|
151
|
+
|
152
|
+
```javascript
|
153
|
+
//= require_tree ./mozaic
|
154
|
+
```
|
155
|
+
```css
|
156
|
+
/*
|
157
|
+
*= require_tree ./mozaic
|
158
|
+
*/
|
159
|
+
```
|
160
|
+
|
161
|
+
For instance a component with the name `'my/test/component'` can have a javascript asset located at `app/assets/javascripts/mozaic/my/test/component.js` and a stylesheet under `app/assets/stylesheets/mozaic/my/test/component.css`.
|
162
|
+
|
163
|
+
**Note:** Asset files are being created automatically when using the component generator.
|
164
|
+
|
148
165
|
---
|
149
166
|
|
150
167
|
## Configuration
|
@@ -8,7 +8,7 @@ module Mozaic
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def component_wrapper name, options = {}, &block
|
11
|
-
content_tag class: "#{name.to_s.split('/').join(' ')} #{options[:class]}", id: options[:id] do
|
11
|
+
content_tag class: "mozaic--component #{name.to_s.split('/').join(' ')} #{options[:class]}", id: options[:id] do
|
12
12
|
capture(&block)
|
13
13
|
end
|
14
14
|
end
|
@@ -15,6 +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
20
|
end
|
19
21
|
|
20
22
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$(document).on( 'turbolinks:load', function() {
|
2
|
+
if ( $('.mozaic--component.<%= options[:name].split("/").join(".") %>').length > 0 ) {
|
3
|
+
<%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init();
|
4
|
+
};
|
5
|
+
});
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
function <%= options[:name].split("/").each_with_index.map { |s, i| i == 0 ? s : s.capitalize }.join('') %>Init() {
|
10
|
+
// ...
|
11
|
+
};
|
data/lib/mozaic/component.rb
CHANGED
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: 1.
|
4
|
+
version: 1.1.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-01-
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -95,6 +95,8 @@ files:
|
|
95
95
|
- lib/generators/mozaic/component_generator.rb
|
96
96
|
- lib/generators/mozaic/install_generator.rb
|
97
97
|
- lib/generators/mozaic/layout_generator.rb
|
98
|
+
- lib/generators/templates/component/asset.css.erb
|
99
|
+
- lib/generators/templates/component/asset.js.erb
|
98
100
|
- lib/generators/templates/component/partial.html.erb
|
99
101
|
- lib/generators/templates/install/initializer.rb
|
100
102
|
- lib/generators/templates/install/layout.html.erb
|