Sha256: 14fc80b9c6ce2d031924a127ab60183e52e96fbfefff44be3be92d16a976b7ac

Contents?: true

Size: 1.48 KB

Versions: 158

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbAvatarActionButton
    class AvatarActionButton
      include Playbook::Props

      prop :action, type: Playbook::Props::String,
                    default: "add"
      prop :image_url, type: Playbook::Props::String
      prop :link_url, type: Playbook::Props::String
      prop :tooltip_text, type: Playbook::Props::String
      prop :tooltip_id, type: Playbook::Props::String
      prop :name, type: Playbook::Props::String,
                  default: ""
      prop :size, type: Playbook::Props::Enum,
                  values: %w[xs sm md lg xl],
                  default: "md"
      prop :placement, type: Playbook::Props::Enum,
                       values: %w[bottom_left bottom_right top_left top_right],
                       default: "bottom_left"

      partial "pb_avatar_action_button/avatar_action_button"

      def classname
        generate_classname("pb_avatar_action_button_kit", action, size, placement)
      end

      def action_icons
        icon_hash = {
          add: "plus-circle",
          remove: "times-circle",
        }
        # if an 'action' prop is passed that isn't
        # in the icon_hash an empty string is returned
        # instead of a null value, which would break the page

        # double pipe ruby syntax below is essentially a reduced if-else statement
        # if icon_hash[action.to_sym] returns a falsey value, return "" instead
        icon_hash[action.to_sym] ||= ""
      end
    end
  end
end

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
playbook_ui-7.3.0 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha11 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha10 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha9 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha8 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha7 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha6 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha5 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha4 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha3 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.3.0.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.2.0 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.2 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.0.pre.alpha2 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.1.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.0.1 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.1 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.0.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb
playbook_ui-7.1.0 app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb