Class: Keystone::Ui::BadgeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::BadgeComponent
- Defined in:
- app/components/keystone/ui/badge_component.rb
Constant Summary collapse
- BASE_CLASSES =
"inline-flex items-center rounded-full px-2 py-1 text-xs font-medium"- VARIANT_CLASSES =
{ neutral: "bg-gray-100 text-gray-700 dark:bg-zinc-700 dark:text-gray-300", success: "bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400", danger: "bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-400", warning: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-400", info: "bg-accent-100 text-accent-700 dark:bg-accent-900/50 dark:text-accent-400" }.freeze
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(label:, variant: :neutral) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(label:, variant: :neutral) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
18 19 20 21 |
# File 'app/components/keystone/ui/badge_component.rb', line 18 def initialize(label:, variant: :neutral) @label = label @variant = variant end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
16 17 18 |
# File 'app/components/keystone/ui/badge_component.rb', line 16 def label @label end |
Instance Method Details
#classes ⇒ Object
23 24 25 |
# File 'app/components/keystone/ui/badge_component.rb', line 23 def classes "#{BASE_CLASSES} #{VARIANT_CLASSES.fetch(@variant)}" end |