Class: Yattho::Alpha::Menu

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/alpha/menu.rb

Overview

Use ‘Menu` to create vertical lists of navigational links.

Direct Known Subclasses

MenuComponent

Constant Summary collapse

HEADING_TAG_OPTIONS =
[:h1, :h2, :h3, :h4, :h5, :h6].freeze
HEADING_TAG_FALLBACK =
:h2

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

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 inherited from Component

deprecated?, generate_id

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) ⇒ Menu

Returns a new instance of Menu.

Examples:

Default

<%= render(Yattho::Alpha::Menu.new) do |component| %>
  <% component.with_heading(tag: :h2) do %>
    Heading
  <% end %>
  <% component.with_item(selected: true, href: "#url") do %>
    Item 1
  <% end %>
  <% component.with_item(href: "#url") do %>
    <%= render(Yattho::Beta::Octicon.new("check")) %>
    With Icon
  <% end %>
  <% component.with_item(href: "#url") do %>
    <%= render(Yattho::Beta::Octicon.new("check")) %>
    With Icon and Counter
    <%= render(Yattho::Beta::Counter.new(count: 25)) %>
  <% end %>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



62
63
64
65
66
67
68
69
# File 'app/components/yattho/alpha/menu.rb', line 62

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

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/components/yattho/alpha/menu.rb', line 71

def render?
  items.any?
end