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 +4 -4
- data/README.md +1 -1
- data/lib/octicons/octicon.rb +49 -28
- data/lib/octicons/version.rb +1 -1
- data/lib/svg/grabber.svg +1 -0
- data/lib/svg/plug.svg +1 -1
- data/lib/svg/plus-small.svg +1 -0
- data/lib/svg/reply.svg +1 -0
- data/lib/svg/smiley.svg +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3eeb410a24dcd75482f20b6bd0781c925de34c
|
4
|
+
data.tar.gz: eb273834778e0a64abb7c0872668124990de4d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
data/lib/octicons/octicon.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
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 #{
|
26
|
+
"<svg #{html_attributes}>#{@path}</svg>"
|
22
27
|
end
|
23
28
|
|
24
29
|
private
|
25
30
|
|
26
|
-
def
|
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
|
34
|
-
|
38
|
+
def a11y
|
39
|
+
accessible = {}
|
35
40
|
|
36
|
-
if @
|
37
|
-
|
41
|
+
if @options[:'aria-label'].nil?
|
42
|
+
accessible[:'aria-hidden'] = "true"
|
38
43
|
else
|
39
|
-
|
44
|
+
accessible[:role] = "img"
|
40
45
|
end
|
46
|
+
|
47
|
+
accessible
|
41
48
|
end
|
42
49
|
|
43
50
|
# prepare the octicon class
|
44
|
-
def
|
45
|
-
|
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
|
60
|
+
def size
|
61
|
+
size = {
|
62
|
+
:width => @width,
|
63
|
+
:height => @height
|
64
|
+
}
|
50
65
|
|
51
|
-
|
66
|
+
# When size is "large"
|
67
|
+
if @options[:size] == "large"
|
68
|
+
size[:width] = 2 * @width
|
69
|
+
size[:height] = 2 * @height
|
52
70
|
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
58
|
-
|
59
|
-
@
|
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
|
-
|
62
|
-
|
63
|
-
@html_options[:height] = @options[:size]
|
82
|
+
size
|
83
|
+
end
|
64
84
|
|
65
|
-
|
66
|
-
|
67
|
-
|
85
|
+
def calculate_width(height)
|
86
|
+
(height.to_i * @width) / @height
|
87
|
+
end
|
68
88
|
|
69
|
-
|
89
|
+
def calculate_height(width)
|
90
|
+
(width.to_i * @height) / @width
|
70
91
|
end
|
71
92
|
end
|
72
93
|
end
|
data/lib/octicons/version.rb
CHANGED
data/lib/svg/grabber.svg
ADDED
@@ -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
|
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
|
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.
|
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-
|
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
|