Class: NitroKit::Alert
- Defined in:
- app/components/nitro_kit/alert.rb
Constant Summary collapse
- VARIANTS =
%i[default warning error success]
Instance Attribute Summary collapse
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Component
Instance Method Summary collapse
- #description(text = nil, **attrs, &block) ⇒ Object
-
#initialize(variant: :default, **attrs) ⇒ Alert
constructor
A new instance of Alert.
- #title(text = nil, **attrs, &block) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(variant: :default, **attrs) ⇒ Alert
Returns a new instance of Alert.
7 8 9 10 11 12 13 14 15 |
# File 'app/components/nitro_kit/alert.rb', line 7 def initialize(variant: :default, **attrs) @variant = variant super( attrs, role: "alert", class: [ base_class, variant_class ] ) end |
Instance Attribute Details
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
17 18 19 |
# File 'app/components/nitro_kit/alert.rb', line 17 def variant @variant end |
Instance Method Details
#description(text = nil, **attrs, &block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/components/nitro_kit/alert.rb', line 33 def description(text = nil, **attrs, &block) builder do div(**mattr(attrs, class: description_class)) do text_or_block(text, &block) end end end |
#title(text = nil, **attrs, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/components/nitro_kit/alert.rb', line 25 def title(text = nil, **attrs, &block) builder do h5(**mattr(attrs, class: title_class)) do text_or_block(text, &block) end end end |
#view_template ⇒ Object
19 20 21 22 23 |
# File 'app/components/nitro_kit/alert.rb', line 19 def view_template div(**attrs) do yield end end |