Module: Sidebars::Concerns::ContainerWithHtmlOptions

Includes:
LinkWithHtmlOptions
Included in:
Menu
Defined in:
lib/sidebars/concerns/container_with_html_options.rb

Instance Method Summary collapse

Methods included from LinkWithHtmlOptions

#link_html_options

Instance Method Details

#collapsed_container_html_optionsObject

The attributes returned from this method will be applied to helper methods like ‘link_to` or the div containing the container when it is collapsed.



27
28
29
30
31
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 27

def collapsed_container_html_options
  {
    aria: { label: title }
  }.merge(extra_collapsed_container_html_options)
end

#container_html_optionsObject

The attributes returned from this method will be applied to helper methods like ‘link_to` or the div containing the container.



11
12
13
14
15
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 11

def container_html_options
  {
    aria: { label: title }
  }.merge(extra_container_html_options)
end

#extra_collapsed_container_html_optionsObject

Classes should mostly override this method and not ‘collapsed_container_html_options`.



35
36
37
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 35

def extra_collapsed_container_html_options
  {}
end

#extra_container_html_optionsObject

Classes will override mostly this method and not ‘container_html_options`.



19
20
21
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 19

def extra_container_html_options
  {}
end

Classes should mostly override this method and not ‘nav_link_html_options`.



52
53
54
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 52

def extra_nav_link_html_options
  {}
end

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 67

def link
  raise NotImplementedError
end

Attributes to pass to the html_options attribute in the helper method that sets the active class on each element.



42
43
44
45
46
47
48
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 42

def nav_link_html_options
  {
    data: {
      track_label: self.class.name.demodulize.underscore
    }
  }.deep_merge(extra_nav_link_html_options)
end

#titleObject

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 56

def title
  raise NotImplementedError
end

#title_html_optionsObject

The attributes returned from this method will be applied right next to the title, for example in the span that renders the title.



63
64
65
# File 'lib/sidebars/concerns/container_with_html_options.rb', line 63

def title_html_options
  {}
end