Class: PandaCms::Admin::TagComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/panda_cms/admin/tag_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statusObject

Returns the value of attribute status.



6
7
8
# File 'app/components/panda_cms/admin/tag_component.rb', line 6

def status
  @status
end

#textObject

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

#callObject



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

   :span, class: classes do
    @text
  end
end