Sha256: 1033f22ba977e18cb3378d5074ceda68cfffd980be8e06d893709ca1beb6fbaf

Contents?: true

Size: 885 Bytes

Versions: 21

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

#
# Renders a div for use with component-manager.
#
class Proscenium::Phlex::ReactComponent < Proscenium::Phlex::Component
  attr_accessor :props, :lazy

  # @param props: [Hash]
  # @param lazy: [Boolean] Lazy load the component using IntersectionObserver. Default: true.
  def initialize(props: {}, lazy: true) # rubocop:disable Lint/MissingSuper
    @props = props
    @lazy = lazy
  end

  # @yield the given block to a `div` within the top level component div. If not given,
  #   `<div>loading...</div>` will be rendered. Use this to display a loading UI while the component
  #   is loading and rendered.
  def template(&block)
    div class: ['componentManagedByProscenium', '@component'],
        data: { component: { path: virtual_path, props: props, lazy: lazy }.to_json } do
      block ? div(&block) : div { 'loading...' }
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
proscenium-0.6.0-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.6.0-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.6.0-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.5.1-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.5.1-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.5.1-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.5.0-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.5.0-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.5.0-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.4.2-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.2-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.2-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.4.1-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.1-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.1-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.4.0-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.0-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.4.0-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.3.0-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.3.0-x86_64-darwin lib/proscenium/phlex/react_component.rb