Sha256: 05e5e0c6fcd9c4a32e0f2d599a829ee699d9a26a6129cb716cfb6428b96f213c

Contents?: true

Size: 615 Bytes

Versions: 4

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module RailsLiveDashboard
  class RequestDurationBadgeComponent < ViewComponent::Base
    CLASSES = {
      ok: 'bg-green-50 text-green-700 ring-green-600/20',
      warning: 'bg-orange-50 text-orange-700 ring-orange-600/10',
      danger: 'bg-red-50 text-red-700 ring-red-600/10'
    }.freeze

    def initialize(duration)
      super

      @duration = duration
      @classes = duration_classes
    end

      private

    def duration_classes
      return CLASSES[:ok] if @duration < 100
      return CLASSES[:warning] if @duration < 500

      CLASSES[:danger]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_live_dashboard-0.2.0 app/components/rails_live_dashboard/request_duration_badge_component.rb
rails_live_dashboard-0.1.2 app/components/rails_live_dashboard/request_duration_badge_component.rb
rails_live_dashboard-0.1.1 app/components/rails_live_dashboard/request_duration_badge_component.rb
rails_live_dashboard-0.1.0 app/components/rails_live_dashboard/request_duration_badge_component.rb