Sha256: 8615bc1994cb3300a11f312efe1cff66b6334f423210272d172ce1f7e6c39179

Contents?: true

Size: 908 Bytes

Versions: 365

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Playbook
  module PbAvatar
    class Avatar < Playbook::KitBase
      prop :image_url, type: Playbook::Props::String
      prop :image_alt, type: Playbook::Props::String,
                       default: ""
      prop :name, type: Playbook::Props::String,
                  default: ""
      prop :size, type: Playbook::Props::Enum,
                  values: %w[xxs xs sm md base lg xl],
                  default: "md"
      prop :status

      def initials
        name.split.map(&:first).join.downcase
      end

      def classname
        generate_classname("pb_avatar_kit", "size_#{size}")
      end

      def online_status_props
        { status: status, classname: "size_#{size}" }
      end

      def alt_text
        image_alt.present? ? image_alt : name
      end

      def handle_img_error
        "this.style.display = 'none'"
      end
    end
  end
end

Version data entries

365 entries across 365 versions & 1 rubygems

Version Path
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg532 app/pb_kits/playbook/pb_avatar/avatar.rb
playbook_ui-12.16.0.pre.alpha.lightboxcurrentphotoprop531 app/pb_kits/playbook/pb_avatar/avatar.rb
playbook_ui-12.16.0.pre.alpha.tiptaptestingpart1528 app/pb_kits/playbook/pb_avatar/avatar.rb
playbook_ui-12.16.0 app/pb_kits/playbook/pb_avatar/avatar.rb
playbook_ui-12.15.0 app/pb_kits/playbook/pb_avatar/avatar.rb