Sha256: 4f444478925c61772244a4b4e104efd008c10268396294ea8b9bb93a087f97f7

Contents?: true

Size: 1.25 KB

Versions: 24

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module GoodJob
  module IconsHelper
    STATUS_ICONS = {
      discarded: "exclamation",
      succeeded: "check",
      queued: "dash_circle",
      retried: "arrow_clockwise",
      running: "play",
      scheduled: "clock",
    }.freeze

    STATUS_COLOR = {
      discarded: "danger",
      succeeded: "success",
      queued: "secondary",
      retried: "warning",
      running: "primary",
      scheduled: "secondary",
    }.freeze

    def status_badge(status)
      content_tag :span, status_icon(status, class: "text-white") + t(status, scope: 'good_job.status', count: 1),
                  class: "badge rounded-pill bg-#{STATUS_COLOR.fetch(status)} d-inline-flex gap-2 ps-1 pe-3 align-items-center"
    end

    def status_icon(status, **options)
      options[:class] ||= "text-#{STATUS_COLOR.fetch(status)}"
      icon = render_icon STATUS_ICONS.fetch(status)
      content_tag :span, icon, **options
    end

    def render_icon(name, **options)
      # workaround to render svg icons without all of the log messages
      partial = lookup_context.find_template("good_job/shared/icons/#{name}", [], true)
      options[:class] = Array(options[:class]).join(" ")
      partial.render(self, { class: options[:class] })
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
good_job-4.1.0 app/helpers/good_job/icons_helper.rb
good_job-3.99.1 app/helpers/good_job/icons_helper.rb
good_job-4.0.3 app/helpers/good_job/icons_helper.rb
good_job-4.0.2 app/helpers/good_job/icons_helper.rb
good_job-4.0.1 app/helpers/good_job/icons_helper.rb
good_job-4.0.0 app/helpers/good_job/icons_helper.rb
good_job-3.99.0 app/helpers/good_job/icons_helper.rb
good_job-3.30.1 app/helpers/good_job/icons_helper.rb
good_job-3.30.0 app/helpers/good_job/icons_helper.rb
good_job-3.29.5 app/helpers/good_job/icons_helper.rb
good_job-3.29.4 app/helpers/good_job/icons_helper.rb
good_job-3.29.3 app/helpers/good_job/icons_helper.rb
good_job-3.28.2 app/helpers/good_job/icons_helper.rb
good_job-3.28.1 app/helpers/good_job/icons_helper.rb
good_job-3.28.0 app/helpers/good_job/icons_helper.rb
good_job-3.27.4 app/helpers/good_job/icons_helper.rb
good_job-3.27.3 app/helpers/good_job/icons_helper.rb
good_job-3.27.2 app/helpers/good_job/icons_helper.rb
good_job-3.27.1 app/helpers/good_job/icons_helper.rb
good_job-3.27.0 app/helpers/good_job/icons_helper.rb