Class: Trek::Toaster::ToastComponent::LinkComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/trek/toaster/toast_component.rb

Instance Method Summary collapse

Methods included from StimulusHelpers

#stimulus_action, #stimulus_class, #stimulus_class_hash, #stimulus_class_key, #stimulus_target, #stimulus_target_hash, #stimulus_target_key, #stimulus_value, #stimulus_value_hash, #stimulus_value_key

Methods included from CssClassesHelpers

#class_for, #class_names_for, #root_class

Methods included from IdentifierHelper

#identifier

Instance Method Details

#callObject



37
38
39
# File 'app/components/trek/toaster/toast_component.rb', line 37

def call
  link_to(rendered_text, href, params)
end

#iconObject



52
53
54
55
56
# File 'app/components/trek/toaster/toast_component.rb', line 52

def icon
  return if target != "_blank"

  render IconComponent.new("external", classnames: class_for("icon"))
end

#paramsObject



58
59
60
61
62
63
64
# File 'app/components/trek/toaster/toast_component.rb', line 58

def params
  {
    rel:,
    target:,
    class: root_class
  }
end

#render?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/components/trek/toaster/toast_component.rb', line 48

def render?
  text.present? && href.present?
end

#rendered_textObject



41
42
43
44
45
46
# File 'app/components/trek/toaster/toast_component.rb', line 41

def rendered_text
  safe_join([
    text,
    icon
  ])
end