Sha256: 5408883bc534fb73f8b2a144b45a385b14df250c32f988a34e868596b24ba086

Contents?: true

Size: 702 Bytes

Versions: 3

Compression:

Stored size: 702 Bytes

Contents

module Lookbook
  class Button::Component < Lookbook::Component
    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

3 entries across 3 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.2 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.1 app/components/lookbook/button/component.rb
lookbook-1.0.0.beta.0 app/components/lookbook/button/component.rb