module NfgUi::Bootstrap::Utilities::CollapseToggleable

Allows components to have a collapsed state when appropriate

Public Instance Methods

data() click to toggle source
Calls superclass method
# File lib/nfg_ui/bootstrap/utilities/collapse_toggleable.rb, line 10
def data
  collapse ? super.merge!(collapse_data_attributes) : super
end

Private Instance Methods

assistive_html_attributes() click to toggle source

To do: currently collapsible doesn't control the actual collapse As such, there's no way to set aria-expanded on the button / toggle… based on whether or not the collapse component is expanded or not

To solve: how to address aria-expanded to accurately reflect the expanded status

Calls superclass method
# File lib/nfg_ui/bootstrap/utilities/collapse_toggleable.rb, line 27
def assistive_html_attributes
  return super unless collapse
  super.merge!(aria: (options[:aria] || {}).merge!(expanded: 'false', controls: collapse.tr('#','')),
               role: 'button')
end
collapse_data_attributes() click to toggle source

Buttons need to be able to to set a target on :buttons and an href on links – so this attribute is customizable if needed

# File lib/nfg_ui/bootstrap/utilities/collapse_toggleable.rb, line 18
def collapse_data_attributes
  @collapse_data_attributes ||= { toggle: 'collapse', target: collapse }
end