heroicons-ruby 1.0.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 +4 -4
- data/README.md +11 -0
- data/lib/heroicons/config.rb +2 -1
- data/lib/heroicons/helper.rb +4 -2
- data/lib/heroicons/icon.rb +3 -3
- data/lib/heroicons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f86604d9e1b7c19a10721e4516601792904c6be19a38e2af368f9af93504d7a
|
4
|
+
data.tar.gz: 96c0e355472922208f9430109f5c090134ee304f26c47056ee3259c4c6c1432a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41eb3c3095a2804aac9f906cb14e08e3b91af37ce4894c3966e67dd4f82936506be9ed44bc8f432f6135960e8f0240599e9e08b325dce6be3303bcce4c6d3020
|
7
|
+
data.tar.gz: 624bbb7e12a6aa156548133368960880c2fe978fc21208038fd193573c9d4476d8d7175effb32853f1efa27490565b72dd469ac965c5cf8fd8141c55de9faf01
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ bundle add heroicons-ruby
|
|
22
22
|
<%= heroicon "arrow-right", class: "h-4 w-4", fill: "none" %>
|
23
23
|
```
|
24
24
|
|
25
|
+
|
26
|
+
## Configuration
|
25
27
|
Valid `variant` values are `%i[mini solid outline]`. The default variant is `solid` however that default can be changed using:
|
26
28
|
|
27
29
|
```ruby
|
@@ -31,6 +33,15 @@ Heroicons.configure do |config|
|
|
31
33
|
end
|
32
34
|
```
|
33
35
|
|
36
|
+
If you would like to specify default HTML attributes (eg. `class="h-4 w-4"`) for a given `variant`, you can configure that like so:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# config/initializers/heroicons.rb
|
40
|
+
Heroicons.configure do |config|
|
41
|
+
config.attributes[:mini] = { class: "h-4 w-4" }
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
34
45
|
### Rationale
|
35
46
|
|
36
47
|
> Don't libraries already exist for this? Why make another?
|
data/lib/heroicons/config.rb
CHANGED
data/lib/heroicons/helper.rb
CHANGED
@@ -4,8 +4,10 @@ require "action_view/helpers" if defined?(Rails)
|
|
4
4
|
|
5
5
|
module Heroicons
|
6
6
|
module Helper
|
7
|
-
def heroicon(name, variant: Heroicons.config.variant, **
|
8
|
-
icon = Heroicons::Icon.new(name: name,
|
7
|
+
def heroicon(name, variant: Heroicons.config.variant, **attributes)
|
8
|
+
icon = Heroicons::Icon.new(name: name,
|
9
|
+
variant: variant,
|
10
|
+
attributes: Heroicons.config.attributes[variant].merge(attributes))
|
9
11
|
|
10
12
|
raw icon.render
|
11
13
|
end
|
data/lib/heroicons/icon.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Heroicons
|
4
4
|
class Icon
|
5
|
-
def initialize(name:, variant:,
|
5
|
+
def initialize(name:, variant:, attributes: {})
|
6
6
|
@name = name
|
7
7
|
@variant = variant
|
8
|
-
@
|
8
|
+
@attributes = attributes
|
9
9
|
end
|
10
10
|
|
11
11
|
def render
|
@@ -14,7 +14,7 @@ module Heroicons
|
|
14
14
|
doc = Nokogiri::XML::Document.parse(file)
|
15
15
|
svg = doc.at_css("svg")
|
16
16
|
|
17
|
-
@
|
17
|
+
@attributes.each do |k, v|
|
18
18
|
svg[dasherize(k.to_s)] = v
|
19
19
|
end
|
20
20
|
|
data/lib/heroicons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroicons-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- narciero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|