Class: LightningUiKit::BannerComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- LightningUiKit::BannerComponent
- Defined in:
- app/components/lightning_ui_kit/banner_component.rb
Instance Method Summary collapse
- #classes ⇒ Object
- #default_classes ⇒ Object
- #icon ⇒ Object
-
#initialize(title:, type: :info, **options) ⇒ BannerComponent
constructor
A new instance of BannerComponent.
Methods inherited from BaseComponent
Methods included from HeroiconHelper
Constructor Details
#initialize(title:, type: :info, **options) ⇒ BannerComponent
Returns a new instance of BannerComponent.
6 7 8 9 10 |
# File 'app/components/lightning_ui_kit/banner_component.rb', line 6 def initialize(title:, type: :info, **) @type = type @title = title @options = end |
Instance Method Details
#classes ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/lightning_ui_kit/banner_component.rb', line 12 def classes type_classes = case @type when :error "lui:*:data-[slot=header]:bg-red-600/80 lui:*:data-[slot=header]:text-white" else "lui:*:data-[slot=header]:bg-gray-50" end merge_classes([default_classes, type_classes, @options[:class]].compact.join(" ")) end |
#default_classes ⇒ Object
32 33 34 |
# File 'app/components/lightning_ui_kit/banner_component.rb', line 32 def default_classes "lui:border lui:border-zinc-950/10 lui:rounded-lg lui:overflow-hidden lui:transition-opacity lui:duration-300 lui:ease-out lui:opacity-100" end |
#icon ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/components/lightning_ui_kit/banner_component.rb', line 23 def icon case @type when :error "exclamation-triangle" else "info-circle" end end |