Class: HakumiComponents::Modal::StatusComponent

Inherits:
BaseComponent
  • Object
show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/modal/status_component.rb

Constant Summary collapse

IconConfig =
T.type_alias { [ Symbol, String ] }
ICON_CONFIG =
T.let({
  info: [ :info_circle, "#1890ff" ],
  success: [ :check_circle, "#52c41a" ],
  error: [ :close_circle, "#ff4d4f" ],
  warning: [ :warning, "#faad14" ]
}.freeze, T::Hash[Symbol, IconConfig])

Constants inherited from BaseComponent

BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput

Instance Method Summary collapse

Methods inherited from BaseComponent

#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?

Constructor Details

#initialize(id:, title: nil, message: nil, open: false, ok_text: nil, cancel_text: nil, **html_options) ⇒ StatusComponent

Returns a new instance of StatusComponent.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/hakumi_components/modal/status_component.rb', line 28

def initialize(
  id:,
  title: nil,
  message: nil,
  open: false,
  ok_text: nil,
  cancel_text: nil,
  **html_options
)
  @id = T.let(id, String)
  @title = T.let(title, HakumiComponents::Types::Renderable)
  @message = T.let(message, HakumiComponents::Types::Renderable)
  @open = T.let(cast_boolean(open) ? true : false, T::Boolean)
  @ok_text = ok_text
  @cancel_text = cancel_text
  @html_options = T.let(html_options, HakumiComponents::Types::HtmlAttributes)
end

Instance Method Details

#callObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/components/hakumi_components/modal/status_component.rb', line 47

def call
  modal = HakumiComponents::Modal::Component.new(
    id: @id,
    title: resolved_title,
    open: @open,
    closable: false,
    mask_closable: false,
    **@html_options
  )
  modal.with_footer { footer_buttons }

  render(modal) do
    (:div, class: "hakumi-modal-confirm-body-wrapper") do
      safe_join([
        icon_element,
        content_element
      ])
    end
  end
end