basicons 1.0.2 → 1.0.4
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/lib/assets/data.json +320 -320
- data/lib/basicons/basicon.rb +29 -52
- data/lib/basicons/version.rb +1 -1
- metadata +3 -3
data/lib/basicons/basicon.rb
CHANGED
@@ -1,74 +1,51 @@
|
|
1
1
|
module Basicons
|
2
2
|
class Basicon
|
3
|
-
|
4
|
-
|
5
|
-
attr_reader :data, :symbol
|
6
|
-
attr_reader :width, :height, :options
|
3
|
+
attr_reader :data, :size
|
4
|
+
attr_reader :symbol, :options
|
7
5
|
|
8
6
|
def initialize(symbol, options = {})
|
9
7
|
@symbol = symbol.to_s
|
10
|
-
|
11
|
-
|
8
|
+
@options = options.dup
|
9
|
+
|
10
|
+
if @data = Basicons::SVG_DATA[@symbol]
|
11
|
+
@options.merge!({
|
12
|
+
class: classes,
|
13
|
+
width: svg_size,
|
14
|
+
height: svg_size,
|
15
|
+
viewBox: '0 0 24 24',
|
16
|
+
stroke: 'currentColor',
|
17
|
+
fill: 'none'
|
18
|
+
})
|
19
|
+
|
20
|
+
@options['stroke-width'] = 2
|
21
|
+
@options['stroke-linecap'] = 'round'
|
22
|
+
@options['stroke-linejoin'] = 'round'
|
23
|
+
@options['xmlns'] = 'http://www.w3.org/2000/svg'
|
12
24
|
else
|
13
|
-
raise "
|
25
|
+
raise "<#{@symbol}> not found"
|
14
26
|
end
|
15
|
-
|
16
|
-
# @path = octicon["path"]
|
17
|
-
# @width = octicon["width"]
|
18
|
-
# @height = octicon["height"]
|
19
|
-
# @options = options.dup
|
20
|
-
# @options.merge!({
|
21
|
-
# class: classes,
|
22
|
-
# viewBox: viewbox,
|
23
|
-
# version: "1.1"
|
24
|
-
# })
|
25
|
-
# @options.merge!(size)
|
26
|
-
# @options.merge!(a11y)
|
27
|
-
|
28
27
|
end
|
29
28
|
|
30
29
|
def to_svg
|
31
|
-
"<svg #{html_attributes}>#{@
|
30
|
+
"<svg #{html_attributes}>#{@data}</svg>"
|
32
31
|
end
|
33
32
|
|
34
33
|
private
|
35
34
|
|
36
|
-
def html_attributes
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# attrs.strip
|
35
|
+
def html_attributes(result = '')
|
36
|
+
@options.each { |key, value| result += "#{key}=\"#{value}\" " }
|
37
|
+
result.strip
|
38
|
+
end
|
41
39
|
|
40
|
+
def svg_size
|
41
|
+
return @size unless @size.nil?
|
42
|
+
@size = @options[:size].to_i
|
43
|
+
@size = 16 if @size.zero?
|
44
|
+
@size
|
42
45
|
end
|
43
46
|
|
44
47
|
def classes
|
45
48
|
"basicon basicon-#{@symbol} #{@options[:class]}".strip
|
46
49
|
end
|
47
|
-
|
48
|
-
def viewbox
|
49
|
-
"0 0 #{@width} #{@height}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def find_basicon(symbol, options = {})
|
53
|
-
basicon = Basicons::SVG_DATA[symbol]
|
54
|
-
return if basicon.nil?
|
55
|
-
|
56
|
-
{}
|
57
|
-
|
58
|
-
# return {
|
59
|
-
# "name" => octicon["name"],
|
60
|
-
# "width" => octicon["heights"][natural_height.to_s]["width"].to_i,
|
61
|
-
# "height" => natural_height,
|
62
|
-
# "path" => octicon["heights"][natural_height.to_s]["path"]
|
63
|
-
# }
|
64
|
-
end
|
65
50
|
end
|
66
51
|
end
|
67
|
-
|
68
|
-
# def size
|
69
|
-
# size = {
|
70
|
-
# width: @width,
|
71
|
-
# height: @height
|
72
|
-
# }
|
73
|
-
# size
|
74
|
-
# end
|
data/lib/basicons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basicons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Basicons Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|