heroicons-ruby 1.0.0 → 2.0.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
  SHA256:
3
- metadata.gz: f27ba832114f2e581ce7f320d38bc8f768eb1aed34cda757a22285a0a32be8f6
4
- data.tar.gz: f8e9c9b0631492ec54f59b88879e8311730bad91ffaba27259e94f385db91bd3
3
+ metadata.gz: 6f86604d9e1b7c19a10721e4516601792904c6be19a38e2af368f9af93504d7a
4
+ data.tar.gz: 96c0e355472922208f9430109f5c090134ee304f26c47056ee3259c4c6c1432a
5
5
  SHA512:
6
- metadata.gz: 66b0cc5fec0e3b1548294c65c31e522e0df0adf8c5fb256aa7719555f9a805019bc30d8213149857e50dc3ac98742b63702b101bc0bc5919742e91a9be2aefee
7
- data.tar.gz: cbd012541b2ac4c630116e7ac7f8830c67c8d19e9f8c15d9a430efc2500ec83d9c14911f004ec60cffa755181b980abd25e787032b97e01f79347d0b51f479cd
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?
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Heroicons
4
4
  class Config
5
- attr_accessor :variant
5
+ attr_accessor :variant, :attributes
6
6
 
7
7
  def initialize
8
8
  @variant = :solid
9
+ @attributes = Hash.new { |_hash, _key| {} }
9
10
  end
10
11
  end
11
12
 
@@ -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, **options)
8
- icon = Heroicons::Icon.new(name: name, variant: variant, options: options)
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
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Heroicons
4
4
  class Icon
5
- def initialize(name:, variant:, options: {})
5
+ def initialize(name:, variant:, attributes: {})
6
6
  @name = name
7
7
  @variant = variant
8
- @options = options
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
- @options.each do |k, v|
17
+ @attributes.each do |k, v|
18
18
  svg[dasherize(k.to_s)] = v
19
19
  end
20
20
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Heroicons
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
5
5
  end
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: 1.0.0
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-09-12 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport