esvg 4.6.8 → 4.6.9
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 +4 -4
- data/README.md +28 -2
- data/lib/esvg/js/embed.js.erb +3 -4
- data/lib/esvg/svgs.rb +1 -0
- data/lib/esvg/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: 389db4f59e10cc4e535d620cc58664ce6a12629c7dce2474c10b8edc7b0aac4c
|
|
4
|
+
data.tar.gz: 71865468e0ad8179c16eb90573f1678ccd438214bc1d5052980ff8cf4f93c694
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9de6fb56c6d98015913835a913dbce16defbd779d319dc49336c312b76677799e0f0c16dc2b616bf8ce7ab1a92e0736f6b9e9203d821d3f117d0b73b994e859d
|
|
7
|
+
data.tar.gz: 785d09aedf8a3e8a19abae86798dfcb5699989a1780808dc98d3709ead53a0c4af39508437b43d1133675108206f966196b187c958cf254a0e926eefa6827615
|
data/README.md
CHANGED
|
@@ -49,9 +49,31 @@ Add this to a page or layout where SVGs should be available
|
|
|
49
49
|
<%= embed_svgs %>
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
### XHR page content
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
If page content is loaded after `domready` and replaces the content of `<body>`, you can register an event listener
|
|
55
|
+
by configuring `xhr_event` in esvg's configuration file to re-embed icons if they have been removed.
|
|
56
|
+
|
|
57
|
+
For example in the Rails community, Turbolinks is a popular system for loading page content with XHR. After it has
|
|
58
|
+
finished its work, it fires a `turbolinks:load` event. If you're using Turbolinks, you'd set `xhr_event` as
|
|
59
|
+
follows.
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
xhr_event: "turbolinks:load"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Which add an the following event listener to esvg's embed script.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
document.addEventListener("turbolinks:load", embed)`
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This will trigger the embed script, addding the symbols to the top of the `<body>` if they were removed in a page
|
|
72
|
+
transition.
|
|
73
|
+
|
|
74
|
+
**During Development:**
|
|
75
|
+
|
|
76
|
+
This will embed a `<script>` which will place svg symbols at the top of your site's `<body>` as soon as the DOM is ready.
|
|
55
77
|
|
|
56
78
|
**In Production:**
|
|
57
79
|
|
|
@@ -120,6 +142,8 @@ $ esvg -c --config foo.yml # Read confguration from foo.yml (otherwise, default
|
|
|
120
142
|
|
|
121
143
|
## Configuration
|
|
122
144
|
|
|
145
|
+
If using Rails, add a configuration file at `config/esvg.yml`.
|
|
146
|
+
|
|
123
147
|
If you're using esvg from the command line, configuration files are read from `./esvg.yml` or you can pass a path with the `--config` option to read the config file from elsewhere.
|
|
124
148
|
|
|
125
149
|
```
|
|
@@ -146,6 +170,8 @@ sizes: # Define size classes for easy assignment
|
|
|
146
170
|
height: 10px
|
|
147
171
|
medium:
|
|
148
172
|
height: 20px
|
|
173
|
+
|
|
174
|
+
xhr_event: "turbolinks:load" # Javascript event name to trigger embedding icons after an xhr page load
|
|
149
175
|
```
|
|
150
176
|
|
|
151
177
|
## Contributing
|
data/lib/esvg/js/embed.js.erb
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
if ( !document.body ) return requestAnimationFrame( embed )
|
|
5
5
|
<%= @embed %>
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
<% if @config[:xhr_event] %>
|
|
8
8
|
// Handle Turbolinks page change events
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
document.addEventListener("<%= @config[:xhr_event] %>", embed)
|
|
10
|
+
<% end %>
|
|
12
11
|
|
|
13
12
|
embed()
|
|
14
13
|
})()
|
data/lib/esvg/svgs.rb
CHANGED
data/lib/esvg/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: esvg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.6.
|
|
4
|
+
version: 4.6.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brandon Mathis
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|