Class: Panda::Core::Admin::CalloutComponent
- Defined in:
- app/components/panda/core/admin/callout_component.rb
Overview
Lightweight callout for inline notices (info, warning, success, error). Intended for static, in-form guidance (not toast/flash).
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #default_attrs ⇒ Object
- #default_icon ⇒ Object
- #icon_class ⇒ Object
-
#initialize(text: nil, title: nil, kind: :info, icon: nil, **attrs) ⇒ CalloutComponent
constructor
A new instance of CalloutComponent.
- #tone_classes ⇒ Object
Constructor Details
#initialize(text: nil, title: nil, kind: :info, icon: nil, **attrs) ⇒ CalloutComponent
Returns a new instance of CalloutComponent.
9 10 11 12 13 14 15 |
# File 'app/components/panda/core/admin/callout_component.rb', line 9 def initialize(text: nil, title: nil, kind: :info, icon: nil, **attrs) @text = text @title = title @kind = kind @icon = icon super(**attrs) end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
17 18 19 |
# File 'app/components/panda/core/admin/callout_component.rb', line 17 def icon @icon end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
17 18 19 |
# File 'app/components/panda/core/admin/callout_component.rb', line 17 def kind @kind end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
17 18 19 |
# File 'app/components/panda/core/admin/callout_component.rb', line 17 def text @text end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
17 18 19 |
# File 'app/components/panda/core/admin/callout_component.rb', line 17 def title @title end |
Instance Method Details
#default_attrs ⇒ Object
19 20 21 22 23 |
# File 'app/components/panda/core/admin/callout_component.rb', line 19 def default_attrs { class: "rounded-2xl border px-4 py-3 text-sm #{tone_classes}" } end |
#default_icon ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/panda/core/admin/callout_component.rb', line 29 def default_icon case kind when :success "fa-circle-check" when :warning "fa-triangle-exclamation" when :error, :alert "fa-circle-xmark" else "fa-circle-info" end end |
#icon_class ⇒ Object
25 26 27 |
# File 'app/components/panda/core/admin/callout_component.rb', line 25 def icon_class icon || default_icon end |
#tone_classes ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/components/panda/core/admin/callout_component.rb', line 42 def tone_classes case kind when :success "bg-emerald-50 text-emerald-700 border-emerald-200" when :warning "bg-amber-50 text-amber-700 border-amber-200" when :error, :alert "bg-rose-50 text-rose-700 border-rose-200" else "bg-gray-50 text-gray-700 border-gray-200" end end |