Class: MenuComponent

Inherits:
Component show all
Includes:
Attachable, Positionable, Sizeable
Defined in:
app/components/menu_component.rb

Overview

Menu — navigation menus.

Usage:

Menu(pointing: true, secondary: true) {
  MenuItem(href: "#", active: true) { text "Home" }
  MenuItem(href: "#") { text "Messages" }
}

Constant Summary collapse

NUMBERS =
%w[one two three four five six seven eight nine ten eleven twelve].freeze

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/components/menu_component.rb', line 35

def to_s
  item_word = items && items.between?(1, 12) ? NUMBERS[items - 1] : nil

  classes = class_names(
    "ui",
    position,
    size,
    color,
    item_word && "#{item_word} item",
    fixed && "#{fixed} fixed",
    { "attached" => attached,
      "secondary" => secondary,
      "pointing" => pointing,
      "tabular" => tabular,
      "vertical" => vertical,
      "inverted" => inverted,
      "icon" => icon && !labeled_icon,
      "labeled icon" => labeled_icon,
      "compact" => compact,
      "fluid" => fluid,
      "stackable" => stackable,
      "text" => text,
      "pagination" => pagination,
      "borderless" => borderless },
    "menu"
  )

  tag.div(class: classes) { @content }
end