Class: RailsLiveDashboard::RequestStatusBadgeComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/rails_live_dashboard/request_status_badge_component.rb

Constant Summary collapse

CLASSES =
{
  100..199 => 'bg-blue-50 text-blue-700 ring-blue-700/10',
  200..299 => 'bg-green-50 text-green-700 ring-green-600/20',
  300..399 => 'bg-yellow-50 text-yellow-800 ring-yellow-600/20',
  400..499 => 'bg-orange-50 text-orange-700 ring-orange-600/10',
  500..599 => 'bg-red-50 text-red-700 ring-red-600/10'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(status) ⇒ RequestStatusBadgeComponent

Returns a new instance of RequestStatusBadgeComponent.



13
14
15
16
17
18
19
20
# File 'app/components/rails_live_dashboard/request_status_badge_component.rb', line 13

def initialize(status)
  super

  return if status.nil?

  @status = status
  @classes = CLASSES.detect { |k, _v| k === status }&.last
end