Sha256: 099f08359e210b0754d444b96833c05ba0ea3e0fa98fcf48e0f6c837f349701c

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

class FoxTail::DotIndicatorComponent < FoxTail::BaseComponent
  has_option :color, default: :default
  has_option :animated, default: false, type: :boolean
  has_option :size, default: :base

  def call
    animated? ? render_animated_dot : render_dot
  end

  private

  def render_dot
    classes = classnames theme.apply(:root, self), theme.apply(:dot, self), html_class
    content_tag :span, nil, html_attributes.merge(class: classes)
  end

  def render_animated_dot
    container_classes = classnames theme.apply(:root, self),
                                   theme.apply(:container, self),
                                   html_class

    dot_classes = classnames theme.apply(:root, self), theme.apply(:dot, self)
    animated_classes = classnames dot_classes, theme.apply("dot/animation", self)

    content_tag :span, html_attributes.merge(class: container_classes) do
      concat content_tag(:span, nil, class: animated_classes)
      concat content_tag(:span, nil, class: dot_classes)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fox_tail-0.1.1 app/components/fox_tail/dot_indicator_component.rb
fox_tail-0.1.0 app/components/fox_tail/dot_indicator_component.rb