module ViewComponent::PreviewActions

def previews

def previews
  find_preview
  if params[:path] == @preview.preview_name
    @page_title = "Component Previews for #{@preview.preview_name}"
    render "view_components/previews", **determine_layout
  else
    prepend_application_view_paths
    prepend_preview_examples_view_path
    @example_name = File.basename(params[:path])
    @render_args = @preview.render_args(@example_name, params: params.permit!)
    layout = determine_layout(@render_args[:layout], prepend_views: false)[:layout]
    locals = @render_args[:locals]
    opts = {}
    opts[:layout] = layout if layout.present? || layout == false
    opts[:locals] = locals if locals.present?
    render "view_components/preview", opts
  end
end