Sha256: ec263b7f3d4e1a44e1dbc2c8418a7d71cffa1edcbf62f39d2d66097ee197cbe7

Contents?: true

Size: 1.19 KB

Versions: 323

Compression:

Stored size: 1.19 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

      def envelope_path
        "app/pb_kits/playbook/utilities/icons/envelope.svg"
      end

    private

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

Version data entries

323 entries across 323 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.rc.23 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.22 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.21 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.play1703errorstatealignment5060 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.20 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.19 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.18 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.PLAY1660reactdropzone5020 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.17 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.16 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.play17004992 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.play1703errorstatealignment4991 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.15 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.PLAY16264952 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.PLAY1731inputmasking4927 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4926 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4925 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.14 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.10.0.pre.rc.13 app/pb_kits/playbook/pb_contact/contact.rb
playbook_ui-14.9.0.pre.alpha.PBNTR746datepickerdefaultbug4903 app/pb_kits/playbook/pb_contact/contact.rb