Skip to content

Commit bd3140c

Browse files
committed
MC-1263: Buttons of Image Content Block are not aligned correctly
- Implemented new classes for column widths - Updated image styles to not break UI on stage
1 parent 556550f commit bd3140c

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,45 @@
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 > span {
19+
display: none;
20+
}
21+
.file-uploader-button {
22+
margin-left: 0;
23+
margin-right: 0;
24+
25+
~ .file-uploader-button {
26+
margin-left: 15px;
27+
}
28+
}
29+
}
30+
.column-width-20 &,
31+
.column-width-10 & {
32+
.file-uploader-button {
33+
width: auto;
34+
}
35+
}
36+
.column-width-30 &,
37+
.column-width-20 &,
38+
.column-width-10 & {
39+
.file-uploader-button ~ .file-uploader-button {
40+
margin-left: 0;
41+
margin-top: 15px;
42+
}
43+
}
44+
.column-width-10 & {
45+
.file-uploader-button {
46+
padding: .6rem 0;
47+
}
48+
.image-upload-requirements {
49+
display: none;
50+
}
51+
}
52+
1453
figure {
1554
box-sizing: border-box;
1655
margin: 0;

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/column/preview.js

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/column/preview.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class Preview extends PreviewCollection {
5252
super(parent, config, observableUpdater);
5353

5454
// Update the width label for the column
55+
this.parent.dataStore.subscribe(this.updateColumnWidthClass.bind(this), "width");
5556
this.parent.dataStore.subscribe(this.updateDisplayLabel.bind(this), "width");
5657
this.parent.parent.dataStore.subscribe(this.updateDisplayLabel.bind(this), "grid_size");
5758
}
@@ -84,6 +85,7 @@ export default class Preview extends PreviewCollection {
8485
*/
8586
public initColumn(element: Element) {
8687
this.element = $(element);
88+
this.updateColumnWidthClass();
8789
events.trigger("column:initializeAfter", {
8890
column: this.parent,
8991
element: $(element),
@@ -266,6 +268,26 @@ export default class Preview extends PreviewCollection {
266268
}
267269
}
268270

271+
/**
272+
* Syncs the column-width-* class on the children-wrapper with the current width to the nearest tenth rounded up
273+
*/
274+
public updateColumnWidthClass() {
275+
// Only update once instantiated
276+
if (!this.element) {
277+
return;
278+
}
279+
280+
const currentClass = this.element.attr("class").match(/(?:^|\s)(column-width-\d{1,3})(?:$|\s)/);
281+
282+
if (currentClass !== null) {
283+
this.element.removeClass(currentClass[1]);
284+
}
285+
286+
const roundedWidth = Math.ceil(parseFloat(this.parent.dataStore.get("width").toString()) / 10) * 10;
287+
288+
this.element.addClass("column-width-" + roundedWidth);
289+
}
290+
269291
/**
270292
* Update the style attribute mapper converts images to directives, override it to include the correct URL
271293
*

0 commit comments

Comments
 (0)