Class: Primer::TextComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/text_component.rb

Overview

The Text component is a wrapper component that will apply typography styles to the text inside.

Constant Summary

Constants inherited from Component

Component::STATUSES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods inherited from Component

status

Methods included from ViewHelper

#primer

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(**system_arguments) ⇒ TextComponent

Returns a new instance of TextComponent.

Examples:

Default

<%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
<%= render(Primer::TextComponent.new(tag: :p, color: :red_5)) { "Red Text" } %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



11
12
13
14
# File 'app/components/primer/text_component.rb', line 11

def initialize(**system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] ||= :span
end

Instance Method Details

#callObject



16
17
18
# File 'app/components/primer/text_component.rb', line 16

def call
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
end