elemental_components 1.0.0.rc1 → 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8724d56949364ada3c44e3db2924edb30ea0c4d3929295fc7d0a683a576b2089
4
- data.tar.gz: d7c2d081abf83dbf6e42e68a3eca26ab186dec2f446380a5a94b0a7ec5634857
3
+ metadata.gz: 188ba4f31148a5b63a6bedc1d45471216563c5b50137c575e1846a8a319807fc
4
+ data.tar.gz: 04a1af8dfe65532e07bdef3cbeb62c1e94faf6c7f9fabb4e940504215e80e3b1
5
5
  SHA512:
6
- metadata.gz: a619164930556d15e744814440632e2a44afabcce5ffefafbe99e8d2c5d88883b9e9e849ec4595ddd8d6a8fbf921d89ebc097a098efd084f6e63237abd67c15a
7
- data.tar.gz: 96dfa689ebbb64c40ca722bc9656a45ba27951e0824318f9da114932314652150c47ec4983434a2b3f0efaf58bbf1289e6a3c59a2e1b83aaeee343d36264e0c6
6
+ metadata.gz: abd7a702a6030f480b384100a684c8e7cf841c5fcda44314c3d55e75236991c5a20d5c0042721bf446a6fdb3244253322f12aa1a4cd8b52bdc99a0b1dee8bbb4
7
+ data.tar.gz: f30734ef9349f9baaa9f86b35dc6d865e0bbb64a4a380616db9ca5e9d47a7ace0ccf1aaee3c0943f4f9466be5524a7c48c98508c2680310a3a25937e58d73b6b
data/README.md CHANGED
@@ -94,9 +94,9 @@ Or require `components`, which will in turn require the assets for all component
94
94
  */
95
95
  ```
96
96
 
97
- ### Attributes and blocks
97
+ ### Attributes and content blocks
98
98
 
99
- There are two ways of passing data to components: attributes and blocks. Attributes are useful for data such as ids, modifiers and data structures (models etc). Blocks are useful when you need to inject HTML content into components.
99
+ There are two ways of passing data to components: attributes and content blocks. Attributes are useful for data such as ids, modifiers and data structures (models etc). Content blocks are useful when you need to inject HTML content into components.
100
100
 
101
101
  Let's define some attributes for the component we just created:
102
102
 
@@ -122,13 +122,13 @@ end
122
122
  <%= component "alert", message: "Something went wrong!", context: "danger" %>
123
123
  ```
124
124
 
125
- To inject some text or HTML content into our component we can print the component variable in our template, and populate it by passing a block to the component helper:
125
+ To inject some text or HTML content into our component we can print the component .content method in our template, and populate it by passing a content block to the component helper:
126
126
 
127
127
  ```erb
128
128
  <% # app/components/alert/_alert.html.erb %>
129
129
 
130
130
  <div class="alert alert--<%= alert.context %>" role="alert">
131
- <%= alert %>
131
+ <%= alert.content %>
132
132
  </div>
133
133
  ```
134
134
 
@@ -269,23 +269,27 @@ end
269
269
  <% # app/components/card/_card.html.erb %>
270
270
 
271
271
  <div class="card <%= "card--flush" if card.flush %>">
272
- <div class="card__header <%= "card__header--centered" if card.header.centered %>">
273
- <%= card.header %>
274
- </div>
272
+ <% if card.header.content? %>
273
+ <div class="card__header <%= "card__header--centered" if card.header.centered %>">
274
+ <%= card.header.content %>
275
+ </div>
276
+ <% end%>
275
277
  <% card.sections.each do |section| %>
276
278
  <div class="card__section <%= "card__section--#{section.size}" %>">
277
- <%= section %>
279
+ <%= section.content %>
280
+ </div>
281
+ <% end %>
282
+ <% if card.footer.content? %>
283
+ <div class="card__footer">
284
+ <%= card.footer.content %>
278
285
  </div>
279
286
  <% end %>
280
- <div class="card__footer">
281
- <%= card.footer %>
282
- </div>
283
287
  </div>
284
288
  ```
285
289
 
286
290
  Elements can be thought of as isolated subcomponents, and they are defined on the component. Passing `multiple: true` makes it a repeating element, and passing a block lets us declare attributes on our elements, in the same way we declare attributes on components.
287
291
 
288
- In order to populate them with data, we pass a block to the component helper, which yields the component, which lets us set attributes and blocks on the element in the same way we do for components:
292
+ In order to populate them with data, we pass a block to the component helper, which yields the component, which lets us set attributes and content blocks on the element in the same way we do for components:
289
293
 
290
294
  ```erb
291
295
  <%= component "card", flush: true do |c| %>
@@ -75,7 +75,11 @@ module ElementalComponents
75
75
  validate!
76
76
  end
77
77
 
78
- def to_s
78
+ def content?
79
+ content.present?
80
+ end
81
+
82
+ def content
79
83
  @yield
80
84
  end
81
85
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ElementalComponents
4
- VERSION = "1.0.0.rc1"
4
+ VERSION = "1.0.0.rc2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elemental_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ljungblad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-01 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails