Class: KozenetUi::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/kozenet_ui/base_component.rb

Overview

Base component that all Kozenet UI components inherit from Provides common functionality for variant handling, class merging, etc.

Constant Summary collapse

UNSET =
Object.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variant: nil, size: nil, class: nil, **html_options) ⇒ BaseComponent

Returns a new instance of BaseComponent.



11
12
13
14
15
16
17
# File 'app/components/kozenet_ui/base_component.rb', line 11

def initialize(variant: nil, size: nil, class: nil, **html_options)
  super()
  @variant = variant || KozenetUi.configuration.default_variant
  @size = size || KozenetUi.configuration.default_size
  @custom_class = binding.local_variable_get(:class)
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



9
10
11
# File 'app/components/kozenet_ui/base_component.rb', line 9

def html_options
  @html_options
end

#sizeObject (readonly)

Returns the value of attribute size.



9
10
11
# File 'app/components/kozenet_ui/base_component.rb', line 9

def size
  @size
end

#variantObject (readonly)

Returns the value of attribute variant.



9
10
11
# File 'app/components/kozenet_ui/base_component.rb', line 9

def variant
  @variant
end