Sha256: 73aa1d811aafa664748f9520c9730961b31114c61339e1ccef6660bc59d6dc87

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

module IconsHelper
  def status_icon(status_like)
    fa_icon *icon_for(status_like.to_submission_status)
  end

  def fixed_fa_icon(name, options = {})
    fa_icon name, options.merge(class: 'fa-fw fixed-icon')
  end

  def exercise_status_icon(exercise)
    link_to exercise_status_fa_icon(exercise),
            exercise_path(exercise) if current_user?
  end

  def language_icon(language)
    tag('span', class: "fa da da-#{language.devicon} lang-icon", alt: language.name)
  end

  private

  def contextualization_fa_icon(contextualization)
    fa_icon(*icon_for(contextualization))
  end

  def exercise_status_fa_icon(exercise)
    contextualization_fa_icon(exercise.assignment_for(current_user))
  end

  def discussion_status_fa_icon(discussion)
    contextualization_fa_icon(discussion)
  end

  def icon_for(iconizable)
    iconized = iconizable.iconize
    [iconized[:type], class: "text-#{iconized[:class]} status-icon"]
  end

  def class_for_exercise(exercise)
    icon_class_for(exercise.assignment_for(current_user))
  end

  def icon_class_for(iconizable)
    iconizable.iconize[:class].to_s
  end

  def icon_type_for(iconizable)
    iconizable.iconize[:type].to_s
  end

  def label_for_contextualization(contextualization, **options)
    iconized = contextualization.iconize
    %Q{
      <span class="text-#{iconized[:class]} status-label">
        #{fa_icon "#{iconized[:type]}"}
        <span class="#{options[:class]}">#{t contextualization.visible_status}</span>
      </span>
    }.html_safe
  end

  def icon_for_read(read)
    tag('i', class: "fa#{read ? 'r' : 's'} fa-envelope")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mumuki-laboratory-8.5.0 app/helpers/icons_helper.rb
mumuki-laboratory-8.4.0 app/helpers/icons_helper.rb
mumuki-laboratory-8.3.0 app/helpers/icons_helper.rb
mumuki-laboratory-8.2.1 app/helpers/icons_helper.rb
mumuki-laboratory-8.2.0 app/helpers/icons_helper.rb