Class: Ariadne::Text

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/text.rb

Overview

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

Constant Summary collapse

DEFAULT_TAG =
:span

Constants inherited from Component

Component::BASE_BODY_CLASSES, Component::BASE_HTML_CLASSES, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(tag: DEFAULT_TAG, classes: "", attributes: {}) ⇒ Text

Returns a new instance of Text.

Examples:

Default

<%= render(Ariadne::Text.new(tag: :p, attributes: { font_weight: :bold })) { "Bold Text" } %>
<%= render(Ariadne::Text.new(tag: :p, attributes: { color: :danger })) { "Danger Text" } %>

Parameters:

  • tag (Symbol, String) (defaults to: DEFAULT_TAG)

    The rendered tag name

  • classes (String) (defaults to: "")

    <%= link_to_classes_docs %>

  • attributes (Hash) (defaults to: {})

    <%= link_to_attributes_docs %>



15
16
17
18
19
# File 'app/components/ariadne/text.rb', line 15

def initialize(tag: DEFAULT_TAG, classes: "", attributes: {})
  @tag = tag
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



21
22
23
# File 'app/components/ariadne/text.rb', line 21

def call
  render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
end