Class: Shadcn::HoverCard::Trigger::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::HoverCard::Trigger::Component
- Defined in:
- app/components/shadcn/hover_card/trigger/component.rb
Overview
HoverCardTrigger. Radix opens on hover and on focus and closes on blur (hover-card.tsx:138-141), so a keyboard reaches the card even though it cannot be tabbed into — see the content for the other half of that.
default_tag :button because the demo's trigger is one and a hoverable
affordance needs to be focusable to open on focus at all; as: :a is
the usual override, which is what upstream's example passes.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #initialize, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
This class inherits a constructor from Shadcn::ApplicationViewComponent
Instance Method Details
#element_attributes(**defaults) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/shadcn/hover_card/trigger/component.rb', line 17 def element_attributes(**defaults) attributes = { "data-state" => "closed", "data-shadcn--hover-card-target" => "trigger", "data-action" => "pointerenter->shadcn--hover-card#open " \ "pointerleave->shadcn--hover-card#close " \ "focus->shadcn--hover-card#open " \ "blur->shadcn--hover-card#close" } attributes[:type] = "button" if tag_name.to_sym == :button super(**attributes.merge(defaults)) end |