Sha256: d94e10906cc345db418fc0abf762eb16d3a6902acc7c3a39feb2a65738c257df

Contents?: true

Size: 775 Bytes

Versions: 17

Compression:

Stored size: 775 Bytes

Contents

module Lookbook
  class TextButton::Component < Lookbook::BaseComponent
    renders_many :icons, Icon::Component

    ICON_SIZES = {
      xs: 3,
      sm: 3.5,
      md: 4,
      lg: 6
    }

    attr_reader :icon, :tooltip, :disabled, :size, :href

    def initialize(id: nil, icon: nil, tooltip: nil, disabled: false, size: :md, href: nil, **html_attrs)
      @id = id
      @icon = icon
      @tooltip = tooltip
      @disabled = disabled
      @size = size
      @href = href
      super(**html_attrs)
    end

    def id
      @id ||= Utils.temp_id(prefix: "button")
    end

    def icon_size
      ICON_SIZES[size]
    end

    def tag_name
      href.present? ? :a : :button
    end

    protected

    def alpine_component
      "buttonComponent"
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lookbook-2.0.3 app/components/lookbook/text_button/component.rb
lookbook-2.0.2 app/components/lookbook/text_button/component.rb
lookbook-2.0.1 app/components/lookbook/text_button/component.rb
lookbook-2.0.0 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.rc.3 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.rc.2 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.rc.1 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.9 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.8 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.7 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.6 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.5 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.4 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.3 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.2 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.1 app/components/lookbook/text_button/component.rb
lookbook-2.0.0.beta.0 app/components/lookbook/text_button/component.rb