Sha256: 4dbf72c46eb5992f152008cdc7676695ab4f6330b44d76a628d10b4dea8658d2

Contents?: true

Size: 784 Bytes

Versions: 20

Compression:

Stored size: 784 Bytes

Contents

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

    ICON_SIZES = {
      xs: 3,
      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
      [:xs, :sm].include?(@size) ? "p-1" : "p-2"
    end

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

    def dropdown?
      dropdown.present?
    end

    protected

    def alpine_component
      "buttonComponent"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
lookbook-1.5.5 app/components/lookbook/button/component.rb
lookbook-1.5.4 app/components/lookbook/button/component.rb
lookbook-1.5.3 app/components/lookbook/button/component.rb
lookbook-1.5.2 app/components/lookbook/button/component.rb
lookbook-1.5.1 app/components/lookbook/button/component.rb
lookbook-1.5.0 app/components/lookbook/button/component.rb
lookbook-1.4.5 app/components/lookbook/button/component.rb
lookbook-1.4.4 app/components/lookbook/button/component.rb
lookbook-1.4.3 app/components/lookbook/button/component.rb
lookbook-1.4.2 app/components/lookbook/button/component.rb
lookbook-1.4.1 app/components/lookbook/button/component.rb
lookbook-1.4.0 app/components/lookbook/button/component.rb
lookbook-1.3.4 app/components/lookbook/button/component.rb
lookbook-1.3.3 app/components/lookbook/button/component.rb
lookbook-1.3.1 app/components/lookbook/button/component.rb
lookbook-1.3.0 app/components/lookbook/button/component.rb
lookbook-1.2.1 app/components/lookbook/button/component.rb
lookbook-1.2.0 app/components/lookbook/button/component.rb
lookbook-1.1.1 app/components/lookbook/button/component.rb
lookbook-1.1.0 app/components/lookbook/button/component.rb