Class: Practical::Views::OpenDrawerButtonComponent

Inherits:
ButtonComponent show all
Defined in:
app/components/practical/views/open_drawer_button_component.rb

Instance Attribute Summary collapse

Attributes inherited from ButtonComponent

#appearance, #color_variant, #options, #size, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ButtonComponent

#call

Methods included from ElementHelper

#grab, #mix

Constructor Details

#initialize(drawer_id:, appearance: nil, color_variant: nil, size: nil, options: {}) ⇒ OpenDrawerButtonComponent

Returns a new instance of OpenDrawerButtonComponent.



6
7
8
9
10
11
# File 'app/components/practical/views/open_drawer_button_component.rb', line 6

def initialize(drawer_id:, appearance: nil, color_variant: nil, size: nil, options: {})
  options = options.with_defaults(
    onclick: self.class.inline_js_to_open_dialog(drawer_id: drawer_id)
  )
  super(type: :button, appearance: appearance, color_variant: color_variant, size: size, options: options)
end

Instance Attribute Details

#drawer_idObject

Returns the value of attribute drawer_id.



4
5
6
# File 'app/components/practical/views/open_drawer_button_component.rb', line 4

def drawer_id
  @drawer_id
end

Class Method Details

.inline_js_to_open_dialog(drawer_id:) ⇒ Object



13
14
15
# File 'app/components/practical/views/open_drawer_button_component.rb', line 13

def self.inline_js_to_open_dialog(drawer_id:)
  return "document.getElementById(`#{drawer_id}`).open = true"
end