fontico 1.2.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee86cae31c0f7f4acb9b303bfd2c06638ea383d86e27ff603452537ec58cfed
4
- data.tar.gz: cf9b3485369dd8601822dad9b1e367bccb41c440620071412b595b755afa97c9
3
+ metadata.gz: 5b63916a176aadaebf800f98fb88b20f58a1bd38652a8ca11a330a25200d7209
4
+ data.tar.gz: 152ec800d410153c87c1b2059a2667d49e2735029aed1fa7959ccaf3304c3ab1
5
5
  SHA512:
6
- metadata.gz: e9e776c9fb99a18085b38a4069f23b72c808ba48c45b321d7948a166c99dd0bf9e93f413dd13a729a5a085148ffdf8e4a1feef544c4babec168e37d037e3b316
7
- data.tar.gz: c5e3727514c2ebaff8c1b879ca9c2468bd2b14df0bef16797f983580b5830ac52b75fd93b9b3f639d433b7e11bac28aedc4c6cacf1d448d66bb2a715cdeccbc5
6
+ metadata.gz: 1d313c8e7c57300beb9b0492409f4be57684d5f3c4ffc5c5546d70de335af4d727587fe32093a80de834e7b58b3b388874a940d18f37b3b8809b87c6be17eb89
7
+ data.tar.gz: c2689f5205be4f820dd7fcd5db0789f0aa6385c85cac02cd10c311af7bbb69a2b1e14d1c210acb54c0216b591c085dd9b8b06afa7efc100cea6a534ca6faed60
data/README.md CHANGED
@@ -196,6 +196,16 @@ sprite same-origin, or switch to inline mode:
196
196
  Fontico.inline_sprite = true # then <%= icons_sprite %> in your layout
197
197
  ```
198
198
 
199
+ ### Symbol ids are namespaced
200
+
201
+ Every `<symbol>` id is `i-` plus the manifest name (`close` is `i-close`,
202
+ `nav.menu` is `i-nav-menu`). An inlined sprite lives in the same document as
203
+ the page, and a bare `id="close"` collides with a `<section id="close">` of
204
+ yours: invalid HTML, an axe `duplicate-id`, `querySelector("#close")` landing
205
+ on the hidden symbol, an anchor `#close` scrolling to it. `icon` and
206
+ `icon_href` write the prefix for you; hand-written markup uses
207
+ `Fontico::Icon::SYMBOL_PREFIX`.
208
+
199
209
  ## Fonts, and Prawn
200
210
 
201
211
  The `ttf` target exists for **PDF generation**, not the web — Prawn reads
@@ -15,7 +15,7 @@ module Fontico
15
15
 
16
16
  def call
17
17
  symbols = @build.map do |icon, body|
18
- %(<symbol id="#{icon.key}" viewBox="0 0 #{@manifest.size} #{@manifest.size}" ) +
18
+ %(<symbol id="#{icon.symbol}" viewBox="0 0 #{@manifest.size} #{@manifest.size}" ) +
19
19
  %(fill="none">#{body}</symbol>)
20
20
  end
21
21
 
@@ -45,7 +45,7 @@ module Fontico
45
45
  entry = Fontico.manifest[key]
46
46
  raise Fontico::Error, "no icon named #{name.inspect} in #{Fontico.manifest_path}" if entry.nil?
47
47
 
48
- "#{sprite_path}##{entry.key}"
48
+ "#{sprite_path}##{entry.symbol}"
49
49
  end
50
50
 
51
51
  # Embeds the symbol definitions directly, for pages served from a CDN
@@ -79,7 +79,7 @@ module Fontico
79
79
  open << "<title>#{ERB::Util.html_escape(title)}</title>" if title
80
80
  open << %(<use href=")
81
81
 
82
- [open.freeze, %(##{entry.key}"></use></svg>).freeze]
82
+ [open.freeze, %(##{entry.symbol}"></use></svg>).freeze]
83
83
  end
84
84
 
85
85
  def safe(str) = str.respond_to?(:html_safe) ? str.html_safe : str
data/lib/fontico/icon.rb CHANGED
@@ -11,5 +11,11 @@ module Fontico
11
11
  # Sprite symbol ids and the id-namespacing prefix both derive from here,
12
12
  # so a rename in the manifest moves them together.
13
13
  def key = name.tr(".", "-")
14
+
15
+ # What the <symbol> is called in the sprite. Namespaced: an inlined sprite
16
+ # shares the document with the page, and a bare "close" is also the page's
17
+ # own #close.
18
+ def symbol = "#{Icon::SYMBOL_PREFIX}#{key}"
14
19
  end
20
+ Icon::SYMBOL_PREFIX = "i-"
15
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fontico
4
- VERSION = "1.2.0"
4
+ VERSION = "2.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontico
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nofxx
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.6.9
132
+ rubygems_version: 4.0.20
133
133
  specification_version: 4
134
134
  summary: Name icons by intent. Source them from anywhere. Ship one artifact.
135
135
  test_files: []