Skip to content

Commit 581d279

Browse files
committed
MC-3150: Update dev docs for row appearances
- Include information regarding new visual select usage
1 parent 9882200 commit 581d279

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

app/code/Magento/PageBuilder/docs/visual-select.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ To add Visual Select customization to a Page Builder content block:
6969

7070
## Override the select component with an element template {#element-template}
7171

72-
We use the default select component in the `/app/code/Magento/PageBuilder/view/adminhtml/ui-component/pagebuilder_base_form.xml` file. You can override the default template, specifying an element template for this functionality, to implement the Visual Select option.
72+
We use the default select component in the `/app/code/Magento/PageBuilder/view/adminhtml/ui-component/pagebuilder_base_form.xml` file. You can override the default template, specifying an element template & component for this functionality, to implement the Visual Select option.
7373

74-
In the provided template, specify `<elementTmpl>`:
74+
In the provided template, specify `<elementTmpl>` alongside updating the fields component to `Magento_PageBuilder/js/form/element/visual-select`:
7575

7676
``` xml
77-
<field name="text_align" sortOrder="10" formElement="select">
77+
<field name="text_align" sortOrder="10" formElement="select" component="Magento_PageBuilder/js/form/element/visual-select">
7878
<settings>
7979
<dataType>text</dataType>
8080
<label translate="true">Alignment</label>
@@ -84,23 +84,24 @@ In the provided template, specify `<elementTmpl>`:
8484

8585
## Add Visual Select to the XML config {#xml-config}
8686

87-
The available options for select, `value`, `title`, and `icon`, can be provided by the PHP class that implements the `\Magento\Framework\Option\ArrayInterface` method.
87+
The available options for select, `value`, `title`, `icon` and `noticeMessage`, can be provided by the PHP class that implements the `\Magento\Framework\Option\ArrayInterface` method.
8888

8989
Options should return an array with the following format:
9090

9191
``` php
9292
[
9393
value => "value", //key used in the component dataSource
9494
title => "Title",
95-
icon => "path/to/picture/on/server"
95+
icon => "path/to/picture/on/server",
96+
noticeMessage => "A message to be displayed when option is selected"
9697
]
9798
```
9899

99100
These new configuration values are used in the `align.html` template file stored in Page Builder's `app/code/Magento/Pagebuilder/view/adminhtml/web/template/form/element` directory.
100101

101102
Use a virtual type of `Magento\PageBuilder\Model\Source\VisualSelect` in your module's `di.xml` configuration file to define the options in a visual select field.
102103

103-
``` xml
104+
```xml
104105
<virtualType name="AlignmentSource" type="Magento\PageBuilder\Model\Source\VisualSelect">
105106
<arguments>
106107
<argument name="optionsSize" xsi:type="string">small</argument>
@@ -129,6 +130,17 @@ Use a virtual type of `Magento\PageBuilder\Model\Source\VisualSelect` in your mo
129130
</virtualType>
130131
```
131132

133+
### Display notice when option is selected
134+
For some options you may wish to display an additional notice when the user selects the item. You can do this by providing a `noticeMessage` within the items declaration.
135+
```xml
136+
<item name="3" xsi:type="array">
137+
<item name="value" xsi:type="string">right</item>
138+
<item name="title" xsi:type="string" translate="true">Right</item>
139+
<item name="icon" xsi:type="string">Magento_PageBuilder/css/images/form/element/visual-select/alignment/right.svg</item>
140+
<item name="noticeMessage" xsi:type="string" translate="true">Message to be displayed below field when selected.</item>
141+
</item>
142+
```
143+
132144
## How to reuse vertical alignment between different content types {#vertical-alignment}
133145
To apply vertical alignment to a content type using the Visual Select component, use the virtualType `Magento\PageBuilder\Model\Source\VerticalAlignment` with options in your module's `di.xml` configuration file.
134146

@@ -158,7 +170,7 @@ To apply vertical alignment to a content type using the Visual Select component,
158170
```
159171
### Add the Visual Select option in your module's form configuration file.
160172
```xml
161-
<field name="justify_content" sortOrder="20" formElement="select">
173+
<field name="justify_content" sortOrder="20" formElement="select" component="Magento_PageBuilder/js/form/element/visual-select">
162174
<argument name="data" xsi:type="array">
163175
<item name="config" xsi:type="array">
164176
<item name="default" xsi:type="string">flex-start</item>

0 commit comments

Comments
 (0)