Class: Avo::Fields::Common::BadgeViewerComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Avo::Fields::Common::BadgeViewerComponent
- Defined in:
- app/components/avo/fields/common/badge_viewer_component.rb
Instance Method Summary collapse
Instance Method Details
#after_initialize ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/components/avo/fields/common/badge_viewer_component.rb', line 7 def after_initialize @backgrounds = { info: "bg-blue-500", success: "bg-green-500", danger: "bg-red-500", warning: "bg-yellow-500", neutral: "bg-gray-500" } end |
#classes ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/avo/fields/common/badge_viewer_component.rb', line 17 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 |