Skip to content

Commit 7ca05aa

Browse files
committed
MC-1263: Buttons of Image Content Block are not aligned correctly
- Updated implementation to work with all responsive cases
1 parent 297b5ff commit 7ca05aa

File tree

4 files changed

+62
-37
lines changed

4 files changed

+62
-37
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/image/_default.less

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,6 @@
1111
border: 1px solid transparent;
1212
width: 100%;
1313

14-
.column-width-40 &,
15-
.column-width-30 &,
16-
.column-width-20 &,
17-
.column-width-10 & {
18-
.file-uploader-area {
19-
align-items: center;
20-
display: flex;
21-
flex-direction: column;
22-
position: relative;
23-
24-
> span {
25-
display: none;
26-
}
27-
}
28-
.image-upload-instructions {
29-
margin-bottom: 5px;
30-
}
31-
.file-uploader-button {
32-
display: block;
33-
margin-left: 0;
34-
margin-right: 0;
35-
margin-top: 15px;
36-
max-width: 180px;
37-
width: 100%;
38-
}
39-
}
40-
.column-width-10 & {
41-
.file-uploader-button {
42-
padding: .6rem 0;
43-
}
44-
.image-upload-requirements {
45-
display: none;
46-
}
47-
}
48-
4914
figure {
5015
box-sizing: border-box;
5116
margin: 0;

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/form/element/uploader/preview/_image.less

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@
6767
display: none;
6868
}
6969

70+
._compact-ui .file-uploader-area,
71+
._micro-ui .file-uploader-area {
72+
align-items: center;
73+
display: flex;
74+
flex-direction: column;
75+
position: relative;
76+
77+
> span {
78+
display: none;
79+
}
80+
.image-upload-instructions {
81+
margin-bottom: 5px;
82+
}
83+
.file-uploader-button {
84+
display: block;
85+
margin-left: 0;
86+
margin-right: 0;
87+
margin-top: 15px;
88+
max-width: 180px;
89+
width: 100%;
90+
}
91+
}
92+
._micro-ui .file-uploader-area {
93+
.file-uploader-button {
94+
padding: .6rem 0;
95+
}
96+
.image-upload-requirements {
97+
display: none;
98+
}
99+
}
100+
70101
.pagebuilder-image-uploader-container-dropzone-overlay {
71102
display: none;
72103
height: 100%;

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/image-uploader.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ define([
88
'underscore',
99
'uiRegistry',
1010
'Magento_Ui/js/form/element/image-uploader',
11+
'Magento_PageBuilder/js/resource/resize-observer/ResizeObserver.min',
1112
'Magento_PageBuilder/js/events',
1213
'mage/translate'
13-
], function ($, _, uiRegistry, Uploader, events, $t) {
14+
], function ($, _, uiRegistry, Uploader, ResizeObserver, events, $t) {
1415
'use strict';
1516

1617
var initializedOnce = false;
1718

1819
return Uploader.extend({
1920
defaults: {
21+
$uploadArea: null,
2022
isShowImageUploadInstructions: true,
2123
isShowImageUploadOptions: false,
2224
classes: {
@@ -59,6 +61,16 @@ define([
5961
}
6062
},
6163

64+
/**
65+
* {@inheritDoc}
66+
*/
67+
initUploader: function (fileInput) {
68+
this._super(fileInput);
69+
this.$uploadArea = this.$fileInput.closest('.pagebuilder-image-empty-preview');
70+
new ResizeObserver(this.updateResponsiveClasses.bind(this)).observe(this.$uploadArea);
71+
this.$uploadArea = $(this.$uploadArea);
72+
},
73+
6274
/**
6375
* Remove draggable classes from dropzones
6476
* {@inheritDoc}
@@ -138,6 +150,23 @@ define([
138150
*/
139151
onAssignedFile: function (file) {
140152
this.value([file]);
153+
},
154+
155+
/**
156+
* Adds the appropriate ui state class to the upload control area based on the current rendered size
157+
*/
158+
updateResponsiveClasses: function () {
159+
if (!this.$uploadArea.is(':visible')) {
160+
return;
161+
}
162+
163+
this.$uploadArea.removeClass('_micro-ui _compact-ui');
164+
165+
if (this.$uploadArea.width() < 130) {
166+
this.$uploadArea.addClass('_micro-ui');
167+
} else if (this.$uploadArea.width() < 440) {
168+
this.$uploadArea.addClass('_compact-ui');
169+
}
141170
}
142171
});
143172
});

app/code/Magento/PageBuilder/view/adminhtml/web/js/master-format/filter-html.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)