Class: DesignSystem::Generic::LinkComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DesignSystem::Generic::LinkComponent
- Defined in:
- app/components/design_system/generic/link_component.rb
Overview
Link (or button-styled link) rendered by ds_link_to. Mirrors the polymorphic Rails link_to signature: with a block the first argument is the URL, otherwise it is the link text. A :type option selects a button style (defined per brand). The link_context switches the default link class (e.g. inside a notification banner).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name = nil, options = nil, html_options = nil, link_context: nil) ⇒ LinkComponent
constructor
A new instance of LinkComponent.
Methods included from Helpers::CssHelper
Methods included from BrandDerivable
Constructor Details
#initialize(name = nil, options = nil, html_options = nil, link_context: nil) ⇒ LinkComponent
Returns a new instance of LinkComponent.
9 10 11 12 13 14 15 |
# File 'app/components/design_system/generic/link_component.rb', line 9 def initialize(name = nil, = nil, = nil, link_context: nil) super() @name = name @options = || {} @html_options = || {} @link_context = link_context end |
Instance Attribute Details
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
17 18 19 |
# File 'app/components/design_system/generic/link_component.rb', line 17 def @html_options end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'app/components/design_system/generic/link_component.rb', line 17 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'app/components/design_system/generic/link_component.rb', line 17 def @options end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/design_system/generic/link_component.rb', line 19 def call if content.present? type = .delete(:type) [:class] = prep_link_classes(type) link_to(name, , ) { content } else type = .delete(:type) [:class] = prep_link_classes(type) link_to(name, , ) end end |