Sha256: d9dea1da6dfd7228f8361c8f37de9a16628117f3b01b86b32696ab4606e9c3c1

Contents?: true

Size: 1.06 KB

Versions: 80

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Proscenium
  # Renders a <div> for use with React components, with data attributes specifying the component
  # path and props.
  #
  # If a block is given, it will be yielded within the div, allowing for a custom "loading" UI. If
  # no block is given, then a "loading..." text will be rendered. It is intended that the component
  # is mounted to this div, and the loading UI will then be replaced with the component's rendered
  # output.
  #
  # You can pass props to the component in the `:props` keyword argument.
  class Phlex::ReactComponent < Phlex
    self.abstract_class = true

    include ReactComponentable

    # Override this to provide your own loading UI.
    #
    # @example
    #   def template(**attributes, &block)
    #     super do
    #       'Look at me! I am loading now...'
    #     end
    #   end
    #
    # @yield the given block to a `div` within the top level component div.
    def template(**attributes, &block)
      send root_tag, **{ data: data_attributes }.deep_merge(attributes), &block
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
proscenium-0.15.0.beta.4-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.4-aarch64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.4-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.4-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.3-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.3-aarch64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.3-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.3-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.2-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.2-aarch64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.2-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.2-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.1-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.1-aarch64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.1-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.15.0.beta.1-x86_64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.14.0-x86_64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.14.0-aarch64-linux lib/proscenium/phlex/react_component.rb
proscenium-0.14.0-arm64-darwin lib/proscenium/phlex/react_component.rb
proscenium-0.14.0-x86_64-darwin lib/proscenium/phlex/react_component.rb