Class: OkonomiUiKit::Components::NavigationBuilder
- Inherits:
-
Object
- Object
- OkonomiUiKit::Components::NavigationBuilder
- Defined in:
- app/helpers/okonomi_ui_kit/components/navigation.rb
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#navigation_component ⇒ Object
readonly
Returns the value of attribute navigation_component.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #group(title) {|group_builder| ... } ⇒ Object
-
#initialize(view, navigation_component) ⇒ NavigationBuilder
constructor
A new instance of NavigationBuilder.
- #profile_section(&block) ⇒ Object
- #render_groups ⇒ Object
- #style(*args) ⇒ Object
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, ) @view = view @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 |
#navigation_component ⇒ Object (readonly)
Returns the value of attribute navigation_component.
36 37 38 |
# File 'app/helpers/okonomi_ui_kit/components/navigation.rb', line 36 def @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
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, ) 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) .style(*args) end |