Class: Charming::Components::Badge
- Inherits:
-
Charming::Component
- Object
- View
- Charming::Component
- Charming::Components::Badge
- Defined in:
- lib/charming/presentation/components/badge.rb
Overview
Instance Method Summary collapse
-
#initialize(label, style: nil, theme: nil) ⇒ Badge
constructor
label is the badge text.
-
#render ⇒ Object
Renders the pill: a space-padded label with the badge style applied.
Methods inherited from Charming::Component
Methods inherited from View
Constructor Details
#initialize(label, style: nil, theme: nil) ⇒ Badge
label is the badge text. style overrides the default themed style.
12 13 14 15 16 |
# File 'lib/charming/presentation/components/badge.rb', line 12 def initialize(label, style: nil, theme: nil) super(theme: theme) @label = label.to_s @badge_style = style end |
Instance Method Details
#render ⇒ Object
Renders the pill: a space-padded label with the badge style applied.
19 20 21 |
# File 'lib/charming/presentation/components/badge.rb', line 19 def render resolved_style.render(" #{@label} ") end |