Class: LightningUiKit::AlertComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- LightningUiKit::AlertComponent
- Defined in:
- app/components/lightning_ui_kit/alert_component.rb
Instance Method Summary collapse
- #classes ⇒ Object
- #icon ⇒ Object
- #icon_classes ⇒ Object
-
#initialize(title: nil, type: :info, **options) ⇒ AlertComponent
constructor
A new instance of AlertComponent.
- #title_classes ⇒ Object
Methods inherited from BaseComponent
Methods included from HeroiconHelper
Constructor Details
#initialize(title: nil, type: :info, **options) ⇒ AlertComponent
Returns a new instance of AlertComponent.
4 5 6 7 8 |
# File 'app/components/lightning_ui_kit/alert_component.rb', line 4 def initialize(title: nil, type: :info, **) @title = title @type = type @options = end |
Instance Method Details
#classes ⇒ Object
10 11 12 |
# File 'app/components/lightning_ui_kit/alert_component.rb', line 10 def classes merge_classes([base_classes, type_classes, @options[:class]].compact.join(" ")) end |
#icon ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/components/lightning_ui_kit/alert_component.rb', line 14 def icon case @type when :error then "exclamation-triangle" when :success then "check-circle" when :warning then "exclamation-triangle" else "information-circle" end end |
#icon_classes ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/components/lightning_ui_kit/alert_component.rb', line 23 def icon_classes base = if @title "lui:absolute lui:left-4 lui:top-4 lui:size-4" else "lui:size-4 lui:me-3 lui:shrink-0" end case @type when :error then "#{base} lui:text-destructive-text" when :success then "#{base} lui:text-success-text" when :warning then "#{base} lui:text-warning-text" else "#{base} lui:text-foreground" end end |
#title_classes ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/components/lightning_ui_kit/alert_component.rb', line 38 def title_classes base = "lui:mb-1 lui:font-medium lui:leading-none lui:tracking-tight" case @type when :error then "#{base} lui:text-destructive-text" when :success then "#{base} lui:text-success-text" when :warning then "#{base} lui:text-warning-text" else base end end |