Sha256: 7b37d8c164f39c46f638d11c43fdd25f359530562c0874d713fdd39d496b0af0

Contents?: true

Size: 598 Bytes

Versions: 3

Compression:

Stored size: 598 Bytes

Contents

module Lookbook
  module UI
    class ParamEditor < BaseComponent
      attr_reader :param

      def initialize(param:, value:, **kwargs)
        @param = param
        @value = value
      end

      def value
        @value.nil? ? param.default_value_string : @value
      end

      def cast_value
        @value.nil? ? param.default_value : param.cast_value(@value)
      end

      def input
        Inspector.param_input(param.input_type)
      end

      def input_options
        {
          **input.options.to_h,
          **param.input_options.to_h
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lookbook-3.0.0.alpha.2 app/components/lookbook/ui/previews/param_editor/param_editor.rb
lookbook-3.0.0.alpha.1 app/components/lookbook/ui/previews/param_editor/param_editor.rb
lookbook-3.0.0.alpha.0 app/components/lookbook/ui/previews/param_editor/param_editor.rb