Sha256: 96d4458133bdd31eceb9697f22e8b87ab2db6fd8533e656260b5ce30605924b4

Contents?: true

Size: 822 Bytes

Versions: 16

Compression:

Stored size: 822 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[input] ||= styles
      end

      protected

      def alpine_component
        "paramsEditorComponent"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lookbook-1.5.5 app/components/lookbook/params/editor/component.rb
lookbook-1.5.4 app/components/lookbook/params/editor/component.rb
lookbook-1.5.3 app/components/lookbook/params/editor/component.rb
lookbook-1.5.2 app/components/lookbook/params/editor/component.rb
lookbook-1.5.1 app/components/lookbook/params/editor/component.rb
lookbook-1.5.0 app/components/lookbook/params/editor/component.rb
lookbook-1.4.5 app/components/lookbook/params/editor/component.rb
lookbook-1.4.4 app/components/lookbook/params/editor/component.rb
lookbook-1.4.3 app/components/lookbook/params/editor/component.rb
lookbook-1.4.2 app/components/lookbook/params/editor/component.rb
lookbook-1.4.1 app/components/lookbook/params/editor/component.rb
lookbook-1.4.0 app/components/lookbook/params/editor/component.rb
lookbook-1.3.4 app/components/lookbook/params/editor/component.rb
lookbook-1.3.3 app/components/lookbook/params/editor/component.rb
lookbook-1.3.1 app/components/lookbook/params/editor/component.rb
lookbook-1.3.0 app/components/lookbook/params/editor/component.rb