Sha256: 1b901ed9eadb9b60dfa19ba3ea96347b418a9b1ed1e4659de9d5aa6550f1afc0

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbBadge
    class Badge < Playbook::PbKit::Base
      PROPS = %i[
        configured_classname
        configured_data
        configured_id
        configured_text
        configured_variant
        configured_rounded
      ].freeze

      def initialize(classname: default_configuration,
                     data: default_configuration,
                     id: default_configuration,
                     text: default_configuration,
                     variant: default_configuration,
                     rounded: default_configuration)
        self.configured_classname = classname
        self.configured_data = data
        self.configured_id = id
        self.configured_text = text
        self.configured_variant = variant
        self.configured_rounded = rounded
      end

      def text
        default_value(configured_text, "")
      end

      def rounded
        true_value(configured_rounded, "rounded", nil)
      end

      def variant
        variant_options = %w[success warning error info neutral primary]
        one_of_value(configured_variant, variant_options, "neutral")
      end

      def kit_class
        kit_options = [
          "pb_badge_kit",
          variant,
          rounded,
        ]
        kit_options.compact.join("_")
      end

      def to_partial_path
        "pb_badge/badge"
      end

    private

      DEFAULT = Object.new
      private_constant :DEFAULT
      def default_configuration
        DEFAULT
      end
      attr_accessor(*PROPS)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-2.9.1 app/pb_kits/playbook/pb_badge/badge.rb