repository_languages_helper.rb 717 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4 5 6
module RepositoryLanguagesHelper
  def repository_languages_bar(languages)
    return if languages.none?

7
    content_tag :div, class: 'progress repository-languages-bar js-show-on-project-root' do
8 9 10 11 12 13 14 15
      safe_join(languages.map { |lang| language_progress(lang) })
    end
  end

  def language_progress(lang)
    content_tag :div, nil,
      class: "progress-bar has-tooltip",
      style: "width: #{lang.share}%; background-color:#{lang.color}",
Johann Hubert Sonntagbauer's avatar
Johann Hubert Sonntagbauer committed
16
      data: { html: true },
17
      title: "<span class=\"repository-language-bar-tooltip-language\">#{escape_javascript(lang.name)}</span>&nbsp;<span class=\"repository-language-bar-tooltip-share\">#{lang.share.round(1)}%</span>"
18 19
  end
end