protos-icon 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be71de1dae784951dfb87869dad29c386fdef6a60aef1ed3b9bf6bb8168235b6
4
- data.tar.gz: f7c85011868849f8b86a62d08144be570be431337bd93c1cc61e0b29b316c665
3
+ metadata.gz: cb262274d7a7863a8af407ae211479020a4f08e34c4e7b4837f9ae3daf7c4eb6
4
+ data.tar.gz: 867bf51e20c59e6b1e2b9f4a2d5cbecc5fbd760f9574dd0179ef364862dbf2c6
5
5
  SHA512:
6
- metadata.gz: ba683ab5c5c99ad28d8a4ef69a7da23304107f8c84bd6c00e6eef544bfa72e0b5e49faa60da1856c01f4eb4e0828e701ef1e291eca08bdcbfd2b30c767bf4fe3
7
- data.tar.gz: ea3dc1fac8db1a0fd42771ace1148b9668ff0b0cdd6b9f5d6153503798f79d49da1c1d72fa1ca8d0be7e2c8ca2d1fb5a4ad2db1eafa101399351fd39d44b2cce
6
+ metadata.gz: 0a72f28c09bdac1413de90a59fcb77b2d07d0607ede4be84ddda56e7a63fa9a1f314c00b7d9996edfaf77a305285112a3ab6fe5b77f5f6395e117034a1a10a4e
7
+ data.tar.gz: 0a0e57768b4d1311cf083856caa3de2b09ca08caf388fd9e0cc92e0c3846007ec72c5e7d3d19313b20d23fc0eb70d4e939cd1ec383af27d2aa75c02c0fbc7047
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2024-12-18
4
+
5
+ - Adds custom Inhouse icons
6
+ - Changes argument error to `MissingIcon` error
7
+
3
8
  ## [0.1.0] - 2024-03-03
4
9
 
5
10
  - Initial release
@@ -0,0 +1,9 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ class="fill-current">
7
+ <path d="M9 8h-3v4h3v12h5v-12h3.642l.358-4h-4v-1.667c0-.955.192-1.333 1.115-1.333h2.885v-5h-3.808c-3.596 0-5.192 1.583-5.192 4.615v3.385z">
8
+ </path>
9
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ class="fill-current">
7
+ <path d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z">
8
+ </path>
9
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ class="fill-current">
7
+ <path d="M19.615 3.184c-3.604-.246-11.631-.245-15.23 0-3.897.266-4.356 2.62-4.385 8.816.029 6.185.484 8.549 4.385 8.816 3.6.245 11.626.246 15.23 0 3.897-.266 4.356-2.62 4.385-8.816-.029-6.185-.484-8.549-4.385-8.816zm-10.615 12.816v-8l8 3.993-8 4.007z">
8
+ </path>
9
+ </svg>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ module Icon
5
+ class Component < Phlex::HTML
6
+ def initialize(filepath)
7
+ @filepath = filepath
8
+ end
9
+
10
+ def view_template
11
+ unsafe_raw File.read(@filepath)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ module Icon
5
+ module Heroicons
6
+ def self.build(name, variant: :solid)
7
+ filepath = lookup(name, variant:)
8
+ Component.new(filepath)
9
+ end
10
+
11
+ def self.lookup(name, variant: :solid)
12
+ filepath = Pathname.new(GEM_ROOT)
13
+ filepath = case variant
14
+ when :solid then filepath.join("assets/heroicons/24/solid")
15
+ when :outline then filepath.join("assets/heroicons/24/outline")
16
+ when :mini then filepath.join("assets/heroicons/20/solid")
17
+ when :micro then filepath.join("assets/heroicons/16/solid")
18
+ else raise ArgumentError, "Unknown variant: #{variant}"
19
+ end
20
+
21
+ filepath
22
+ .join("#{name}.svg")
23
+ .tap do |path|
24
+ File.exist?(path) or raise MissingIcon, "Unknown icon: #{name}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ module Icon
5
+ module Inhouse
6
+ def self.build(name)
7
+ filepath = lookup(name)
8
+ Component.new(filepath)
9
+ end
10
+
11
+ def self.lookup(name)
12
+ assets = Pathname.new(GEM_ROOT).join("assets/inhouse")
13
+
14
+ assets
15
+ .join("#{name}.svg")
16
+ .tap do |path|
17
+ File.exist?(path) or raise MissingIcon, "Unknown icon: #{name}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Protos
4
4
  module Icon
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/lib/protos/icon.rb CHANGED
@@ -3,54 +3,45 @@
3
3
  require "phlex"
4
4
 
5
5
  require_relative "icon/version"
6
+ require_relative "icon/heroicons"
7
+ require_relative "icon/inhouse"
8
+ require_relative "icon/component"
6
9
 
7
10
  module Protos
8
11
  module Icon
9
12
  # Your code goes here...
13
+ class Error < StandardError; end
14
+ MissingIcon = Class.new(Error)
10
15
 
11
16
  GEM_ROOT = Pathname.new(__dir__).join("..", "..").expand_path
12
17
  public_constant :GEM_ROOT
13
18
 
14
- class Component < Phlex::HTML
15
- def initialize(filepath)
16
- @filepath = filepath
17
- end
19
+ def self.heroicon(name, variant: :solid)
20
+ Heroicons.build(name, variant:)
21
+ end
18
22
 
19
- def view_template
20
- unsafe_raw File.read(@filepath)
21
- end
23
+ def self.inhouse(name, **)
24
+ Inhouse.build(name)
22
25
  end
23
26
 
24
- module Heroicons
25
- def self.new(name, variant: :solid)
26
- filepath = lookup(name, variant:)
27
- Component.new(filepath)
28
- end
29
-
30
- def self.lookup(name, variant: :solid)
31
- filepath = Pathname.new(GEM_ROOT)
32
- filepath = case variant
33
- when :solid then filepath.join("assets/heroicons/24/solid")
34
- when :outline then filepath.join("assets/heroicons/24/outline")
35
- when :mini then filepath.join("assets/heroicons/20/solid")
36
- when :micro then filepath.join("assets/heroicons/16/solid")
37
- else raise ArgumentError, "Unknown variant: #{variant}"
38
- end
39
-
40
- filepath
41
- .join("#{name}.svg")
42
- .tap do |path|
43
- File.exist?(path) or raise ArgumentError, "Unknown icon: #{name}"
44
- end
45
- end
27
+ def self.build(name, ...)
28
+ component = maybe(Heroicons, name, ...)
29
+ component ||= maybe(Inhouse, name, ...)
30
+ raise MissingIcon, "Could not find an icon for #{name}" unless component
31
+
32
+ component
46
33
  end
47
34
 
48
- def self.heroicon(name, variant: :solid)
49
- Heroicons.new(name, variant:)
35
+ def self.maybe(mod, name, ...)
36
+ mod.build(name, ...)
37
+ rescue MissingIcon
38
+ nil
50
39
  end
51
40
 
52
41
  def icon(...)
53
- render Protos::Icon.heroicon(...)
42
+ raise MissingIcon unless component = Protos::Icon.build(...)
43
+
44
+ render component
54
45
  end
55
46
  end
56
47
  end
data/protos-icon.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  # For more information and examples about making a new gem, check out our
37
37
  # guide at: https://bundler.io/guides/creating_gem.html
38
+ spec.metadata['rubygems_mfa_required'] = 'true'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protos-icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan J Tait
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-07 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -1213,7 +1213,13 @@ files:
1213
1213
  - assets/heroicons/24/solid/wrench.svg
1214
1214
  - assets/heroicons/24/solid/x-circle.svg
1215
1215
  - assets/heroicons/24/solid/x-mark.svg
1216
+ - assets/inhouse/facebook.svg
1217
+ - assets/inhouse/twitter.svg
1218
+ - assets/inhouse/youtube.svg
1216
1219
  - lib/protos/icon.rb
1220
+ - lib/protos/icon/component.rb
1221
+ - lib/protos/icon/heroicons.rb
1222
+ - lib/protos/icon/inhouse.rb
1217
1223
  - lib/protos/icon/version.rb
1218
1224
  - protos-icon.gemspec
1219
1225
  homepage: https://github.com/inhouse-work/protos-icon
@@ -1223,6 +1229,7 @@ metadata:
1223
1229
  homepage_uri: https://github.com/inhouse-work/protos-icon
1224
1230
  source_code_uri: https://github.com/inhouse-work/protos-icon
1225
1231
  changelog_uri: https://github.com/inhouse-work/protos-icon
1232
+ rubygems_mfa_required: 'true'
1226
1233
  post_install_message:
1227
1234
  rdoc_options: []
1228
1235
  require_paths:
@@ -1238,7 +1245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1238
1245
  - !ruby/object:Gem::Version
1239
1246
  version: '0'
1240
1247
  requirements: []
1241
- rubygems_version: 3.5.7
1248
+ rubygems_version: 3.5.22
1242
1249
  signing_key:
1243
1250
  specification_version: 4
1244
1251
  summary: ''