heroicons-ruby 1.0.0 → 2.0.0.pre.beta.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27ba832114f2e581ce7f320d38bc8f768eb1aed34cda757a22285a0a32be8f6
4
- data.tar.gz: f8e9c9b0631492ec54f59b88879e8311730bad91ffaba27259e94f385db91bd3
3
+ metadata.gz: 2f341effc5e3fd8c718c7265494aafa2b78dcfdf287794473a8069e1e8033eca
4
+ data.tar.gz: 968c447e06a755a7316f5870a09291fb90066814d06863669fa9e35dc93fdae3
5
5
  SHA512:
6
- metadata.gz: 66b0cc5fec0e3b1548294c65c31e522e0df0adf8c5fb256aa7719555f9a805019bc30d8213149857e50dc3ac98742b63702b101bc0bc5919742e91a9be2aefee
7
- data.tar.gz: cbd012541b2ac4c630116e7ac7f8830c67c8d19e9f8c15d9a430efc2500ec83d9c14911f004ec60cffa755181b980abd25e787032b97e01f79347d0b51f479cd
6
+ metadata.gz: e10eeca46ac23846edf59e8ac053b4fdd174980377478ce62c319baa18365ca751d760eb60857fb19b75ec6fde7cbc9c06aa08b8fbd03f3b3dca38bd7c465d7a
7
+ data.tar.gz: d910dfe3301e08608aacd896a6f524b21126ecedd94963495a4c180a51756dfdb0191c63470d6ec33dca4af609339ee26d728ee9b004d18c3f04e15b5a893698
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-beta.1"
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.pre.beta.1
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
@@ -1004,9 +1004,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1004
1004
  version: '2.7'
1005
1005
  required_rubygems_version: !ruby/object:Gem::Requirement
1006
1006
  requirements:
1007
- - - ">="
1007
+ - - ">"
1008
1008
  - !ruby/object:Gem::Version
1009
- version: '0'
1009
+ version: 1.3.1
1010
1010
  requirements: []
1011
1011
  rubygems_version: 3.4.6
1012
1012
  signing_key: