Sha256: ca07422cb672c17d1dd0fc5668d3ea8194a0136011b983393952fe6544977e29

Contents?: true

Size: 989 Bytes

Versions: 22

Compression:

Stored size: 989 Bytes

Contents

# frozen_string_literal: true

class Avo::Fields::Common::Files::ListViewerComponent < Avo::BaseComponent
  include Turbo::FramesHelper

  prop :field
  prop :resource

  def classes
    base_classes = "py-4 rounded-2xl max-w-full"

    view_type_classes = if view_type == :list
      "flex flex-col space-y-2"
    else
      "relative grid xs:grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6"
    end

    "#{base_classes} #{view_type_classes}"
  end

  def wrapper_classes
    (@field.stacked && !@field.hide_view_type_switcher) ? "-mt-9" : ""
  end

  def available_view_types
    [:list, :grid]
  end

  def view_type_component(file)
    component = "Avo::Fields::Common::Files::ViewType::#{view_type.to_s.capitalize}ItemComponent".constantize
    component.new(field: @field, resource: @resource, file: file, extra_classes: "aspect-video")
  end

  def view_type
    @view_type ||= (@resource.params.dig(:view_type) || @field.view_type).to_sym
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
avo-3.16.5 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.16.4 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.16.3 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.16.2 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.16.1 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.16.0 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.7 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.6 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.5 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.4 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.3 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.2 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.1 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.15.0 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.5 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.4 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.3 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.2 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.1 app/components/avo/fields/common/files/list_viewer_component.rb
avo-3.14.0 app/components/avo/fields/common/files/list_viewer_component.rb