Class: PandaCms::Admin::TagComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- PandaCms::Admin::TagComponent
- Defined in:
- app/components/panda_cms/admin/tag_component.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(status: :active, text: nil) ⇒ TagComponent
constructor
A new instance of TagComponent.
Constructor Details
#initialize(status: :active, text: nil) ⇒ TagComponent
Returns a new instance of TagComponent.
8 9 10 11 |
# File 'app/components/panda_cms/admin/tag_component.rb', line 8 def initialize(status: :active, text: nil) @status = status.to_sym @text = text || status.to_s.humanize end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'app/components/panda_cms/admin/tag_component.rb', line 6 def status @status end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'app/components/panda_cms/admin/tag_component.rb', line 6 def text @text end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/components/panda_cms/admin/tag_component.rb', line 13 def call classes = "inline-flex items-center py-1 px-2 text-xs font-medium rounded-md ring-1 ring-inset " classes += case @status when :active "text-white ring-black/30 bg-active border-0 " when :draft "text-black ring-black/30 bg-warning " when :inactive, :hidden "text-black ring-black/30 bg-black/5 bg-white " else "text-black bg-white " end content_tag :span, class: classes do @text end end |