Class: Primer::MenuComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/menu_component.rb

Overview

Use menus to create vertical lists of navigational links.

Constant Summary

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(**system_arguments) ⇒ MenuComponent

Returns a new instance of MenuComponent.

Examples:

Default

<%= render(Primer::MenuComponent.new) do |c| %>
  <% c.heading do %>
    Heading
  <% end %>
  <% c.item(selected: true, href: "#url") do %>
    Item 1
  <% end %>
  <% c.item(href: "#url") do %>
    <%= render(Primer::OcticonComponent.new("check")) %>
    With Icon
  <% end %>
  <% c.item(href: "#url") do %>
    <%= render(Primer::OcticonComponent.new("check")) %>
    With Icon and Counter
    <%= render(Primer::CounterComponent.new(count: 25)) %>
  <% end %>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



56
57
58
59
60
61
62
63
# File 'app/components/primer/menu_component.rb', line 56

def initialize(**system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :nav
  @system_arguments[:classes] = class_names(
    "menu",
    @system_arguments[:classes]
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/components/primer/menu_component.rb', line 65

def render?
  items.any?
end