app/controllers/lookbook/previews_controller.rb in lookbook-1.0.0.beta.7 vs app/controllers/lookbook/previews_controller.rb in lookbook-1.0.0.beta.8
- old
+ new
@@ -128,11 +128,11 @@
def inspector_data
return @inspector_data if @inspector_data.present?
context_data = {
preview_params: preview_params,
- path: params[:path],
+ path: params[:path]
}
example = @example
preview = @preview
preview.define_singleton_method(:params, proc {
@@ -143,11 +143,11 @@
render_args = @preview.render_args(example.name, params: preview_controller.params)
has_template = render_args[:template] != "view_components/preview"
output = preview_controller.process(:render_example_to_string, @preview, example.name)
source = has_template ? example.template_source(render_args[:template]) : example.method_source
source_lang = has_template ? example.template_lang(render_args[:template]) : example.lang
-
+
example.define_singleton_method(:output, proc { output })
example.define_singleton_method(:source, proc { source })
example.define_singleton_method(:source_lang, proc { source_lang })
example
end
@@ -168,24 +168,24 @@
Lookbook.config.inspector_panels.each do |name, config|
config_with_defaults = Lookbook.config.inspector_panel_defaults.merge(config)
callable_data = {
name: name.to_s,
- index_position: (@panels.select { |p| p.pane == config.pane }.size + 1),
+ index_position: (@panels.count { |p| p.pane == config.pane } + 1),
**inspector_data
}
resolved_config = config_with_defaults.transform_values do |value|
- value.class == Proc ? value.call(Lookbook::Store.new(callable_data)) : value
+ value.instance_of?(Proc) ? value.call(Lookbook::Store.new(callable_data)) : value
end
resolved_config[:name] = name.to_s
-
+
@panels << Lookbook::Store.new(resolved_config, deep: false)
end
@panels = @panels.select(&:show).sort_by { |p| [p.position, p.label] }
end
-
+
def main_panels
panels.select { |panel| panel.pane == :main }
end
def drawer_panels