Class: Editor::Component

Inherits:
Lookbook::BaseComponent
  • Object
show all
Defined in:
app/components/lookbook/display_options/editor/component.rb,
app/components/lookbook/params/editor/component.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**html_attrs) ⇒ Component

Returns a new instance of Component.



9
10
11
12
13
# File 'app/components/lookbook/params/editor/component.rb', line 9

def initialize(**html_attrs)
  @field_count = -1
  @@input_styles = {}
  super(**html_attrs)
end

Class Method Details

.add_styles(input, styles) ⇒ Object



25
26
27
28
# File 'app/components/lookbook/params/editor/component.rb', line 25

def self.add_styles(input, styles)
  @@input_styles = {} unless defined?(@@input_styles)
  @@input_styles[input] ||= styles
end

Instance Method Details

#before_renderObject



15
16
17
# File 'app/components/lookbook/params/editor/component.rb', line 15

def before_render
  fields
end

#param_stylesObject



19
20
21
22
23
# File 'app/components/lookbook/params/editor/component.rb', line 19

def param_styles
  @css_styles ||= @@input_styles.map do |input_name, styles|
    styles.map { |s| "[data-param-input=#{input_name}] #{s}" }.join("\n")
  end.join("\n")
end