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 included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

Primer::TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

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: :text_danger)) { "Danger Text" } %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



13
14
15
16
# File 'app/components/primer/text_component.rb', line 13

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

Instance Method Details

#callObject



18
19
20
# File 'app/components/primer/text_component.rb', line 18

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