Sha256: 42f687b6fd7097065cd0262969a19500b89ca909be22b43518ae4b07788675cb

Contents?: true

Size: 1.51 KB

Versions: 63

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbButton
    class Button < Playbook::KitBase
      prop :disabled, type: Playbook::Props::Boolean,
                      default: false
      prop :full_width, type: Playbook::Props::Boolean,
                        default: false
      prop :link
      prop :loading, type: Playbook::Props::Boolean,
                     default: false
      prop :new_window, type: Playbook::Props::Boolean,
                        default: false
      prop :variant, type: Playbook::Props::Enum,
                     values: %w[primary secondary link],
                     default: "primary"
      prop :text
      prop :type
      prop :value

      def options
        {
          aria: aria,
          class: classname,
          data: data,
          disabled: disabled,
          id: id,
          role: "button",
          type: type,
          value: value,
        }.compact
      end

      def link_options
        options.merge(
          href: link,
          role: "link",
          target: new_window ? "_blank" : "_self"
        )
      end

      def tag
        link ? "a" : "button"
      end

    private

      def classname
        generate_classname("pb_button_kit", variant, full_width_class, disabled_class, loading_class)
      end

      def disabled_class
        disabled ? "disabled" : "enabled"
      end

      def full_width_class
        full_width ? "block" : "inline"
      end

      def loading_class
        loading ? "loading" : nil
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
playbook_ui-10.23.0.pre.cachetest app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.21.0.pre.alpha.rg1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.21.0.pre.alpha.jg1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.21.0.pre.alpha.na1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.21.0.pre.alpha.jd1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.20.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.19.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.19.0.pre.lightbox app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.18.2 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.17.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.16.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.15.1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.15.1.pre.alpha.rubocop.deps app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.15.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.14.1.pre.alpha2 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.14.1.pre.alpha1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.14.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.13.1 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.13.0 app/pb_kits/playbook/pb_button/button.rb
playbook_ui-10.13.0.pre.node.update app/pb_kits/playbook/pb_button/button.rb