Class: Pulse::BaseComponent
- Inherits:
-
Component
- Object
- Component
- Pulse::BaseComponent
- 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
- #call ⇒ Object
-
#initialize(tag:, classes: nil, **system_arguments) ⇒ BaseComponent
constructor
A new instance of BaseComponent.
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
#call ⇒ Object
32 33 34 |
# File 'app/components/pulse/base_component.rb', line 32 def call content_tag(@tag, content, class: @classes, **@system_arguments) end |