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

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

Constructor Details

#initialize(**kws) ⇒ BrowserComponent

Creates a new Browser component.

rubocop:disable Lint/UselessMethodDefinition -- exists so the doc comment above has a real method to attach to; BrowserComponent has no options of its own beyond the universal ones documented here.

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


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

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

Instance Method Details

#before_renderObject

Sets up the component's CSS classes.



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

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

#callObject

Renders the toolbar (if present) and content.



79
80
81
82
83
84
# File 'app/components/daisy/mockup/browser_component.rb', line 79

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