Sha256: 4c63fdcfa7e989f52b778df648c93e0214fe68433d0597df6abb9628a148a40d

Contents?: true

Size: 656 Bytes

Versions: 4

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

class FoxTail::HelperTextComponent < FoxTail::BaseComponent
  include FoxTail::Concerns::Formable

  has_option :state

  def render?
    content.present? || content_translator.translate.present?
  end

  def before_render
    super

    html_attributes[:class] = classnames theme.apply(:root, self), html_class
  end

  def call
    content_tag :p, retrieve_content, html_attributes
  end

  private

  def retrieve_content
    return content if content?
    return nil unless object_name? && method_name?

    content_translator.translate
  end

  def content_translator
    translator scope: "helpers.help_text"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fox_tail-0.2.1 app/components/fox_tail/helper_text_component.rb
fox_tail-0.2.0 app/components/fox_tail/helper_text_component.rb
fox_tail-0.1.1 app/components/fox_tail/helper_text_component.rb
fox_tail-0.1.0 app/components/fox_tail/helper_text_component.rb