Sha256: 7af9a6ea4d00ed4854a0f3378eb1524421f2daeb101d0ab1f00ad65ef78330e1
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module Primer # Use `HiddenTextExpander` to indicate and toggle hidden text. class HiddenTextExpander < Primer::Component # @example Default # <%= render(Primer::HiddenTextExpander.new) %> # # @example Inline # <%= render(Primer::HiddenTextExpander.new(inline: true)) %> # # @example Styling the button # <%= render(Primer::HiddenTextExpander.new(button_arguments: { p: 1, classes: "my-custom-class" })) %> # # @param inline [Boolean] Whether or not the expander is inline. # @param button_arguments [Hash] <%= link_to_system_arguments_docs %> for the button element. # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> def initialize(inline: false, button_arguments: {}, **system_arguments) @system_arguments = system_arguments @system_arguments[:tag] ||= :span @system_arguments[:classes] = class_names( "hidden-text-expander", @system_arguments[:classes], "inline" => inline ) @button_arguments = button_arguments @button_arguments[:"aria-expanded"] = false @button_arguments[:classes] = class_names( "ellipsis-expander", button_arguments[:classes] ) end def call render(Primer::BaseComponent.new(**@system_arguments)) do render(Primer::BaseButton.new(**@button_arguments)) { "…".html_safe } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
primer_view_components-0.0.41 | app/components/primer/hidden_text_expander.rb |
primer_view_components-0.0.40 | app/components/primer/hidden_text_expander.rb |