Class: Avo::Fields::Common::Files::ListViewerComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Avo::Fields::Common::Files::ListViewerComponent
- Includes:
- Turbo::FramesHelper
- Defined in:
- app/components/avo/fields/common/files/list_viewer_component.rb
Instance Method Summary collapse
- #available_view_types ⇒ Object
- #classes ⇒ Object
- #view_type ⇒ Object
- #view_type_component(file) ⇒ Object
- #wrapper_classes ⇒ Object
Instance Method Details
#available_view_types ⇒ Object
25 26 27 |
# File 'app/components/avo/fields/common/files/list_viewer_component.rb', line 25 def available_view_types [:list, :grid] end |
#classes ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/components/avo/fields/common/files/list_viewer_component.rb', line 9 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 |
#view_type ⇒ Object
34 35 36 |
# File 'app/components/avo/fields/common/files/list_viewer_component.rb', line 34 def view_type @view_type ||= (@resource.params.dig(:view_type) || @field.view_type).to_sym end |
#view_type_component(file) ⇒ Object
29 30 31 32 |
# File 'app/components/avo/fields/common/files/list_viewer_component.rb', line 29 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 |
#wrapper_classes ⇒ Object
21 22 23 |
# File 'app/components/avo/fields/common/files/list_viewer_component.rb', line 21 def wrapper_classes (@field.stacked && !@field.hide_view_type_switcher) ? "-mt-9" : "" end |