Class: Shadcn::DropdownMenu::RadioItem::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::DropdownMenu::RadioItem::Component
- Defined in:
- app/components/shadcn/dropdown_menu/radio_item/component.rb
Overview
DropdownMenuRadioItem
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.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(value:, 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(value:, checked: false, disabled: false, **attributes) ⇒ Component
Returns a new instance of Component.
24 25 26 27 28 29 |
# File 'app/components/shadcn/dropdown_menu/radio_item/component.rb', line 24 def initialize(value:, checked: false, disabled: false, **attributes) @value = value.to_s @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/radio_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/radio_item/component.rb', line 22 def disabled @disabled end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
22 23 24 |
# File 'app/components/shadcn/dropdown_menu/radio_item/component.rb', line 22 def value @value end |
Instance Method Details
#call ⇒ Object
45 46 47 |
# File 'app/components/shadcn/dropdown_menu/radio_item/component.rb', line 45 def call render_element(body: safe_join([ indicator, content ])) end |
#element_attributes(**defaults) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/shadcn/dropdown_menu/radio_item/component.rb', line 31 def element_attributes(**defaults) super(**{ role: "menuitemradio", tabindex: "-1", "aria-checked" => checked.to_s, "data-value" => value, "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 |