Class: Pulse::BaseComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/pulse/base_component.rb

Overview

BaseComponent accepts a standard set of options, providing the foundation for other components to use and build upon. Specify a tag, optional classes, and any other additional options will be passed to Rails' content_tag helper.

This is a simplified version of Primer's BaseComponent

For example:

<%= render Pulse::BaseComponent.new(tag: :span, classes: "text-sm") do %>
  Hello world
<% end %>

Renders:

<span class="text-sm">Hello world</span>

Instance Method Summary collapse

Constructor Details

#initialize(tag:, classes: nil, **system_arguments) ⇒ BaseComponent

Returns a new instance of BaseComponent.



26
27
28
29
30
# File 'app/components/pulse/base_component.rb', line 26

def initialize(tag:, classes: nil, **system_arguments)
  @tag = tag
  @classes = classes
  @system_arguments = system_arguments
end

Instance Method Details

#callObject



32
33
34
# File 'app/components/pulse/base_component.rb', line 32

def call
  (@tag, content, class: @classes, **@system_arguments)
end