Sha256: 88c9baa616a91918c074f20d080d85df775ef073a96d1570c61bce86abd3cfc2

Contents?: true

Size: 663 Bytes

Versions: 28

Compression:

Stored size: 663 Bytes

Contents

module Lookbook
  class Button::Component < Lookbook::BaseComponent
    renders_one :dropdown

    attr_reader :id, :icon, :button_attrs

    def initialize(id: nil, icon: nil, **html_attrs)
      @id = id
      @icon = icon
      @button_attrs = html_attrs
    end

    def dropdown?
      dropdown.present?
    end

    def text_button?
      content.present?
    end

    def icon_button?
      !text_button? && icon
    end

    def before_render
      if dropdown? && id.nil?
        raise "Dropdown buttons must be given an ID"
      end
    end

    def button_component
      icon_button? ? IconButton::Component : TextButton::Component
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
lookbook-2.0.0.beta.7 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.6 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.5 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.4 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.3 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.2 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.1 app/components/lookbook/button/component.rb
lookbook-2.0.0.beta.0 app/components/lookbook/button/component.rb