Class: Daisy::Layout::HoverComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Layout::HoverComponent
- Includes:
- LocoMotion::Concerns::LinkableComponent
- Defined in:
- app/components/daisy/layout/hover_component.rb
Overview
The hover-3d effect relies on DaisyUI's display: inline-grid.
Passing a display utility such as block or flex via css: overrides
it and collapses the eight hover zones, so the content only scales instead
of tilting. Use sizing and spacing utilities (w-60, max-w-100, m-4)
without changing display.
The HoverComponent wraps any content with the DaisyUI hover-3d effect,
tilting and rotating the content based on the mouse position to create an
interactive 3D feel. Common use cases include:
- Credit cards, ID cards, and ticket mockups.
- Image galleries and product showcases.
- Marketing or hero sections that benefit from a subtle 3D flourish.
DaisyUI's hover-3d works by overlaying eight invisible "hover zones" on top
of the content. Each zone applies a slight rotation as the cursor moves over
it, and the combined effect produces a smooth 3D tilt. This component takes
care of generating those eight empty zones for you so the API is just a
wrapper around your content.
Includes the LocoMotion::Concerns::LinkableComponent module so that
providing an href: will render the wrapper as an <a> tag, which is the
DaisyUI-recommended way to make the entire 3D card clickable. Avoid placing
interactive elements (buttons, links) inside the wrapper since they will
conflict with the hover zones.
Constant Summary collapse
- HOVER_ZONE_COUNT =
The number of empty hover zones DaisyUI's
hover-3drequires. 8
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Sets up the component's CSS classes.
-
#initialize(*args, **kws, &block) ⇒ HoverComponent
constructor
Creates a new Hover (3D) component.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Methods included from LocoMotion::Concerns::InspectableComponent
Constructor Details
#initialize(*args, **kws, &block) ⇒ HoverComponent
Creates a new Hover (3D) component.
95 96 97 |
# File 'app/components/daisy/layout/hover_component.rb', line 95 def initialize(*args, **kws, &block) super end |
Instance Method Details
#before_render ⇒ Object
Sets up the component's CSS classes.
102 103 104 105 |
# File 'app/components/daisy/layout/hover_component.rb', line 102 def before_render setup_component super end |