octicons 1.0.0 → 1.1.0

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
  SHA1:
3
- metadata.gz: 9d27467c7641ffa5bb3f966ae01fdaf0ad2e92a1
4
- data.tar.gz: f8f51072c94e860d41b600d54f1666f815ced9e1
3
+ metadata.gz: aa3eeb410a24dcd75482f20b6bd0781c925de34c
4
+ data.tar.gz: eb273834778e0a64abb7c0872668124990de4d3c
5
5
  SHA512:
6
- metadata.gz: f0f9f2bd64d282134e40c6523c8f1e972fdd174c7ae65d3e125a03d1a5c4d89253148fcd8b6fbfe38ef6707c5800059224aa747d57ce9cc6c7b415deffab1e77
7
- data.tar.gz: 4e5c1755bab5fccec3b35f3df2a08944615479537b0959f143e74e0fe8c963450fe6810799a7f06c27a89dfe58f59c50fd88001ee6b79878cebf4cb6018e66f6
6
+ metadata.gz: 1462667e821dae27c878c54062e593b8a703d6e600ce4d1bc05d18a22ceec916b6ffb28b6d45525441b33624c417048eecaefc1d5523423f60065b5bae2dea5f
7
+ data.tar.gz: bae7f385ef8fe074dfcf0d4176e21a0e4968d340bf2081bde6b02e708619e66e2c1ee3b21c9bc5a0212a39726be6732535a8235509b4be856058e067e99ccaf2
data/README.md CHANGED
@@ -31,7 +31,7 @@ The `Octicon` class takes a hash of arguments to construct the icon you want
31
31
  #### Options
32
32
 
33
33
  * `:symbol` _(required)_ - This is the name of the octicon you want to use. For example `alert`. [Full list of icons][octicons-docs]
34
- * `:size` - This will help output 16 or 32 sized icons. You can also pass an Integer to this, for other sizes
34
+ * `:size` - This will help output 16 or 32 sized icons. if you pass "large" the icon will be double the size. You can also pass an number and the icon will be scaled properly.
35
35
  * `:width`, `:height` - width and height are exact sizes, if you have an odd shape like the gist logo, pass in exact dimensions
36
36
 
37
37
  Everything else passed in through the options hash will be treated as html attributes and added to the svg tag.
@@ -7,66 +7,87 @@ module Octicons
7
7
  @path = symbol[:path]
8
8
  @width = symbol[:width]
9
9
  @height = symbol[:height]
10
- @html_options = @options.reject { |d| [:symbol, :tag, :size].include? d }
11
10
 
12
- css_class
13
- compute_size
14
- accessible
11
+ # create html_options from options, except for a few
12
+ @html_options = @options.reject { |d| [:symbol, :size].include? d }
13
+ @html_options.merge!({
14
+ :class => classes,
15
+ :viewBox => viewbox,
16
+ :version => "1.1"
17
+ })
18
+ @html_options.merge!(size)
19
+ @html_options.merge!(a11y)
15
20
  else
16
21
  raise "Couldn't find octicon symbol for #{options[:symbol].inspect}"
17
22
  end
18
23
  end
19
24
 
20
25
  def to_svg
21
- "<svg #{html_attrs}>#{@path}</svg>"
26
+ "<svg #{html_attributes}>#{@path}</svg>"
22
27
  end
23
28
 
24
29
  private
25
30
 
26
- def html_attrs
31
+ def html_attributes
27
32
  attrs = ""
28
33
  @html_options.each { |attr, value| attrs += "#{attr}=\"#{value}\" " }
29
34
  attrs.strip
30
35
  end
31
36
 
32
37
  # add some accessibility features to svg
33
- def accessible
34
- @html_options[:version] = "1.1"
38
+ def a11y
39
+ accessible = {}
35
40
 
36
- if @html_options[:'aria-label'].nil?
37
- @html_options[:'aria-hidden'] = "true"
41
+ if @options[:'aria-label'].nil?
42
+ accessible[:'aria-hidden'] = "true"
38
43
  else
39
- @html_options[:role] = "img"
44
+ accessible[:role] = "img"
40
45
  end
46
+
47
+ accessible
41
48
  end
42
49
 
43
50
  # prepare the octicon class
44
- def css_class
45
- @html_options[:class] = "octicon octicon-#{@options[:symbol]} #{@options[:class]} ".strip
51
+ def classes
52
+ "octicon octicon-#{@options[:symbol]} #{@options[:class]} ".strip
53
+ end
54
+
55
+ def viewbox
56
+ "0 0 #{@width} #{@height}"
46
57
  end
47
58
 
48
59
  # determine the height and width of the octicon based on :size option
49
- def compute_size
60
+ def size
61
+ size = {
62
+ :width => @width,
63
+ :height => @height
64
+ }
50
65
 
51
- @html_options[:viewBox] = "0 0 #{@width} #{@height}"
66
+ # When size is "large"
67
+ if @options[:size] == "large"
68
+ size[:width] = 2 * @width
69
+ size[:height] = 2 * @height
52
70
 
53
- if !@options[:width].nil? && !@options[:height].nil?
54
- @html_options[:width] = @options[:width]
55
- @html_options[:height] = @options[:height]
71
+ # When size is an integer
72
+ elsif @options[:size].is_a?(Integer) || !!(@options[:size] =~ /\A[0-9]+\z/)
73
+ size[:width] = calculate_width(@options[:size])
74
+ size[:height] = @options[:size]
56
75
 
57
- elsif @options[:size] == "large"
58
- @html_options[:width] = 2 * @width
59
- @html_options[:height] = 2 * @height
76
+ # Specific size
77
+ elsif !@options[:width].nil? || !@options[:height].nil?
78
+ size[:width] = @options[:width].nil? ? calculate_width(@options[:height]) : @options[:width]
79
+ size[:height] = @options[:height].nil? ? calculate_height(@options[:width]) : @options[:height]
80
+ end
60
81
 
61
- elsif @options[:size].is_a? Integer
62
- @html_options[:width] = (@options[:size] * @width) / @height
63
- @html_options[:height] = @options[:size]
82
+ size
83
+ end
64
84
 
65
- else
66
- @html_options[:width] = @width
67
- @html_options[:height] = @height
85
+ def calculate_width(height)
86
+ (height.to_i * @width) / @height
87
+ end
68
88
 
69
- end
89
+ def calculate_height(width)
90
+ (width.to_i * @height) / @width
70
91
  end
71
92
  end
72
93
  end
@@ -1,3 +1,3 @@
1
1
  module Octicons
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="8" height="16" viewBox="0 0 8 16"><path d="M8 4v1H0V4h8zM0 8h8V7H0v1zm0 3h8v-1H0v1z"/></svg>
data/lib/svg/plug.svg CHANGED
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path d="M14 7V6h-4V4H8v1H6c-1.03 0-1.77.81-2 2L3 8c-1.66 0-3 1.34-3 3v2h1v-2c0-1.11.89-2 2-2l1 1c.25 1.16.98 2 2 2h2v1h2v-2h4v-1h-4V7h4z"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path d="M14 6V5h-4V3H8v1H6c-1.03 0-1.77.81-2 2L3 7c-1.66 0-3 1.34-3 3v2h1v-2c0-1.11.89-2 2-2l1 1c.25 1.16.98 2 2 2h2v1h2v-2h4V9h-4V6h4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="7" height="16" viewBox="0 0 7 16"><path d="M4 7V4H3v3H0v1h3v3h1V8h3V7H4z"/></svg>
data/lib/svg/reply.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path d="M6 3.5c3.92.44 8 3.125 8 10-2.312-5.062-4.75-6-8-6V11L.5 5.5 6 0v3.5z"/></svg>
data/lib/svg/smiley.svg CHANGED
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm4.81 12.81a6.72 6.72 0 0 1-2.17 1.45c-.83.36-1.72.53-2.64.53-.92 0-1.81-.17-2.64-.53-.81-.34-1.55-.83-2.17-1.45a6.773 6.773 0 0 1-1.45-2.17A6.59 6.59 0 0 1 1.21 8c0-.92.17-1.81.53-2.64.34-.81.83-1.55 1.45-2.17.62-.62 1.36-1.11 2.17-1.45A6.59 6.59 0 0 1 8 1.21c.92 0 1.81.17 2.64.53.81.34 1.55.83 2.17 1.45.62.62 1.11 1.36 1.45 2.17.36.83.53 1.72.53 2.64 0 .92-.17 1.81-.53 2.64-.34.81-.83 1.55-1.45 2.17zM4 5.8v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2H5.2C4.53 7 4 6.47 4 5.8zm5 0v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2h-.59C9.53 7 9 6.47 9 5.8zm4 4.2c-.72 1.88-2.91 3-5 3s-4.28-1.13-5-3c-.14-.39.23-1 .66-1h8.59c.41 0 .89.61.75 1z"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm4.81 12.81a6.72 6.72 0 0 1-2.17 1.45c-.83.36-1.72.53-2.64.53-.92 0-1.81-.17-2.64-.53-.81-.34-1.55-.83-2.17-1.45a6.773 6.773 0 0 1-1.45-2.17A6.59 6.59 0 0 1 1.21 8c0-.92.17-1.81.53-2.64.34-.81.83-1.55 1.45-2.17.62-.62 1.36-1.11 2.17-1.45A6.59 6.59 0 0 1 8 1.21c.92 0 1.81.17 2.64.53.81.34 1.55.83 2.17 1.45.62.62 1.11 1.36 1.45 2.17.36.83.53 1.72.53 2.64 0 .92-.17 1.81-.53 2.64-.34.81-.83 1.55-1.45 2.17zM4 6.8v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2H5.2C4.53 8 4 7.47 4 6.8zm5 0v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2h-.59C9.53 8 9 7.47 9 6.8zm4 3.2c-.72 1.88-2.91 3-5 3s-4.28-1.13-5-3c-.14-.39.23-1 .66-1h8.59c.41 0 .89.61.75 1z"/></svg>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octicons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -109,6 +109,7 @@ files:
109
109
  - lib/svg/git-merge.svg
110
110
  - lib/svg/git-pull-request.svg
111
111
  - lib/svg/globe.svg
112
+ - lib/svg/grabber.svg
112
113
  - lib/svg/graph.svg
113
114
  - lib/svg/heart.svg
114
115
  - lib/svg/history.svg
@@ -154,6 +155,7 @@ files:
154
155
  - lib/svg/person.svg
155
156
  - lib/svg/pin.svg
156
157
  - lib/svg/plug.svg
158
+ - lib/svg/plus-small.svg
157
159
  - lib/svg/plus.svg
158
160
  - lib/svg/primitive-dot.svg
159
161
  - lib/svg/primitive-square.svg
@@ -161,6 +163,7 @@ files:
161
163
  - lib/svg/question.svg
162
164
  - lib/svg/quote.svg
163
165
  - lib/svg/radio-tower.svg
166
+ - lib/svg/reply.svg
164
167
  - lib/svg/repo-clone.svg
165
168
  - lib/svg/repo-force-push.svg
166
169
  - lib/svg/repo-forked.svg