Sha256: 0d487b950693d17821a719b83782503b2d87df9a7e12f6e8f6029c9047b832f6

Contents?: true

Size: 882 Bytes

Versions: 28

Compression:

Stored size: 882 Bytes

Contents

module Lookbook
  module Params
    class Editor::Component < Lookbook::BaseComponent
      renders_many :fields, ->(**attrs) do
        @field_count += 1
        Lookbook::Params::Field::Component.new(**attrs, index: @field_count)
      end

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

      def before_render
        fields
      end

      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

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

      protected

      def alpine_component
        "paramsEditorComponent"
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
lookbook-2.3.4 app/components/lookbook/params/editor/component.rb
lookbook-2.3.3 app/components/lookbook/params/editor/component.rb
lookbook-2.3.2 app/components/lookbook/params/editor/component.rb
lookbook-2.3.0 app/components/lookbook/params/editor/component.rb
lookbook-2.2.2 app/components/lookbook/params/editor/component.rb
lookbook-2.2.1 app/components/lookbook/params/editor/component.rb
lookbook-2.2.0 app/components/lookbook/params/editor/component.rb
lookbook-2.1.1 app/components/lookbook/params/editor/component.rb
lookbook-2.1.0 app/components/lookbook/params/editor/component.rb
lookbook-2.0.5 app/components/lookbook/params/editor/component.rb
lookbook-2.0.4 app/components/lookbook/params/editor/component.rb
lookbook-2.0.3 app/components/lookbook/params/editor/component.rb
lookbook-2.0.2 app/components/lookbook/params/editor/component.rb
lookbook-2.0.1 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0.rc.3 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0.rc.2 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0.rc.1 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0.beta.9 app/components/lookbook/params/editor/component.rb
lookbook-2.0.0.beta.8 app/components/lookbook/params/editor/component.rb