Class: Daisy::Mockup::BrowserComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/mockup/browser_component.rb

Overview

The BrowserComponent creates a realistic browser window mockup, perfect for:

  • Showcasing web applications.

  • Creating website previews.

  • Demonstrating responsive designs.

  • Building marketing materials.

The component includes an optional toolbar for URL input and browser controls, and a content area that can contain any content you wish to display.

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) ⇒ BrowserComponent

Creates a new Browser component.

Parameters:

  • kws (Hash)

    a customizable set of options

Options Hash (**kws):

  • css (String)

    Additional CSS classes for styling. Common options include:

    • Size: ‘w-full`, `max-w-4xl`

    • Border: ‘border`, `border-2`, `border-primary`

    • Background: ‘bg-base-100`, `bg-primary`

    • Shadow: ‘shadow`, `shadow-lg`



57
58
59
# File 'app/components/daisy/mockup/browser_component.rb', line 57

def initialize(**kws)
  super(**kws)
end

Instance Method Details

#before_renderObject

Sets up the component’s CSS classes.



64
65
66
# File 'app/components/daisy/mockup/browser_component.rb', line 64

def before_render
  add_css(:component, "mockup-browser")
end

#callObject

Renders the toolbar (if present) and content.



71
72
73
74
75
76
# File 'app/components/daisy/mockup/browser_component.rb', line 71

def call
  part(:component) do
    concat(toolbar) if toolbar
    concat(content)
  end
end