Class: Railsboot::NavComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::NavComponent
- Defined in:
- app/components/railsboot/nav_component.rb
Overview
ViewComponent: renders the nav block.
Constant Summary collapse
- STYLES =
Styles.
["", "tabs", "pills", "underline"].freeze
- DEFAULT_STYLE =
Default style.
"".freeze
- WIDTHS =
Widths.
["", "fill", "justified"].freeze
- DEFAULT_WIDTH =
Default width.
"".freeze
Instance Method Summary collapse
-
#initialize(tag: "nav", style: DEFAULT_STYLE, width: DEFAULT_WIDTH, **html_attributes) ⇒ NavComponent
constructor
A new instance of NavComponent.
Constructor Details
#initialize(tag: "nav", style: DEFAULT_STYLE, width: DEFAULT_WIDTH, **html_attributes) ⇒ NavComponent
Returns a new instance of NavComponent.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/railsboot/nav_component.rb', line 16 def initialize(tag: "nav", style: DEFAULT_STYLE, width: DEFAULT_WIDTH, **html_attributes) @tag = tag @style = fetch_or_fallback(style, STYLES, DEFAULT_STYLE) @width = fetch_or_fallback(width, WIDTHS, DEFAULT_WIDTH) @html_attributes = html_attributes @html_attributes[:class] = class_names( "nav", { "nav-#{@style}" => @style.present? }, { "nav-#{@width}" => @width.present? }, html_attributes.delete(:class) ) end |