Sha256: 7b95c1bb6768c4d30f44687a5490934320e8d6cacda40103229b778a09d94708

Contents?: true

Size: 610 Bytes

Versions: 4

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

module RailsLiveDashboard
  class QueryDurationBadgeComponent < 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 < 10
      return CLASSES[:warning] if @duration < 100

      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/query_duration_badge_component.rb
rails_live_dashboard-0.1.2 app/components/rails_live_dashboard/query_duration_badge_component.rb
rails_live_dashboard-0.1.1 app/components/rails_live_dashboard/query_duration_badge_component.rb
rails_live_dashboard-0.1.0 app/components/rails_live_dashboard/query_duration_badge_component.rb