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 +4 -4
- data/README.md +16 -12
- data/lib/elemental_components/element.rb +5 -1
- data/lib/elemental_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 188ba4f31148a5b63a6bedc1d45471216563c5b50137c575e1846a8a319807fc
|
4
|
+
data.tar.gz: 04a1af8dfe65532e07bdef3cbeb62c1e94faf6c7f9fabb4e940504215e80e3b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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).
|
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
|
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
|
-
|
273
|
-
<%= card.header %>
|
274
|
-
|
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| %>
|
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.
|
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-
|
11
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|