Sha256: 6f6790bf9321c76c0b4739dce3f01ca20d581362ac4580596294d62946a26dc9

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

class Icon < ApplicationComponent
  param :name, reader: false
  option :variant, reader: false, default: -> { }
  option :size, default: -> { :md }, reader: false

  def template
    div(**attrs) do
      render Protos::Icon.heroicon(@name, variant:)
    end
  end

  private

  def variant
    @variant || {
      xs: :micro,
      sm: :mini,
      md: :solid,
      lg: :solid
    }.fetch(@size)
  end

  def size
    {
      xs: "w-3 h-3",
      sm: "w-4 h-4",
      md: "w-5 h-5",
      lg: "w-7 h-7"
    }.fetch(@size)
  end

  def theme
    {
      container: tokens(size, "opacity-90", "inline-block")
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staticky-0.3.1 site_template/lib/icon.rb
staticky-0.3.0 site_template/lib/icon.rb