Class: Primer::Beta::Truncate::TruncateText

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

Overview

This component is part of ‘Primer::Beta::Truncate` and should not be used as a standalone component.

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

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

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(priority: false, expandable: false, max_width: nil, **system_arguments) ⇒ TruncateText

Returns a new instance of TruncateText.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/components/primer/beta/truncate.rb', line 40

def initialize(priority: false, expandable: false, max_width: nil, **system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = system_arguments[:tag] || :span
  @system_arguments[:classes] = class_names(
    "Truncate-text",
    system_arguments[:classes],
    "Truncate-text--primary": priority,
    "Truncate-text--expandable": expandable
  )

  @system_arguments[:style] = join_style_arguments(@system_arguments[:style], "max-width: #{max_width}px;") unless max_width.nil?
end

Instance Method Details

#callObject



53
54
55
56
57
# File 'app/components/primer/beta/truncate.rb', line 53

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