Module: HeroiconsHelper

Defined in:
lib/heroicons_helper.rb,
lib/heroicons_helper/icon.rb,
lib/heroicons_helper/cache.rb,
lib/heroicons_helper/version.rb

Defined Under Namespace

Classes: Cache, Icon

Constant Summary collapse

ICONS =
JSON.parse(file_data).freeze
VERSION =
"0.9.1"

Instance Method Summary collapse

Instance Method Details

#heroicon(name, variant:, size: nil, **attributes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/heroicons_helper.rb', line 12

def heroicon(name, variant:, size: nil, **attributes)
  cache_key = HeroiconsHelper::Cache.get_key(
    name: name,
    variant: variant,
    size: size,
    attributes: attributes,
  )

  cached_heroicon = HeroiconsHelper::Cache.read(cache_key)
  return cached_heroicon unless cached_heroicon.nil?

  heroicon = ::HeroiconsHelper::Icon.new(name, variant, size: size, attributes: attributes)
  HeroiconsHelper::Cache.set(cache_key, heroicon)

  heroicon
end