Module: GoodJob::IconsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/good_job/icons_helper.rb
Constant Summary collapse
- 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
Instance Method Summary collapse
- #icons_path ⇒ Object
- #render_icon(name, class: nil, **options) ⇒ Object
- #status_badge(status) ⇒ Object
- #status_icon(status, **options) ⇒ Object
Instance Method Details
#icons_path ⇒ Object
40 41 42 |
# File 'app/helpers/good_job/icons_helper.rb', line 40 def icons_path @_icons_path ||= frontend_static_path(:icons, format: :svg, locale: nil) end |
#render_icon(name, class: nil, **options) ⇒ Object
34 35 36 37 38 |
# File 'app/helpers/good_job/icons_helper.rb', line 34 def render_icon(name, class: nil, **) tag.svg(viewBox: "0 0 16 16", class: "svg-icon #{binding.local_variable_get(:class)}", **) do tag.use(fill: "currentColor", href: "#{icons_path}##{name}") end end |
#status_badge(status) ⇒ Object
23 24 25 26 |
# File 'app/helpers/good_job/icons_helper.rb', line 23 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 |
#status_icon(status, **options) ⇒ Object
28 29 30 31 32 |
# File 'app/helpers/good_job/icons_helper.rb', line 28 def status_icon(status, **) [:class] ||= "text-#{STATUS_COLOR.fetch(status)}" icon = render_icon STATUS_ICONS.fetch(status) content_tag :span, icon, ** end |