workarea-product_grid_content 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc +25 -0
  4. data/.eslintrc.json +35 -0
  5. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  6. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.github/workflows/ci.yml +61 -0
  9. data/.gitignore +20 -0
  10. data/.rubocop.yml +2 -0
  11. data/.scss-lint.yml +192 -0
  12. data/.stylelintrc.json +8 -0
  13. data/CHANGELOG.md +104 -0
  14. data/CODE_OF_CONDUCT.md +3 -0
  15. data/CONTRIBUTING.md +3 -0
  16. data/Gemfile +5 -0
  17. data/LICENSE.md +3 -0
  18. data/README.md +72 -0
  19. data/Rakefile +59 -0
  20. data/app/assets/images/workarea/admin/content_block_types/insights_grid_cell.svg +1 -0
  21. data/app/assets/images/workarea/admin/content_block_types/product_grid_cell.svg +1 -0
  22. data/app/assets/javascripts/workarea/storefront/product_grid_content/modules/match_product_summary_height.js +53 -0
  23. data/app/assets/stylesheets/workarea/product_grid_content/components/_content_block_product_grid_cell.scss +45 -0
  24. data/app/assets/stylesheets/workarea/product_grid_content/components/_insights_grid_cell_content_block.scss +10 -0
  25. data/app/assets/stylesheets/workarea/product_grid_content/components/_pagination_product_grid_content.scss +9 -0
  26. data/app/assets/stylesheets/workarea/product_grid_content/components/_product_grid_cell_content_block.scss +30 -0
  27. data/app/controllers/workarea/storefront/content_blocks_controller.decorator +46 -0
  28. data/app/view_models/workarea/storefront/category_view_model.decorator +11 -0
  29. data/app/view_models/workarea/storefront/content_blocks/grid_content.rb +40 -0
  30. data/app/view_models/workarea/storefront/content_blocks/insights_grid_cell_view_model.rb +25 -0
  31. data/app/view_models/workarea/storefront/content_blocks/product_grid_cell_view_model.rb +23 -0
  32. data/app/view_models/workarea/storefront/product_grid_content.rb +17 -0
  33. data/app/view_models/workarea/storefront/search_view_model.decorator +12 -0
  34. data/app/views/layouts/workarea/storefront/in_grid_content_preview.html.haml +55 -0
  35. data/app/views/workarea/storefront/content_blocks/_insights_grid_cell.html.haml +8 -0
  36. data/app/views/workarea/storefront/content_blocks/_product_grid_cell.html.haml +10 -0
  37. data/app/views/workarea/storefront/shared/_product_grid_content_cell.html.haml +3 -0
  38. data/app/views/workarea/storefront/style_guides/components/_product_grid_cell_content_block.html.haml +27 -0
  39. data/bin/rails +25 -0
  40. data/config/initializers/appends.rb +23 -0
  41. data/config/initializers/content_block_config.rb +17 -0
  42. data/config/initializers/content_block_types.rb +48 -0
  43. data/lib/workarea/product_grid_content/engine.rb +8 -0
  44. data/lib/workarea/product_grid_content/version.rb +5 -0
  45. data/lib/workarea/product_grid_content.rb +11 -0
  46. data/package.json +9 -0
  47. data/public/sample_grid_content.png +0 -0
  48. data/test/dummy/Rakefile +6 -0
  49. data/test/dummy/bin/bundle +3 -0
  50. data/test/dummy/bin/rails +4 -0
  51. data/test/dummy/bin/rake +4 -0
  52. data/test/dummy/bin/setup +28 -0
  53. data/test/dummy/bin/update +28 -0
  54. data/test/dummy/bin/yarn +11 -0
  55. data/test/dummy/config/application.rb +31 -0
  56. data/test/dummy/config/boot.rb +5 -0
  57. data/test/dummy/config/environment.rb +5 -0
  58. data/test/dummy/config/environments/development.rb +52 -0
  59. data/test/dummy/config/environments/production.rb +83 -0
  60. data/test/dummy/config/environments/test.rb +45 -0
  61. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  62. data/test/dummy/config/initializers/assets.rb +14 -0
  63. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  64. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  65. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  66. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  67. data/test/dummy/config/initializers/inflections.rb +16 -0
  68. data/test/dummy/config/initializers/mime_types.rb +4 -0
  69. data/test/dummy/config/initializers/workarea.rb +5 -0
  70. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  71. data/test/dummy/config/locales/en.yml +33 -0
  72. data/test/dummy/config/puma.rb +34 -0
  73. data/test/dummy/config/routes.rb +5 -0
  74. data/test/dummy/config/secrets.yml +32 -0
  75. data/test/dummy/config/spring.rb +6 -0
  76. data/test/dummy/config.ru +5 -0
  77. data/test/dummy/db/seeds.rb +2 -0
  78. data/test/dummy/lib/assets/.keep +0 -0
  79. data/test/dummy/log/.keep +0 -0
  80. data/test/dummy/package.json +5 -0
  81. data/test/system/workarea/admin/in_grid_content_system_test.rb +67 -0
  82. data/test/teaspoon_env.rb +6 -0
  83. data/test/test_helper.rb +10 -0
  84. data/test/view_models/workarea/storefront/category_view_model_test.decorator +31 -0
  85. data/test/view_models/workarea/storefront/content_blocks/insights_grid_cell_view_model_test.rb +63 -0
  86. data/test/view_models/workarea/storefront/content_blocks/product_grid_cell_view_model_test.rb +77 -0
  87. data/workarea-product_grid_content.gemspec +16 -0
  88. data/yarn.lock +3290 -0
  89. metadata +150 -0
data/.stylelintrc.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ Workarea Product Grid Content 1.3.0 (2019-06-25)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Adds a new in grid content block leveraging insights data.
5
+
6
+ The new insights grid cell block type allows retailers to strategically insert products, driven by insights data, at any position within their category browse page and search customization product grids
7
+ Workarea minimum version requirement bumped to v3.4 to support new insight types
8
+
9
+ WPGC-20
10
+ Jake Beresford
11
+
12
+ * Add link to cover background image
13
+
14
+ Due to implementation of image as a CSS background the link is applied as an absolutely-relative positioned element which covers the background, and is behind the content area, allowing that text to remain accessible.
15
+
16
+ WPGC-4
17
+ Jake Beresford
18
+
19
+
20
+
21
+ Workarea Product Grid Content 1.2.0 (2019-02-19)
22
+ --------------------------------------------------------------------------------
23
+
24
+ * Add test for in grid content on search customizations
25
+
26
+ WPGC-18
27
+ Jake Beresford
28
+
29
+ * Allow in-grid content for search customizations
30
+
31
+ * Update configuration to add in-grid area to search cusotmizations
32
+ * Add logic to read content for in grid area from customization in search controller
33
+
34
+ WPGC-18
35
+ Jake Beresford
36
+
37
+
38
+
39
+ Workarea Product Grid Content 1.1.0 (2018-11-13)
40
+ --------------------------------------------------------------------------------
41
+
42
+ * Update block type definition to use find_asset_id_by_file_name
43
+
44
+ * Minimum Workarea version requirement is now v3.1.13
45
+
46
+ WPGC-17
47
+ Jake Beresford
48
+
49
+ * Sets the content image as a background image
50
+
51
+ The change caused the content block to collapse in the admin preview since
52
+ the content is positioned with absolute relativity. In order to make this
53
+ block work properly in the admin a new layout was added for content previews
54
+ in any 'in grid' area.
55
+
56
+ * Adds config for number of products to display in grid preview.
57
+ * Renders the content block in a relevant position in the grid.
58
+ * Add calculation for preview position to grid_content view model, allowing
59
+ the preview position to look good and work for cell width, cell height,
60
+ and position controls.
61
+
62
+ WPGC-9
63
+ Jake Beresford
64
+
65
+ * Add tooltips to blocktype definition
66
+
67
+ WPGC-7
68
+ Jake Beresford
69
+
70
+ * Allow admin user to specify a background color in lieu of an image
71
+
72
+ WPGC-10
73
+ Jake Beresford
74
+
75
+
76
+
77
+ Workarea Product Grid Content 1.0.2 (2018-10-02)
78
+ --------------------------------------------------------------------------------
79
+
80
+ * Fix pagination on firefox
81
+
82
+ * Extends clearfix in .pagination to allow for floated content blocks within the paged product results
83
+ * Add missing heading class to improve developer experience
84
+
85
+ WPGC-14
86
+ Jake Beresford
87
+
88
+
89
+
90
+ Workarea Product Grid Content 1.0.1 (2018-05-24)
91
+ --------------------------------------------------------------------------------
92
+
93
+ * Clean up markdown formatting of readme
94
+
95
+ WPGC-12
96
+ Dave Barnow
97
+
98
+
99
+
100
+ Workarea Product Grid Content 1.0.0 (2018-03-22)
101
+ --------------------------------------------------------------------------------
102
+
103
+
104
+
@@ -0,0 +1,3 @@
1
+ View this plugin's code of conduct here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CODE_OF_CONDUCT.md>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's contribution guidelines here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CONTRIBUTING.md>
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'workarea', git: 'https://github.com/workarea-commerce/workarea.git'
data/LICENSE.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's license here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/LICENSE.md>
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ Workarea Product Grid Content
2
+ ================================================================================
3
+
4
+ Product Grid Content plugin for the Workarea platform.
5
+
6
+ Extend the merchandising abilities of the Workarea Ecommerce platform with content in product browse grids!
7
+
8
+ Example of a 2x1 content block in the browse grid:
9
+ ![Sample 2x1 Grid Content](public/sample_grid_content.png)
10
+
11
+ Block Type Grid Options
12
+ --------------------------------------------------------------------------------
13
+
14
+ * **Position:** An integer input that allows the admin to choose the position of content within the grid.
15
+ * **Height & Width:** Allows admin to create 1x1, 1x2, 2x1, and 2x2 content blocks.
16
+ * **Height - floating tall blocks:** When the height of a block is greater than 1 cell it must be floated either left or right. This avoids breaking the grid and looks good at all viewport widths. By default, a block that is 2 cells in height will automatically float left, even if the float select menu is set to none. The float select menu can be used to override this behavior and float the content to the right.
17
+ * **Float:** Aside from 2 cell tall blocks it is unlikely that your admin will need to use this option.
18
+
19
+ Configuring Cell Width Classes
20
+ --------------------------------------------------------------------------------
21
+
22
+ Since most applications customize the number of products per-row in the product browse grid we have provided a handy configuration for cell widths for in grid content blocks. Add the following to your host application workarea.rb
23
+
24
+ Workarea.configure do |config|
25
+ config.product_grid_cell_classes = {
26
+ "1": "grid__cell--50 grid__cell--25-at-medium grid__cell--20-at-wide",
27
+ "2": "grid__cell--50-at-medium grid__cell--40-at-wide"
28
+ }
29
+ end
30
+
31
+ Content Block Compatibility
32
+ --------------------------------------------------------------------------------
33
+
34
+ The content block which ships with this plugin is the only block type that can be used in the product grid area out of the box.
35
+ If you want to enable other block types for use in the product grid you will need to make the following changes to each block type:
36
+
37
+ 1. Add the 'Grid' fieldset to your block - you can copy and paste from the content block type defined in this plugin.
38
+ 2. Include the GridContent module in your content block's view model.
39
+ 3. Add the data binding for match_product_summary_height to your view
40
+ 4. Test the block type in a grid position, you may need to adjust styles and markup to fit your design at this point.
41
+
42
+ Contentable Grids
43
+ --------------------------------------------------------------------------------
44
+
45
+ This plugin enables in-grid content for category/show and searches/show.
46
+ If your application has another browse grid which you want to make contentable you will need to:
47
+
48
+ 1. Ensure your model is contentable
49
+ 2. Include Storefront::ProductGridContent in the view model
50
+ 3. Update the view to render content blocks as part of the loop over products. You may need to update your .each to .each_with_index as the index is necessary to render blocks for a given position.
51
+
52
+ Roadmap
53
+ --------------------------------------------------------------------------------
54
+
55
+ * Figure out a solution for 'hanging products' which are caused by the presence
56
+ of content in the browse grid. The only workaround currently is to add significant
57
+ content to the page, forcing a full row of hanging products.
58
+ * Note that when using finite scroll pagination these hanging products are less
59
+ noticeable, gaps are filled when the next page of products is appended.
60
+ * More controls for images in the block type (cropping/resizing)
61
+ * Positioning the content in the context of the content editor is a bit cumbersome,
62
+ currently I cant think of a better solution which does not pose huge technical challenges.
63
+ Ideally, we could edit the position of the blocks in a nice drag and drop interface.
64
+
65
+ Workarea Platform Documentation
66
+ --------------------------------------------------------------------------------
67
+
68
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea platform documentation.
69
+
70
+ Copyright & Licensing
71
+ --------------------------------------------------------------------------------
72
+ Workarea Commerce Platform is released under the [Business Software License](https://github.com/workarea-commerce/workarea/blob/master/LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ require "rdoc/task"
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = "rdoc"
10
+ rdoc.title = "Product Grid Content"
11
+ rdoc.options << "--line-numbers"
12
+ rdoc.rdoc_files.include("README.md")
13
+ rdoc.rdoc_files.include("lib/**/*.rb")
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load "rails/tasks/engine.rake"
18
+ load "rails/tasks/statistics.rake"
19
+ load "workarea/changelog.rake"
20
+
21
+ require "rake/testtask"
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << "lib"
24
+ t.libs << "test"
25
+ t.pattern = "test/**/*_test.rb"
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
31
+ require "workarea/product_grid_content/version"
32
+
33
+ desc "Release version #{Workarea::ProductGridContent::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ Rake::Task["workarea:changelog"].execute
38
+ system "git add CHANGELOG.md"
39
+ system 'git commit -m "Update CHANGELOG"'
40
+ system "git push origin HEAD"
41
+
42
+ system "git tag -a v#{Workarea::ProductGridContent::VERSION} -m 'Tagging #{Workarea::ProductGridContent::VERSION}'"
43
+ system "git push --tags"
44
+
45
+ system "gem build workarea-product_grid_content.gemspec"
46
+ system "gem push workarea-product_grid_content-#{Workarea::ProductGridContent::VERSION}.gem --host #{host}"
47
+ system "rm workarea-product_grid_content-#{Workarea::ProductGridContent::VERSION}.gem"
48
+ end
49
+
50
+ desc "Run the JavaScript tests"
51
+ ENV["TEASPOON_RAILS_ENV"] = File.expand_path("../test/dummy/config/environment", __FILE__)
52
+ task teaspoon: "app:teaspoon"
53
+
54
+ desc "Start a server at http://localhost:3000/teaspoon for JavaScript tests"
55
+ task :teaspoon_server do
56
+ Dir.chdir("test/dummy")
57
+ teaspoon_env = File.expand_path("../test/teaspoon_env.rb", __FILE__)
58
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
59
+ end
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 40.93"><title>insights grid cell</title><path d="M22,39H8V28H22ZM10,37H20V30H10Z"/><path d="M39,26H8V2H39ZM10,24H37V4H10Z"/><path d="M56,39H42V28H56ZM44,37H54V30H44Z"/><path d="M56,13H42V2H56ZM44,11H54V4H44Z"/><path d="M56,26H42V15H56ZM44,24H54V17H44Z"/><path d="M39,39H25V28H39ZM27,37H37V30H27Z"/><path d="M23.5,5.63a.35.35,0,0,0-.35.35V7.37a.35.35,0,1,0,.7,0V6a.35.35,0,0,0-.35-.35m-4.93,2a.36.36,0,0,0-.25.6l1,1a.35.35,0,0,0,.49-.49l-1-1a.32.32,0,0,0-.24-.11m9.86,0a.34.34,0,0,0-.24.11l-1,1a.35.35,0,0,0,.49.49l1-1a.36.36,0,0,0-.25-.6M23.5,8.77a4.12,4.12,0,0,0-4.19,4c0,3,2.27,3.67,2.27,5.79h3.84c0-2.12,2.27-2.76,2.27-5.79a4.12,4.12,0,0,0-4.19-4m-7,3.83a.35.35,0,0,0-.35.35.35.35,0,0,0,.35.35h1.4a.35.35,0,0,0,.35-.35.35.35,0,0,0-.35-.35h-1.4m12.56,0a.35.35,0,0,0-.35.35.35.35,0,0,0,.35.35h1.4a.35.35,0,0,0,.35-.35.35.35,0,0,0-.35-.35h-1.4m-7.5,6.63v.7h3.84v-.7H21.58m0,1.4a.7.7,0,0,0,.7.7h2.44a.7.7,0,0,0,.7-.7H21.58m1.22,1a.7.7,0,0,0,1.4,0H22.8"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 40.93"><title>Product Grid Cell</title><path d="M22,39H8V28H22ZM10,37H20V30H10Z"/><path d="M39,26H8V2H39ZM10,24H37V4H10Z"/><path d="M56,39H42V28H56ZM44,37H54V30H44Z"/><path d="M56,13H42V2H56ZM44,11H54V4H44Z"/><path d="M56,26H42V15H56ZM44,24H54V17H44Z"/><path d="M39,39H25V28H39ZM27,37H37V30H27Z"/><path d="M28,13H25V10a1,1,0,1,0-2,0v3H20a1,1,0,0,0,0,2h3v3a1,1,0,0,0,2,0V15h3a1,1,0,0,0,0-2Z"/></svg>
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @namespace WORKAREA.matchProductsummaryHeight
3
+ */
4
+ WORKAREA.registerModule('matchProductsummaryHeight', (function () {
5
+ 'use strict';
6
+
7
+ var maxHeight = function ($pagination) {
8
+ var $productSummaries = $('.product-summary', $pagination);
9
+
10
+ return _.reduce($productSummaries, function(result, value) {
11
+ return $(value).height() > result ? $(value).height() : result;
12
+ }, 0);
13
+ },
14
+
15
+ updatecontentBlock = function ($contentBlock, numberOfRows, $pagination) {
16
+ var height = maxHeight($pagination);
17
+ $contentBlock.height(height * numberOfRows);
18
+ },
19
+
20
+ setHeight = function($scope, index, contentBlock) {
21
+ var $contentBlock = $(contentBlock),
22
+ contentBlockData = $contentBlock.data('matchProductSummaryHeight'),
23
+ numberOfRows = contentBlockData.rows || 1,
24
+ $pagination = $contentBlock.closest('.pagination');
25
+
26
+ $contentBlock.height('100%');
27
+
28
+ // Dont set the height if the blocktype is outside of a pagination
29
+ // This prevents the display breaking in the admin content editor
30
+ if (_.isEmpty($pagination)) { return; }
31
+
32
+ // Need to wait for the stack to clear so that the height
33
+ // is calculated by the browser in time
34
+ _.defer(updatecontentBlock, $contentBlock, numberOfRows, $pagination);
35
+ },
36
+
37
+ refresh = function ($scope) {
38
+ $('[data-match-product-summary-height]', $scope).each(_.partial(setHeight, $scope));
39
+ },
40
+
41
+ onResize = _.once(function($scope) {
42
+ $(window).on('resize', _.debounce(_.partial(refresh, $scope), 200));
43
+ }),
44
+
45
+ init = function ($scope) {
46
+ $('[data-match-product-summary-height]', $scope).each(_.partial(setHeight, $scope));
47
+ onResize($scope);
48
+ };
49
+
50
+ return {
51
+ init: init
52
+ };
53
+ }()));
@@ -0,0 +1,45 @@
1
+ /*------------------------------------*\
2
+ #CONTENT-BLOCK--PRODUCT-GRID-CELL
3
+ Component modifier for .content-block
4
+ \*------------------------------------*/
5
+
6
+ .content-block--insights-grid-cell,
7
+ .content-block--product-grid-cell {
8
+ display: inline;
9
+
10
+ &.content-block--hidden-for-small {
11
+ display: none;
12
+
13
+ @include respond-to($medium-breakpoint) {
14
+ display: inline;
15
+ }
16
+ }
17
+
18
+ &.content-block--hidden-for-medium {
19
+ @include respond-to($medium-breakpoint) {
20
+ display: none;
21
+ }
22
+
23
+ @include respond-to($wide-breakpoint) {
24
+ display: inline;
25
+ }
26
+ }
27
+
28
+ &.content-block--hidden-for-wide {
29
+ @include respond-to($wide-breakpoint) {
30
+ display: none;
31
+ }
32
+
33
+ @include respond-to($x-wide-breakpoint) {
34
+ display: inline;
35
+ }
36
+ }
37
+
38
+ &.content-block--hidden-for-x-wide {
39
+ display: none;
40
+ }
41
+
42
+ .grid--flush & {
43
+ padding-left: 0;
44
+ }
45
+ }
@@ -0,0 +1,10 @@
1
+ /*------------------------------------*\
2
+ #INSIGHTS-GRID-CELL-CONTENT-BLOCK
3
+ \*------------------------------------*/
4
+
5
+ .insights-grid-cell-content-block {
6
+ position: relative;
7
+ margin-bottom: $spacing-unit;
8
+ height: 100%;
9
+ overflow: hidden;
10
+ }
@@ -0,0 +1,9 @@
1
+ /*------------------------------------*\
2
+ #PAGINATION
3
+ Extends the base pagination styles adding clearfix to ensure floated content
4
+ blocks do not break the page layout.
5
+ \*------------------------------------*/
6
+
7
+ .pagination {
8
+ @extend %clearfix;
9
+ }
@@ -0,0 +1,30 @@
1
+ /*------------------------------------*\
2
+ #PRODUCT-GRID-CELL-CONTENT-BLOCK
3
+ \*------------------------------------*/
4
+
5
+ .product-grid-cell-content-block {
6
+ position: relative;
7
+ margin-bottom: $spacing-unit;
8
+ height: 100%;
9
+ overflow: hidden;
10
+ }
11
+
12
+ .product-grid-cell-content-block__background-link {
13
+ position: absolute;
14
+ top: 0;
15
+ right: 0;
16
+ bottom: 0;
17
+ left: 0;
18
+ }
19
+
20
+ .product-grid-cell-content-block__content {
21
+ @include center;
22
+ }
23
+
24
+ .product-grid-cell-content-block__heading {}
25
+ .product-grid-cell-content-block__action {}
26
+
27
+ .product-grid-cell-content-block__media-container {}
28
+ .product-grid-cell-content-block__media-container--maintain-aspect-ratio {}
29
+
30
+ .product-grid-cell-content-block__image {}
@@ -0,0 +1,46 @@
1
+ module Workarea
2
+ decorate Storefront::ContentBlocksController, with: :product_grid_content do
3
+ decorated do
4
+ layout :check_grid_preview, only: [:show, :draft]
5
+ end
6
+
7
+ def show
8
+ super
9
+
10
+ if @block.area.inquiry.in_grid?
11
+ get_product_for_grid_preview
12
+ end
13
+ end
14
+
15
+ def draft
16
+ draft = Content::BlockDraft.find(params[:id])
17
+
18
+ @content = draft.content
19
+ @block = Storefront::ContentBlockViewModel.wrap(
20
+ draft.to_block,
21
+ view_model_options
22
+ )
23
+
24
+ if @block.area.inquiry.in_grid?
25
+ get_product_for_grid_preview
26
+ end
27
+
28
+ render :show
29
+ end
30
+
31
+ private
32
+
33
+ def check_grid_preview
34
+ if @block.area.inquiry.in_grid?
35
+ "workarea/storefront/in_grid_content_preview"
36
+ else
37
+ "workarea/storefront/empty"
38
+ end
39
+ end
40
+
41
+ def get_product_for_grid_preview
42
+ product = Workarea::Catalog::Product.sample
43
+ @product = Workarea::Storefront::ProductViewModel.wrap(product)
44
+ end
45
+ end
46
+ end