Class: Primer::Truncate
- Defined in:
- app/components/primer/truncate.rb
Overview
Use Truncate to shorten overflowing text with an ellipsis.
Constant Summary
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
Primer::TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(inline: false, expandable: false, max_width: nil, **system_arguments) ⇒ Truncate
constructor
A new instance of Truncate.
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(inline: false, expandable: false, max_width: nil, **system_arguments) ⇒ Truncate
Returns a new instance of Truncate.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/primer/truncate.rb', line 26 def initialize(inline: false, expandable: false, max_width: nil, **system_arguments) @system_arguments = system_arguments @system_arguments[:tag] ||= :div @system_arguments[:classes] = class_names( @system_arguments[:classes], "css-truncate", "css-truncate-overflow" => !inline, "css-truncate-target" => inline, "expandable" => inline && ) @system_arguments[:style] = join_style_arguments(@system_arguments[:style], "max-width: #{max_width}px;") unless max_width.nil? end |
Instance Method Details
#call ⇒ Object
39 40 41 |
# File 'app/components/primer/truncate.rb', line 39 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |