Class: Shadcn::NavigationMenuLinkComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/navigation_menu_link_component.rb

Overview

A link within the navigation menu (for items without dropdowns)

Constant Summary collapse

[
  "group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2",
  "text-sm font-medium transition-colors",
  "hover:bg-accent hover:text-accent-foreground",
  "focus:bg-accent focus:text-accent-foreground focus:outline-none",
  "disabled:pointer-events-none disabled:opacity-50"
].join(" ").freeze
ACTIVE_CLASSES =
"bg-accent/50"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(href:, active: false, **options) ⇒ NavigationMenuLinkComponent

Returns a new instance of NavigationMenuLinkComponent.

Parameters:

  • href (String)

    The link destination

  • active (Boolean) (defaults to: false)

    Whether this link is currently active



18
19
20
21
22
# File 'app/components/shadcn/navigation_menu_link_component.rb', line 18

def initialize(href:, active: false, **options)
  super(**options)
  @href = href
  @active = active
end

Instance Method Details

#callObject



24
25
26
# File 'app/components/shadcn/navigation_menu_link_component.rb', line 24

def call
  (:a, content, link_attributes)
end