Class: LightningUiKit::BannerComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/lightning_ui_kit/banner_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#merge_classes

Methods included from HeroiconHelper

#heroicon

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, **options)
  @type = type
  @title = title
  @options = options
end

Instance Method Details

#classesObject



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_classesObject



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

#iconObject



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