Sha256: 9c0d08148607ced05b6da0c72f04feedc08834cc67137c40f857f2d71e59f181
Contents?: true
Size: 806 Bytes
Versions: 19
Compression:
Stored size: 806 Bytes
Contents
# frozen_string_literal: true class Avo::Fields::Common::BadgeViewerComponent < Avo::BaseComponent 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
19 entries across 19 versions & 1 rubygems