Sha256: cbf1c9170926835a5cd8ddbf603376e576530cfa48812f4c54a049e6c460b079
Contents?: true
Size: 807 Bytes
Versions: 57
Compression:
Stored size: 807 Bytes
Contents
# frozen_string_literal: true class Avo::Fields::Common::BadgeViewerComponent < ViewComponent::Base def initialize(value:, options:) @value = value @options = options @backgrounds = { info: "bg-blue-500", success: "bg-green-500", danger: "bg-red-500", warning: "bg-yellow-500", neutral: "bg-gray-500" } end def classes background = :info @options.invert.each do |values, type| if [values].flatten.map { |value| value.to_s }.include? @value.to_s background = type.to_sym next end end classes = "whitespace-nowrap rounded-md uppercase px-2 py-1 text-xs font-bold block text-center truncate " classes += "#{@backgrounds[background]} text-white" if @backgrounds[background].present? classes end end
Version data entries
57 entries across 57 versions & 1 rubygems