Sha256: c16e35387466dca852bc270325e8442e1610a6a28fed4da8e694ac15b1291f46

Contents?: true

Size: 706 Bytes

Versions: 18

Compression:

Stored size: 706 Bytes

Contents

module Lookbook
  class Button::Component < Lookbook::BaseComponent
    renders_one :icon, Lookbook::Icon::Component
    renders_one :dropdown

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

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

    def icon_size
      ICON_SIZES[@size]
    end

    def padding
      @size == :sm ? "p-1" : "p-2"
    end

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

    protected

    def alpine_component
      "buttonComponent"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
lookbook-1.0.8 app/components/lookbook/button/component.rb
lookbook-1.0.7 app/components/lookbook/button/component.rb
lookbook-1.0.6 app/components/lookbook/button/component.rb
lookbook-1.0.5 app/components/lookbook/button/component.rb
lookbook-1.0.4 app/components/lookbook/button/component.rb
lookbook-1.0.3 app/components/lookbook/button/component.rb
lookbook-1.0.2 app/components/lookbook/button/component.rb
lookbook-1.0.1 app/components/lookbook/button/component.rb
lookbook-1.0.0 app/components/lookbook/button/component.rb
lookbook-1.0.0.rc.3 app/components/lookbook/button/component.rb
lookbook-1.0.0.rc.2 app/components/lookbook/button/component.rb
lookbook-1.0.0.rc.1 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.8 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.7 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.6 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.5 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.4 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.3 app/components/lookbook/button/component.rb