Skip to content

Commit 71d0203

Browse files
committed
MC-3146: Add new row appearances to configuration
- Update appearance visual select to be generic - Refactor row data migration renderer - Remove unnesscary row appearance docs
1 parent c258279 commit 71d0203

29 files changed

+66
-168
lines changed

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/Row.php

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ public function __construct(StyleExtractorInterface $styleExtractor)
2727

2828
/**
2929
* {@inheritdoc}
30-
*
31-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
32-
* @SuppressWarnings(PHPMD.NPathComplexity)
3330
*/
3431
public function render(array $itemData, array $additionalData = []) : string
3532
{
@@ -40,12 +37,6 @@ public function render(array $itemData, array $additionalData = []) : string
4037
// Handle adding the wrapper element attributes when using the contained appearance
4138
$rootElementAttributes = [];
4239
if ($appearance === 'contained') {
43-
$wrapperElementAttributes = [
44-
'data-element' => 'wrapper',
45-
'data-role' => 'row',
46-
'data-appearance' => 'contained',
47-
'class' => 'row-contained',
48-
];
4940
$rootElementAttributes = [
5041
'data-element' => 'main',
5142
'class' => $itemData['formData']['css_classes'] ?? '',
@@ -64,24 +55,49 @@ public function render(array $itemData, array $additionalData = []) : string
6455
$rootElementAttributes['style'] = $style;
6556
}
6657

67-
$rootElementHtml = '<div';
68-
foreach ($rootElementAttributes as $attributeName => $attributeValue) {
69-
$attributeValue = trim($attributeValue);
70-
$rootElementHtml .= $attributeValue ? " $attributeName=\"$attributeValue\"" : '';
58+
$childrenHtml = (isset($additionalData['children']) ? $additionalData['children'] : '');
59+
60+
// Wrap the children when the layout is full width
61+
if ($appearance === 'full-width') {
62+
$childrenHtml = '<div class="row-full-width-inner" data-element="inner">' . $childrenHtml . '</div>';
7163
}
72-
$rootElementHtml .= '>' . (isset($additionalData['children']) ? $additionalData['children'] : '') . '</div>';
64+
65+
$rootElementHtml = $this->renderElementWithAttributes(
66+
$rootElementAttributes,
67+
$childrenHtml
68+
);
7369

7470
// Wrap the root element in our wrapper for contained appearances
75-
if ($appearance === 'contained' && isset($wrapperElementAttributes)) {
76-
$wrapperElementHtml = '<div';
77-
foreach ($wrapperElementAttributes as $attributeName => $attributeValue) {
78-
$attributeValue = trim($attributeValue);
79-
$wrapperElementHtml .= $attributeValue ? " $attributeName=\"$attributeValue\"" : '';
80-
}
81-
$wrapperElementHtml .= '>' . $rootElementHtml . '</div>';
82-
return $wrapperElementHtml;
71+
if ($appearance === 'contained') {
72+
return $this->renderElementWithAttributes(
73+
[
74+
'data-element' => 'wrapper',
75+
'data-role' => 'row',
76+
'data-appearance' => 'contained',
77+
'class' => 'row-contained',
78+
],
79+
$rootElementHtml
80+
);
8381
}
8482

8583
return $rootElementHtml;
8684
}
85+
86+
/**
87+
* Render an element with an attributes array
88+
*
89+
* @param array $attributes
90+
* @param string $childrenHtml
91+
* @return string
92+
*/
93+
private function renderElementWithAttributes(array $attributes, string $childrenHtml = '') : string
94+
{
95+
$rootElementHtml = '<div';
96+
foreach ($attributes as $attributeName => $attributeValue) {
97+
$attributeValue = trim($attributeValue);
98+
$rootElementHtml .= $attributeValue ? " $attributeName=\"$attributeValue\"" : '';
99+
}
100+
$rootElementHtml .= '>' . $childrenHtml . '</div>';
101+
return $rootElementHtml;
102+
}
87103
}

app/code/Magento/PageBuilder/docs/row-appearance.md

Lines changed: 0 additions & 118 deletions
This file was deleted.

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_accordion_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">default</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_anchor_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">default</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_banner_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">poster</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_block_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">default</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_button_item_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">default</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_buttons_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">inline</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_column_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<label />
5656
</settings>
5757
</field>
58-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
58+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
5959
<argument name="data" xsi:type="array">
6060
<item name="config" xsi:type="array">
6161
<item name="default" xsi:type="string">full-height</item>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_divider_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<link name="hideLabel">${$.name}.appearance:options</link>
4545
</imports>
4646
</settings>
47-
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/appearance-visual-select">
47+
<field name="appearance" formElement="select" sortOrder="10" component="Magento_PageBuilder/js/form/element/dependent-visual-select">
4848
<argument name="data" xsi:type="array">
4949
<item name="config" xsi:type="array">
5050
<item name="default" xsi:type="string">default</item>

0 commit comments

Comments
 (0)