Class: OkonomiUiKit::Components::NavigationBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/okonomi_ui_kit/components/navigation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, navigation_component) ⇒ NavigationBuilder

Returns a new instance of NavigationBuilder.



38
39
40
41
42
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 38

def initialize(view, navigation_component)
  @view = view
  @navigation_component = navigation_component
  @groups = []
end

Instance Attribute Details

#groups ⇒ Object (readonly)

Returns the value of attribute groups.



36
37
38
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 36

def groups
  @groups
end

Returns the value of attribute navigation_component.



36
37
38
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 36

def navigation_component
  @navigation_component
end

#view ⇒ Object (readonly)

Returns the value of attribute view.



36
37
38
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 36

def view
  @view
end

Instance Method Details

#group(title) {|group_builder| ... } ⇒ Object

Yields:

  • (group_builder)


44
45
46
47
48
49
50
51
52
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 44

def group(title, &block)
  group_builder = NavigationGroupBuilder.new(view, navigation_component)
  yield(group_builder)

  @groups << view.tag.li do
    view.tag.div(title, class: style(:group, :title)) +
    view.tag.ul(group_builder.render_links, role: "list", class: style(:group, :list))
  end
end

#profile_section(&block) ⇒ Object



54
55
56
57
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 54

def profile_section(&block)
  content = view.capture(&block)
  @groups << view.tag.li(content, class: style(:profile_section, :base))
end

#render_groups ⇒ Object



63
64
65
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 63

def render_groups
  view.safe_join(@groups)
end

#style(*args) ⇒ Object



59
60
61
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 59

def style(*args)
  navigation_component.style(*args)
end