Class: SolidusAdmin::UI::Badge::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::UI::Badge::Component
- Defined in:
- app/components/solidus_admin/ui/badge/component.rb
Constant Summary collapse
- COLORS =
{ graphite_light: "text-black bg-graphite-light", red: 'text-red-500 bg-red-100', green: 'text-forest bg-seafoam', blue: 'text-blue bg-sky', black: 'text-white bg-black', yellow: 'text-orange bg-papaya-whip', }.freeze
- SIZES =
{ s: 'px-2 py-0.5 text-xs font-semibold', m: 'px-3 py-0.5 text-sm font-semibold', l: 'px-3 py-0.5 text-base font-semibold', }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, color: :graphite_light, size: :m) ⇒ Component
constructor
A new instance of Component.
- #name ⇒ Object
Constructor Details
#initialize(name:, color: :graphite_light, size: :m) ⇒ Component
Returns a new instance of Component.
19 20 21 22 23 24 25 26 27 |
# File 'app/components/solidus_admin/ui/badge/component.rb', line 19 def initialize(name:, color: :graphite_light, size: :m) @name = name @class_name = [ 'inline-flex items-center rounded-full whitespace-nowrap', # layout SIZES.fetch(size.to_sym), # size COLORS.fetch(color.to_sym), # color ].join(' ') end |
Class Method Details
.no ⇒ Object
33 34 35 |
# File 'app/components/solidus_admin/ui/badge/component.rb', line 33 def self.no new(name: :no, color: :graphite_light, size: :m) end |
.yes ⇒ Object
29 30 31 |
# File 'app/components/solidus_admin/ui/badge/component.rb', line 29 def self.yes new(name: :yes, color: :green, size: :m) end |
Instance Method Details
#name ⇒ Object
37 38 39 |
# File 'app/components/solidus_admin/ui/badge/component.rb', line 37 def name @name.is_a?(Symbol) ? t(".#{@name}") : @name end |