Sha256: 739f61eec34a489b5811cf195112883b2f3ca318e66e82fc0c0ab35325f3174a

Contents?: true

Size: 1001 Bytes

Versions: 3

Compression:

Stored size: 1001 Bytes

Contents

module Workarea
  module Storefront
    module ContentBlocks
      module GridContent
        def position
          # Product grid index starts at 0.
          # Offset position to make admin UI more intuitive
          data[:position] - 1
        end

        def preview_position
          return position unless position > Workarea.config.grid_cell_content_preview_cells
          position % Workarea.config.grid_cell_content_preview_cells
        end

        def cell_width_class
          Workarea.config.product_grid_cell_classes[data[:width].to_sym]
        end

        def cell_styles
          styles = []
          styles << "float: #{float_side};" if float?
          styles.join(" ")
        end

        def float?
          data[:height].to_i > 1 || data[:float] != "none"
        end

        def float_side
          if data[:height].to_i > 1 && data[:float] == "none"
            "left"
          else
            data[:float]
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-product_grid_content-1.4.0 app/view_models/workarea/storefront/content_blocks/grid_content.rb
workarea-product_grid_content-1.3.1 app/view_models/workarea/storefront/content_blocks/grid_content.rb
workarea-product_grid_content-1.3.0 app/view_models/workarea/storefront/content_blocks/grid_content.rb