Sha256: 52b290fa67d13a12533162980659a3d8ad3dda8030a4a11c00b999f4d6a82a02

Contents?: true

Size: 1.09 KB

Versions: 701

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "action_view"

module Playbook
  module PbContact
    class Contact < Playbook::KitBase
      prop :contact_type
      prop :contact_value
      prop :contact_detail

      def classname
        generate_classname("pb_contact_kit")
      end

      def contact_icon
        case contact_type
        when "cell"
          "mobile"
        when "home"
          "phone"
        when "work"
          "phone-office"
        when "email"
          "envelope"
        when "work-cell"
          "phone-laptop"
        when "wrong-phone"
          "phone-slash"
        when "extension"
          "phone-plus"
        else # "unknown" || "other"
          "phone"
        end
      end

      def formatted_contact_value
        if contact_type == "email"
          contact_value
        elsif contact_type == "extension" && contact_value.match(/^\d{4}$/)
          contact_value
        else
          number_to_phone(formatted_value, area_code: true)
        end
      end

    private

      def formatted_value
        contact_value.to_s.gsub(/\D/, "")
      end
    end
  end
end

Version data entries

701 entries across 701 versions & 1 rubygems

Version Path
playbook_ui-14.2.0.pre.alpha.PLAY15063626 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.PLAY15063624 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.play1432playgroundsanitation3622 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.PLAY15063621 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.PLAY15063620 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.PLAY15063619 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.2.0.pre.alpha.PLAY15063618 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.3.0.pre.rc.0 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063617 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063616 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063615 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063614 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063613 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063612 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PLAY15063610 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PBNTR417addcolorsupdatedefaultcolor3608 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PBNTR449rtepreviewerrails3605 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PA1477timestampkit3601 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3600 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.1.0.pre.alpha.pbntr373enablekitsforradio3595 app/pb_kits/playbook/pb_contact/contact.rb