esvg 4.6.8 → 4.6.9

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: a587e4323c912bdbf8a8110e83db8375fcaece3933df6aa0fa20d2ea3b0c97ac
4
- data.tar.gz: 4e5e04891f8db68d221b1a7e1771e0e8d1eff94cf4db83adfaa95e6a3dd8ede5
3
+ metadata.gz: 389db4f59e10cc4e535d620cc58664ce6a12629c7dce2474c10b8edc7b0aac4c
4
+ data.tar.gz: 71865468e0ad8179c16eb90573f1678ccd438214bc1d5052980ff8cf4f93c694
5
5
  SHA512:
6
- metadata.gz: 6b0af9ff543433b47a34a6c12b9d95a4e0db3219d538d71083dd8009c1cf0ced7f8fd3c1c84c53ac272d6cf612da58004054db551e008dbad0f7baac81d0014b
7
- data.tar.gz: 53ca074faa1f6b99ed95c95765def4051ceabb917c95d238bcfbf110dc75b61cd3129a9da77e4348191cb54eafa52c69a48662f1c1c75a64b2ad4c6c528854aa
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
- **During development:**
52
+ ### XHR page content
53
53
 
54
- 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, and after any Turbolinks page load events.
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
@@ -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
- if ( window.Turbolinks ) {
10
- document.addEventListener("turbolinks:load", function(event) { embed() })
11
- }
9
+ document.addEventListener("<%= @config[:xhr_event] %>", embed)
10
+ <% end %>
12
11
 
13
12
  embed()
14
13
  })()
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'zlib'
4
4
  require 'digest'
5
5
  require 'esvg/symbol'
6
+ require 'erb'
6
7
 
7
8
  module Esvg
8
9
  class Svgs
@@ -1,3 +1,3 @@
1
1
  module Esvg
2
- VERSION = "4.6.8"
2
+ VERSION = "4.6.9"
3
3
  end
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.8
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-05-30 00:00:00.000000000 Z
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler