Class: BetterUi::Dialog::AlertComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/better_ui/dialog/alert_component.rb

Constant Summary collapse

ICON_VARIANTS =
{
  success:   :check_circle,
  danger:    :exclamation_circle,
  warning:   :exclamation_triangle,
  info:      :information_circle,
  primary:   :information_circle,
  secondary: :information_circle,
  accent:    :information_circle,
  light:     :information_circle,
  dark:      :information_circle
}.freeze

Constants inherited from ApplicationComponent

ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED

Instance Method Summary collapse

Constructor Details

#initialize(variant: :info, title: nil, text: nil, icon: true, button_label: "OK", size: :sm, close_on_backdrop: true, close_on_escape: true, **options) ⇒ AlertComponent

Returns a new instance of AlertComponent.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/components/better_ui/dialog/alert_component.rb', line 20

def initialize(
  variant: :info,
  title: nil,
  text: nil,
  icon: true,
  button_label: "OK",
  size: :sm,
  close_on_backdrop: true,
  close_on_escape: true,
  **options
)
  @variant = validate_variant(normalize_symbol(variant, :info))
  @title = title
  @text = text
  @icon = icon
  @button_label = button_label
  @size = normalize_symbol(size, :sm)
  @close_on_backdrop = close_on_backdrop
  @close_on_escape = close_on_escape
  @options = options
end