Class: Arara::DialogComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/dialog_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_options, #html_tag, included

Constructor Details

#initialize(role: "alertdialog", labelledby:, describedby:, surface_class: nil, **kw) ⇒ DialogComponent

Returns a new instance of DialogComponent.



9
10
11
12
13
14
15
16
# File 'app/components/arara/dialog_component.rb', line 9

def initialize(role: "alertdialog", labelledby:, describedby:, surface_class: nil, **kw)
  super(tag: "div", role: role, **kw)

  @role = role
  @labelledby = labelledby
  @describedby = describedby
  @surface_class = surface_class
end

Instance Attribute Details

#describedbyObject (readonly)

Returns the value of attribute describedby.



7
8
9
# File 'app/components/arara/dialog_component.rb', line 7

def describedby
  @describedby
end

#labelledbyObject (readonly)

Returns the value of attribute labelledby.



7
8
9
# File 'app/components/arara/dialog_component.rb', line 7

def labelledby
  @labelledby
end

#roleObject (readonly)

Returns the value of attribute role.



7
8
9
# File 'app/components/arara/dialog_component.rb', line 7

def role
  @role
end

#surface_classObject (readonly)

Returns the value of attribute surface_class.



7
8
9
# File 'app/components/arara/dialog_component.rb', line 7

def surface_class
  @surface_class
end

Instance Method Details

#default_html_classObject



19
20
21
# File 'app/components/arara/dialog_component.rb', line 19

def default_html_class
  "mdc-dialog"
end

#surface_optionsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/arara/dialog_component.rb', line 23

def surface_options
  html_class = ["mdc-dialog__surface"]
  html_class << surface_class if surface_class
  {
    class: html_class.join(" "),
    role: role,
    aria: {
      modal: "true",
      labelledby: labelledby,
      describedby: describedby
    }
  }
end