futurism 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/lib/futurism/helpers.rb +4 -2
- data/lib/futurism/helpers.rb~ +1 -1
- data/lib/futurism/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: 313e2de708762f264a6b0b647e9ae7e1eff5f2463e4ba852e95696ffd8706fb3
|
4
|
+
data.tar.gz: 73f61a471267578dba1e2460cb0c388d96bdf46a52bcae5a047e9c729fe76095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f205ad83640359aaaf72414069bd8a287faf5177b8ec320298c39b82db75eedab9799c45cbff003478804f432d033fc6fe65522ca1de7a5932601fe387c7e8a2
|
7
|
+
data.tar.gz: 56b67210ed5b229298e07216d5b920b358c43758d825ce6dc906faf4a2289dc20feafb2aa8e25ff846802c8ca6bc8fce6061c20f210b1a37690d5798349cac7d
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Futurism
|
2
2
|
[![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch)
|
3
3
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
4
|
-
[![All Contributors](https://img.shields.io/badge/all_contributors-
|
4
|
+
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
|
5
5
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
6
6
|
Lazy-load Rails partials via CableReady
|
7
7
|
|
@@ -20,6 +20,7 @@ Lazy-load Rails partials via CableReady
|
|
20
20
|
- [Resource](#resource)
|
21
21
|
- [Explicit Partial](#explicit-partial)
|
22
22
|
- [HTML Options](#html-options)
|
23
|
+
- [Eager Loading](#eager-loading)
|
23
24
|
- [Events](#events)
|
24
25
|
- [Installation](#installation)
|
25
26
|
- [Manual Installation](#manual-installation)
|
@@ -140,6 +141,19 @@ This will output the following:
|
|
140
141
|
</tr>
|
141
142
|
```
|
142
143
|
|
144
|
+
### Eager Loading
|
145
|
+
It may sound surprising to support eager loading in a lazy loading library :joy:, but there's a quite simple use case:
|
146
|
+
|
147
|
+
Suppose you have some hidden interactive portion of your page, like a tab or dropdown. You don't want its content to block the initial page load, but once that is done, you occasionally don't want to wait for the element to become visible and trigger the `IntersectionObserver`, you want to lazy load its contents right after it's added to the DOM.
|
148
|
+
|
149
|
+
Futurism makes that dead simple:
|
150
|
+
|
151
|
+
```erb
|
152
|
+
<%= futurize 'some_tab', eager: true, extends: :tr do %>
|
153
|
+
<div class="placeholder"</td>
|
154
|
+
<% end %>
|
155
|
+
```
|
156
|
+
|
143
157
|
## Events
|
144
158
|
|
145
159
|
Once your futurize element has been rendered, the `futurize:appeared` custom event will be called.
|
@@ -243,6 +257,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
243
257
|
<td align="center"><a href="https://marcoroth.dev"><img src="https://avatars2.githubusercontent.com/u/6411752?v=4" width="100px;" alt=""/><br /><sub><b>Marco Roth</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=marcoroth" title="Code">💻</a></td>
|
244
258
|
<td align="center"><a href="https://viedit.com"><img src="https://avatars1.githubusercontent.com/u/49990587?v=4" width="100px;" alt=""/><br /><sub><b>Viedit com</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=vieditcom" title="Documentation">📖</a></td>
|
245
259
|
<td align="center"><a href="http://scottbarrow.ca"><img src="https://avatars2.githubusercontent.com/u/5571736?v=4" width="100px;" alt=""/><br /><sub><b>Scott Barrow</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=scottbarrow" title="Code">💻</a></td>
|
260
|
+
<td align="center"><a href="http://domchristie.co.uk"><img src="https://avatars0.githubusercontent.com/u/111734?v=4" width="100px;" alt=""/><br /><sub><b>Dom Christie</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Adomchristie" title="Reviewed Pull Requests">👀</a></td>
|
261
|
+
<td align="center"><a href="http://www.rickychilcott.com"><img src="https://avatars1.githubusercontent.com/u/445759?v=4" width="100px;" alt=""/><br /><sub><b>Ricky Chilcott</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Arickychilcott" title="Reviewed Pull Requests">👀</a></td>
|
246
262
|
</tr>
|
247
263
|
</table>
|
248
264
|
|
data/lib/futurism/helpers.rb
CHANGED
@@ -36,11 +36,12 @@ module Futurism
|
|
36
36
|
class Element
|
37
37
|
include ActionView::Helpers
|
38
38
|
|
39
|
-
attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options
|
39
|
+
attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options, :eager
|
40
40
|
|
41
41
|
def initialize(extends:, placeholder:, options:)
|
42
42
|
@extends = extends
|
43
43
|
@placeholder = placeholder
|
44
|
+
@eager = options.delete(:eager)
|
44
45
|
@html_options = options.delete(:html_options) || {}
|
45
46
|
@data_attributes = html_options.fetch(:data, {}).except(:sgid, :signed_params)
|
46
47
|
@model = options.delete(:model)
|
@@ -50,7 +51,8 @@ module Futurism
|
|
50
51
|
def dataset
|
51
52
|
data_attributes.merge({
|
52
53
|
signed_params: signed_params,
|
53
|
-
sgid: model && model.to_sgid.to_s
|
54
|
+
sgid: model && model.to_sgid.to_s,
|
55
|
+
eager: eager.presence
|
54
56
|
})
|
55
57
|
end
|
56
58
|
|
data/lib/futurism/helpers.rb~
CHANGED
@@ -69,7 +69,7 @@ module Futurism
|
|
69
69
|
require_relative "shims/deep_transform_values" unless options.respond_to? :deep_transform_values
|
70
70
|
|
71
71
|
options.deep_transform_values do |value|
|
72
|
-
value.is_a?(ActiveRecord::Base) ? value.to_global_id.to_s : value
|
72
|
+
value.is_a?(ActiveRecord::Base) && !value.new_record? ? value.to_global_id.to_s : value
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
data/lib/futurism/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futurism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|