Class: Solrengine::Ui::BadgeComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/solrengine/ui/badge_component.rb

Constant Summary collapse

VARIANTS =
{
  success: "bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-400 border-green-200 dark:border-green-800",
  warning: "bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800",
  error: "bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-400 border-red-200 dark:border-red-800",
  info: "bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400 border-blue-200 dark:border-blue-800",
  purple: "bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-400 border-purple-200 dark:border-purple-800"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, variant: :info) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.



16
17
18
19
# File 'app/components/solrengine/ui/badge_component.rb', line 16

def initialize(text:, variant: :info)
  @text = text
  @variant = variant
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



14
15
16
# File 'app/components/solrengine/ui/badge_component.rb', line 14

def text
  @text
end

#variantObject (readonly)

Returns the value of attribute variant.



14
15
16
# File 'app/components/solrengine/ui/badge_component.rb', line 14

def variant
  @variant
end

Instance Method Details

#variant_classesObject



21
22
23
# File 'app/components/solrengine/ui/badge_component.rb', line 21

def variant_classes
  VARIANTS.fetch(variant, VARIANTS[:info])
end