class Preview::Generators::ComponentGenerator

def create_preview_file

def create_preview_file
  preview_paths = ViewComponent::Base.config.preview_paths
  optional_path = options[:preview_path]
  return if preview_paths.count > 1 && optional_path.blank?
  path_prefix = if optional_path.present?
    optional_path
  else
    preview_paths.one? ? preview_paths.first : "test/components/previews"
  end
  template "component_preview.rb", File.join(path_prefix, class_path, "#{file_name}_component_preview.rb")
end

def file_name

def file_name
  @_file_name ||= super.sub(/_component\z/i, "")
end

def render_signature

def render_signature
  return if attributes.blank?
  attributes.map { |attr| %(#{attr.name}: "#{attr.name}") }.join(", ")
end