Class: Daisy::Layout::HeroComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/layout/hero_component.rb

Overview

The HeroComponent creates an eye-catching, full-width section typically used at the top of a page. Common use cases include:

  • Landing page introductions.
  • Feature showcases.
  • Call-to-action sections.
  • Image-rich banners.

The component is responsive by default and provides flexible layout options for content positioning and image integration.

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

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

#build_inspect_string

Constructor Details

#initialize(*args, **kws, &block) ⇒ HeroComponent

Creates a new Hero component.

Parameters:

  • kws (Hash)

    Keyword arguments for customizing the hero.

Options Hash (**kws):

  • css (String)

    Additional CSS classes for styling. Common options include:

    • Height: min-h-screen, min-h-[50vh]
    • Background: bg-base-200, bg-primary
    • Text: text-center, text-primary-content
  • content_wrapper_css (String)

    CSS classes for the content wrapper. Common options include:

    • Layout: flex-col, flex-col md:flex-row
    • Spacing: gap-4, space-y-4
    • Alignment: items-center, justify-between
  • html (Hash)

    HTML attributes for the hero container. Commonly used for background images:

    html: { style: "background-image: url('image.jpg')" }
    


76
77
78
# File 'app/components/daisy/layout/hero_component.rb', line 76

def initialize(*args, **kws, &block)
  super
end

Instance Method Details

#before_renderObject

Sets up the component's CSS classes.



83
84
85
86
# File 'app/components/daisy/layout/hero_component.rb', line 83

def before_render
  add_css(:component, "hero")
  add_css(:content_wrapper, "hero-content")
end