Class: Shadcn::Menubar::Sub::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Menubar::Sub::Component
- Defined in:
- app/components/shadcn/menubar/sub/component.rb
Overview
A nested menu. Written out rather than subclassed, because ViewComponent refuses to redeclare an inherited slot and this one holds this family's sub-content.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#open ⇒ Object
readonly
Returns the value of attribute open.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
-
#side_offset ⇒ Object
readonly
Returns the value of attribute side_offset.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(open: false, side: :right, align: :start, side_offset: 0, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(open: false, side: :right, align: :start, side_offset: 0, **attributes) ⇒ Component
Returns a new instance of Component.
17 18 19 20 21 22 23 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 17 def initialize(open: false, side: :right, align: :start, side_offset: 0, **attributes) @open = open @side = side&.to_sym || :right @align = align&.to_sym || :start @side_offset = side_offset super(**attributes) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
15 16 17 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 15 def align @align end |
#open ⇒ Object (readonly)
Returns the value of attribute open.
15 16 17 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 15 def open @open end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
15 16 17 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 15 def side @side end |
#side_offset ⇒ Object (readonly)
Returns the value of attribute side_offset.
15 16 17 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 15 def side_offset @side_offset end |
Instance Method Details
#call ⇒ Object
37 38 39 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 37 def call render_element(body: safe_join([ trigger, , content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/shadcn/menubar/sub/component.rb', line 25 def element_attributes(**defaults) super(**{ style: merged_style(CONTENTS_STYLE), "data-controller" => "shadcn--dropdown-menu", "data-shadcn--dropdown-menu-prefix-value" => "menubar", "data-shadcn--dropdown-menu-open-value" => open, "data-shadcn--dropdown-menu-side-value" => side, "data-shadcn--dropdown-menu-align-value" => align, "data-shadcn--dropdown-menu-side-offset-value" => side_offset }.merge(defaults)) end |