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

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: 5f1a16ed19ecd7a23731a39151a241eb43b044df9c0de15d83cc8b652e1a4bf4
4
- data.tar.gz: e35e533f072fda14f0961b7e99e38c801d81d3fdc5c292f22ad279674d39d407
3
+ metadata.gz: 2f341effc5e3fd8c718c7265494aafa2b78dcfdf287794473a8069e1e8033eca
4
+ data.tar.gz: 968c447e06a755a7316f5870a09291fb90066814d06863669fa9e35dc93fdae3
5
5
  SHA512:
6
- metadata.gz: a4067255fb65f56a5360344f22283b3ed51bdc45d3d190093c24a1af8cc7d73cca9a6a583bd426b33f8c879485e0a9efeb85ab0d1d67d75fdf6282448d1ae3d8
7
- data.tar.gz: 6f64fba2ed10332257dfc8d51f15accbd82f350e423dcaea84a0cbe695ed9e5ad87effb3800e22cfb7aa3320816dc69106ec903fa15f0368ae3fca3709919e41
6
+ metadata.gz: e10eeca46ac23846edf59e8ac053b4fdd174980377478ce62c319baa18365ca751d760eb60857fb19b75ec6fde7cbc9c06aa08b8fbd03f3b3dca38bd7c465d7a
7
+ data.tar.gz: d910dfe3301e08608aacd896a6f524b21126ecedd94963495a4c180a51756dfdb0191c63470d6ec33dca4af609339ee26d728ee9b004d18c3f04e15b5a893698
data/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.0.0] - 2023-08-09
3
+ ## [1.0.0] - 2023-09-12
4
4
 
5
5
  - Initial release
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 = "0.1.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: 0.1.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-08-11 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: