Class: SnFilterable::BaseComponents::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ClassNameHelper, FetchOrFallbackHelper
Defined in:
app/components/sn_filterable/base_components/base_component.rb

Direct Known Subclasses

ButtonComponent

Instance Method Summary collapse

Constructor Details

#initialize(tag:, classes: nil, **system_arguments) ⇒ BaseComponent

Returns a new instance of BaseComponent.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/sn_filterable/base_components/base_component.rb', line 9

def initialize(tag:, classes: nil, **system_arguments)
  @tag = tag
  @system_arguments = system_arguments

  # TODO
  # Implement a more native way of adding custom CSS class instead of stupid string concat
  # Similar to the Claasifier Primer build
  # https://github.com/primer/view_components/blob/41b277aa047ba7d1a669a48dc392115bf4948435/app/components/primer/base_component.rb
  @system_arguments[:class] = class_names(
    system_arguments[:class],
    classes
  )
end

Instance Method Details

#callObject



23
24
25
# File 'app/components/sn_filterable/base_components/base_component.rb', line 23

def call
  (@tag, content, **@system_arguments)
end