Sha256: eee31f234c9cffa07d1352ca4c37226b7a60e762569b1d67960f6b023cfaba05

Contents?: true

Size: 1.2 KB

Versions: 63

Compression:

Stored size: 1.2 KB

Contents

module IconsHelper
  #FIXME refactor names
  def status_icon(status_like)
    fa_icon *icon_for_status(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 status_fa_icon(status)
    fa_icon(*icon_for_status(status))
  end

  def exercise_status_fa_icon(exercise)
    status_fa_icon(exercise.status_for(current_user))
  end

  def discussion_status_fa_icon(discussion)
    status_fa_icon(discussion.status)
  end

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

  def label_for_status(s)
    iconized = s.iconize
    %Q{
      <span class="text-#{iconized[:class]} status-label">
        #{fa_icon "#{iconized[:type]}"}
        <span>#{t s}</span>
      </span>
    }.html_safe
  end

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

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
mumuki-laboratory-7.3.1 app/helpers/icons_helper.rb
mumuki-laboratory-7.3.0 app/helpers/icons_helper.rb
mumuki-laboratory-7.2.0 app/helpers/icons_helper.rb
mumuki-laboratory-7.1.0 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.12 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.11 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.10 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.9 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.8 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.7 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.6 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.5 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.4 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.3 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.2 app/helpers/icons_helper.rb
mumuki-laboratory-6.7.7 app/helpers/icons_helper.rb
mumuki-laboratory-6.7.6 app/helpers/icons_helper.rb
mumuki-laboratory-6.7.5 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.1 app/helpers/icons_helper.rb
mumuki-laboratory-7.0.0 app/helpers/icons_helper.rb