Skip to content

Commit 317ca3b

Browse files
ENGCOM-6279: Fixed masonry grid rendering and styles #25553
- Merge Pull Request #25553 from sivaschenko/magento2:masonry-styles - Merged commits: 1. 5fea47b 2. cdf8e4e 3. 4ce646d
2 parents 2635bd8 + 4ce646d commit 317ca3b

File tree

6 files changed

+140
-1
lines changed

6 files changed

+140
-1
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ define([
1010

1111
return Column.extend({
1212
defaults: {
13+
bodyTmpl: 'ui/grid/columns/image-preview',
1314
previewImageSelector: '[data-image-preview]',
1415
visibleRecord: null,
1516
height: 0,
1617
displayedRecord: {},
1718
lastOpenedImage: null,
19+
fields: {
20+
previewUrl: 'preview_url',
21+
title: 'title'
22+
},
1823
modules: {
1924
masonry: '${ $.parentName }',
2025
thumbnailComponent: '${ $.parentName }.thumbnail_url'
@@ -154,6 +159,26 @@ define([
154159
return this.visibleRecord() === record._rowIndex || false;
155160
},
156161

162+
/**
163+
* Returns preview image url for a given record.
164+
*
165+
* @param {Object} record
166+
* @return {String}
167+
*/
168+
getUrl: function (record) {
169+
return record[this.fields.previewUrl];
170+
},
171+
172+
/**
173+
* Returns image title for a given record.
174+
*
175+
* @param {Object} record
176+
* @return {String}
177+
*/
178+
getTitle: function (record) {
179+
return record[this.fields.title];
180+
},
181+
157182
/**
158183
* Get styles for preview
159184
*

app/code/Magento/Ui/view/base/web/js/grid/columns/image.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ define([
99

1010
return Column.extend({
1111
defaults: {
12+
bodyTmpl: 'ui/grid/columns/image',
1213
modules: {
1314
previewComponent: '${ $.parentName }.preview'
1415
},

app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ define([
88
'use strict';
99

1010
return Column.extend({
11+
defaults: {
12+
bodyTmpl: 'ui/grid/columns/overlay'
13+
},
14+
1115
/**
1216
* If overlay should be visible
1317
*

app/code/Magento/Ui/view/base/web/js/grid/masonry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define([
1313

1414
return Listing.extend({
1515
defaults: {
16-
template: 'Magento_Ui/grid/masonry',
16+
template: 'ui/grid/masonry',
1717
imports: {
1818
rows: '${ $.provider }:data.items',
1919
errorMessage: '${ $.provider }:data.errorMessage'

app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
// */
55

66
@import 'module/_data-grid.less';
7+
@import 'module/_masonry-grid.less';
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
@admin__masonry_grid_image__space: 20px;
6+
@admin__masonry_grid_background_color: #fff;
7+
@admin__masonry_overlay_background_color: #507dc8;
8+
9+
& when (@media-common = true) {
10+
.masonry-image {
11+
&-grid {
12+
margin: @admin__masonry_grid_image__space/2 -(@admin__masonry_grid_image__space/2);
13+
overflow: hidden;
14+
position: relative;
15+
16+
.no-data-message-container,
17+
.error-message-container {
18+
font-size: @data-grid__no-records__font-size;
19+
padding: @data-grid__no-records__padding;
20+
text-align: center;
21+
}
22+
}
23+
24+
&-column {
25+
background-color: @admin__masonry_grid_background_color;
26+
float: left;
27+
margin: @admin__masonry_grid_image__space/2;
28+
overflow: hidden;
29+
30+
img {
31+
cursor: pointer;
32+
height: 100%;
33+
width: 100%;
34+
}
35+
}
36+
37+
&-overlay {
38+
background-color: @admin__masonry_overlay_background_color;
39+
color: @admin__masonry_grid_background_color;
40+
opacity: 1;
41+
padding: .5rem;
42+
position: absolute;
43+
text-align: center;
44+
width: 80px;
45+
z-index: 10;
46+
}
47+
48+
&-preview {
49+
background-color: @admin__masonry_grid_background_color;
50+
display: table;
51+
left: 0;
52+
position: absolute;
53+
right: 0;
54+
width: 100%;
55+
56+
.container {
57+
margin: auto;
58+
max-width: 880px;
59+
padding-top: 10px;
60+
61+
.action-buttons {
62+
text-align: right;
63+
64+
.action {
65+
&-close {
66+
padding: 30px;
67+
position: static;
68+
}
69+
70+
&-previous,
71+
&-next {
72+
background: transparent;
73+
border: none;
74+
margin: 0;
75+
white-space: nowrap;
76+
}
77+
78+
&-close,
79+
&-previous,
80+
&-next {
81+
font-size: 2rem;
82+
}
83+
}
84+
}
85+
86+
.preview-row-content {
87+
display: flex;
88+
89+
&:after {
90+
clear: both;
91+
content: '';
92+
display: table;
93+
}
94+
95+
img.preview {
96+
display: block;
97+
flex-basis: 300px;
98+
float: left;
99+
margin-bottom: 20px;
100+
max-height: 500px;
101+
max-width: 60%;
102+
width: auto;
103+
}
104+
}
105+
}
106+
}
107+
}
108+
}

0 commit comments

Comments
 (0)