Class: UI::Badge
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Badge
- Includes:
- BadgeBehavior
- Defined in:
- app/components/ui/badge.rb
Overview
Badge - Phlex implementation
Displays a badge or a component that looks like a badge. Uses BadgeBehavior module for shared styling logic.
Based on shadcn/ui Badge: ui.shadcn.com/docs/components/badge
Instance Method Summary collapse
-
#initialize(variant: :default, classes: "", **attributes) ⇒ Badge
constructor
A new instance of Badge.
- #view_template(&block) ⇒ Object
Methods included from BadgeBehavior
#badge_classes, #badge_html_attributes
Constructor Details
#initialize(variant: :default, classes: "", **attributes) ⇒ Badge
Returns a new instance of Badge.
26 27 28 29 30 |
# File 'app/components/ui/badge.rb', line 26 def initialize(variant: :default, classes: "", **attributes) @variant = variant @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
32 33 34 35 36 |
# File 'app/components/ui/badge.rb', line 32 def view_template(&block) span(**badge_html_attributes.deep_merge(@attributes)) do yield if block_given? end end |