Sha256: 26f9f547db13135a7c3c0d70e5d280c8d11bba787d713ce1ca6d95fefbf556b3

Contents?: true

Size: 1.19 KB

Versions: 48

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module KlassExtension
  def join_classes(*classes)
    UiBibz::Utils::Screwdriver.join_classes classes
  end

  def exclude_classes(arr, *classes)
    UiBibz::Utils::Screwdriver.exclude_classes arr, classes
  end

  # Override this method to add a status class
  def status; end

  def exclude_classes_in_html_options(*classes)
    html_options[:class] = exclude_classes html_options[:class], classes
  end

  private

  def initialize_component_html_classes
    cls = [
      original_html_options,
      state,
      status,
      effect,
      options_classes,
      connect,
      component_html_classes
    ]
    html_options[:class] = join_classes(cls)
  end

  def original_html_options
    transform_classes_to_array(html_options[:class])
  end

  def effect
    options[:effect]
  end

  def options_classes
    transform_classes_to_array(options[:class])
  end

  def state
    options[:state] unless options[:state].nil?
  end

  def connect
    'ui-bibz-connect' unless options[:connect].nil?
  end

  def transform_classes_to_array(classes)
    UiBibz::Utils::Screwdriver.uniq_word_in_string(classes.is_a?(String) ? classes : classes.join(' ')) unless classes.nil?
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
ui_bibz-3.0.13 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.12 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.11 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.10 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.9 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.8 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.7 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.6 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.5 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.4 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.3 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.2 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.1 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta19 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta18 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta17 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta16 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta15 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb
ui_bibz-3.0.0.beta14 lib/ui_bibz/ui/extensions/core/component/klass_extension.rb