Sha256: 53b24e84594911ac31d64c1ad1db2c51a3dd74fdb257b159ab1f739aa3cc2a28

Contents?: true

Size: 1.03 KB

Versions: 323

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbDashboardValue
    class DashboardValue < Playbook::KitBase
      prop :align, type: Playbook::Props::Enum,
                   values: %w[left center right],
                   default: "left"
      prop :stat_change, type: Playbook::Props::Hash,
                         default: {}
      prop :stat_label
      prop :stat_value, type: Playbook::Props::Hash,
                        default: {}

      def formatted_stat_value
        { **stat_value, value: sanitized_stat_value }
      end

      def classname
        generate_classname("pb_dashboard_value_kit", align)
      end

      # rubocop:disable Lint/FloatComparison
      # Comparing the value coerced to a float versus an integer is the point of this methodd
      def sanitized_stat_value
        value = stat_value[:value]
        if value.is_a?(::String)
          value.to_f == value.to_i ? value.to_i : value.to_f
        else
          value
        end
      end
      # rubocop:enable Lint/FloatComparison
    end
  end
end

Version data entries

323 entries across 323 versions & 1 rubygems

Version Path
playbook_ui-12.38.0.pre.alpha.PLAY966collapsiblenav41086 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.38.0.pre.alpha.audiencesalpha1083 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.38.0.pre.alpha.PLAY966collapsiblenav41082 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.38.0.pre.alpha.PLAYaddingdatapropselectkit1080 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31078 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.38.0.pre.alpha.playbook123801077 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31074 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31073 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.PLAYaddingdatapropselectkit1071 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.38.0 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.svgiconmethods1064 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31062 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.37.0 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.svgiconmethods1059 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1058 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1050 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1047 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.svgiconmethods1043 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0.pre.alpha.PLAY942collapsiblenav21035 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb
playbook_ui-12.36.0 app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb