Sha256: 29ffa5052deb9618d0f5b817843a73ff77605dc76948857a211046c5884755ce

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbLoadingInline
    class LoadingInline < Playbook::PbKit::Base
      PROPS = %i[configured_align
                 configured_classname
                 configured_dark
                 configured_data
                 configured_id].freeze

      def initialize(align: default_configuration,
                     classname: default_configuration,
                     dark: default_configuration,
                     data: default_configuration,
                     id: default_configuration)
        self.configured_align = align
        self.configured_classname = classname
        self.configured_dark = dark
        self.configured_data = data
        self.configured_id = id
      end

      def align
        align_options = %w[left center right]
        one_of_value(configured_align, align_options, "left")
      end

      def dark
        is_true? configured_dark
      end

      def icon
        pb_icon = Playbook::PbIcon::Icon.new(fixed_width: true, icon: "spinner", pulse: true)
        ApplicationController.renderer.render(partial: pb_icon, as: :object)
      end

      def value
        pb_icon_value = Playbook::PbBody::Body.new(color: "light", dark: dark) do
          icon + "Loading"
        end
        ApplicationController.renderer.render(partial: pb_icon_value, as: :object)
      end

      def to_partial_path
        "pb_loading_inline/loading_inline"
      end

      def kit_class
        loading_inline_options = [
          "pb_loading_inline_kit",
          align,
        ]
        loading_inline_options.join("_")
      end

    private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-2.9.3 app/pb_kits/playbook/pb_loading_inline/loading_inline.rb
playbook_ui-2.9.2 app/pb_kits/playbook/pb_loading_inline/loading_inline.rb
playbook_ui-2.9.1 app/pb_kits/playbook/pb_loading_inline/loading_inline.rb