Class: Shadcn::DropdownMenu::CheckboxItem::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::DropdownMenu::CheckboxItem::Component
- Defined in:
- app/components/shadcn/dropdown_menu/checkbox_item/component.rb
Overview
DropdownMenuCheckboxItem
Constant Summary collapse
- INDICATOR_CLASSES =
"pointer-events-none absolute left-2 flex size-3.5 " \ "items-center justify-center"
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#checked ⇒ Object
readonly
Returns the value of attribute checked.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(checked: false, disabled: false, **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(checked: false, disabled: false, **attributes) ⇒ Component
Returns a new instance of Component.
24 25 26 27 28 |
# File 'app/components/shadcn/dropdown_menu/checkbox_item/component.rb', line 24 def initialize(checked: false, disabled: false, **attributes) @checked = checked @disabled = disabled super(**attributes) end |
Instance Attribute Details
#checked ⇒ Object (readonly)
Returns the value of attribute checked.
22 23 24 |
# File 'app/components/shadcn/dropdown_menu/checkbox_item/component.rb', line 22 def checked @checked end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
22 23 24 |
# File 'app/components/shadcn/dropdown_menu/checkbox_item/component.rb', line 22 def disabled @disabled end |
Instance Method Details
#call ⇒ Object
43 44 45 |
# File 'app/components/shadcn/dropdown_menu/checkbox_item/component.rb', line 43 def call render_element(body: safe_join([ indicator, content ])) end |
#element_attributes(**defaults) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/shadcn/dropdown_menu/checkbox_item/component.rb', line 30 def element_attributes(**defaults) super(**{ role: "menuitemcheckbox", tabindex: "-1", "aria-checked" => checked.to_s, "data-state" => (checked ? "checked" : "unchecked"), "data-disabled" => (true if disabled), "data-shadcn--dropdown-menu-target" => "item", "data-action" => "click->shadcn--dropdown-menu#select " \ "pointerenter->shadcn--dropdown-menu#pointerenter" }.merge(defaults)) end |