Class: Shadcn::Sidebar::MenuAction::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Sidebar::MenuAction::Component
- Defined in:
- app/components/shadcn/sidebar/menu_action/component.rb
Overview
SidebarMenuAction — the small button that sits on a menu item. It has a
variant, which is why it is a component rather than a sidebar_part.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#show_on_hover ⇒ Object
readonly
Returns the value of attribute show_on_hover.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(show_on_hover: false, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(show_on_hover: false, **attributes) ⇒ Component
Returns a new instance of Component.
43 44 45 46 |
# File 'app/components/shadcn/sidebar/menu_action/component.rb', line 43 def initialize(show_on_hover: false, **attributes) @show_on_hover = show_on_hover super(**attributes) end |
Instance Attribute Details
#show_on_hover ⇒ Object (readonly)
Returns the value of attribute show_on_hover.
41 42 43 |
# File 'app/components/shadcn/sidebar/menu_action/component.rb', line 41 def show_on_hover @show_on_hover end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
52 53 54 |
# File 'app/components/shadcn/sidebar/menu_action/component.rb', line 52 def element_attributes(**defaults) super(**{ type: "button", "data-sidebar" => "menu-action" }.merge(defaults)) end |
#style_variants ⇒ Object
48 49 50 |
# File 'app/components/shadcn/sidebar/menu_action/component.rb', line 48 def style_variants { show_on_hover: show_on_hover ? :yes : :no } end |