Class: NitroKit::Badge
- Defined in:
- app/components/nitro_kit/badge.rb
Constant Summary collapse
- VARIANTS =
%i[default outline]
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(text = nil, variant: :default, size: :md, color: :gray, **attrs) ⇒ Badge
constructor
A new instance of Badge.
- #view_template(&block) ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(text = nil, variant: :default, size: :md, color: :gray, **attrs) ⇒ Badge
Returns a new instance of Badge.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/nitro_kit/badge.rb', line 7 def initialize(text = nil, variant: :default, size: :md, color: :gray, **attrs) @text = text @variant = variant @size = size @color = color super( attrs, class: [ base_class, variant_class, size_class ] ) end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
23 24 25 |
# File 'app/components/nitro_kit/badge.rb', line 23 def color @color end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
23 24 25 |
# File 'app/components/nitro_kit/badge.rb', line 23 def size @size end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
23 24 25 |
# File 'app/components/nitro_kit/badge.rb', line 23 def text @text end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
23 24 25 |
# File 'app/components/nitro_kit/badge.rb', line 23 def variant @variant end |
Instance Method Details
#view_template(&block) ⇒ Object
25 26 27 28 29 |
# File 'app/components/nitro_kit/badge.rb', line 25 def view_template(&block) span(**attrs) do text_or_block(text, &block) end end |