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

Constructor Details

#initialize(**kws) ⇒ HeroComponent

Creates a new Hero component.

Options Hash (**kws):

  • css (String)

    Additional CSS classes for styling. Common options include:

    • Height: ‘min-h-screen`, `min-h-`

    • 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: “‘ruby html: { style: “background-image: url(’image.jpg’)” } “‘



72
73
74
# File 'app/components/daisy/layout/hero_component.rb', line 72

def initialize(**kws)
  super
end

Instance Method Details

#before_renderObject

Sets up the component’s CSS classes.



79
80
81
82
# File 'app/components/daisy/layout/hero_component.rb', line 79

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