Skip to content

Commit 6b0c156

Browse files
committed
MAGEDOC-3448: Add docs for content type styles
Incorporated review comments
1 parent afd2742 commit 6b0c156

File tree

9 files changed

+301
-302
lines changed

9 files changed

+301
-302
lines changed

docs/create-basic-content-type/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The steps for creating the Quote content type are illustrated and described belo
3535
3. **Add component**: Create a JavaScript file that defines the behavior of your content type on the Admin stage (`preview.js`) and the storefront (`master.js`).
3636
4. **Add form**: Create a UI component form and a layout so Admin users can edit your content type within the Page Builder editor.
3737
5. **Add styles**: Create LESS files to style your content types when rendered in the Admin UI and on the storefront.
38-
6. **Add icon**: Create an SVG icon to visually identify your content type within the Page Builder panel.
38+
6. **Add an icon**: Create an SVG icon to visually identify your content type within the Page Builder panel.
3939

4040
## Quote file structure
4141

docs/create-basic-content-type/step-1-add-configuration.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following configuration is from the Quote content type. An overview of these
2727
```xml
2828
<?xml version="1.0"?>
2929
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_PageBuilder:etc/content_type.xsd">
30-
<type name="example_quote"
30+
<type name="example_quote"
3131
label="Quote"
3232
group="elements"
3333
component="Magento_PageBuilder/js/content-type"
@@ -39,18 +39,18 @@ The following configuration is from the Quote content type. An overview of these
3939
translate="label">
4040
<children default_policy="deny"/>
4141
<parents default_policy="deny">
42-
<parent name="column" policy="allow"/>
42+
<parent name="column" policy="allow"/>
4343
</parents>
4444
<appearances>
45-
<appearance name="default"
45+
<appearance name="default"
4646
default="true"
4747
preview_template="Example_PageBuilderQuote/content-type/acme_quote/default/preview"
4848
render_template="Example_PageBuilderQuote/content-type/acme_quote/default/master"
4949
reader="Magento_PageBuilder/js/master-format/read/configurable">
5050
<elements...>
51-
</appearance>
51+
</appearance>
5252
</appearances>
53-
</type>
53+
</type>
5454
</config>
5555
```
5656

@@ -67,8 +67,8 @@ The `type` element defines the key properties of your content type. The attribut
6767
| `preview_component` | Optional. JavaScript file (`preview.js`) that provides rendering logic within the Admin UI. The preview component does not need to specify the `.js` extension. If you don't provide the `preview_component`, Page Builder uses the base `Preview` component shown in the code: `Magento_PageBuilder/js/content-type/preview`. |
6868
| `master_component` | Optional. JavaScript file (`master.js`) that provides rendering logic generic for all appearances of your content type when rendered on the storefront. The master component does not need to specify the `.js` extension. If you don't provide the `master_component`, Page Builder uses the base `Master` component shown in the code: `Magento_PageBuilder/js/content-type/master`. |
6969
| `form` | UI component form that provides the form controls for editing your content type. |
70-
| `icon` | Optional. Class name for your PNG or SVG image (or font icon) displayed in the Page Builder panel alongside the label. If no icon value is provided, the content type will simply be displayed in the Page Builder panel without an icon. |
71-
| `sortOrder` | Optional. The listed order within the menu group. For example, `sortOrder=21` puts the content type third in the `Elements` menu group, after the content types with `sortOrder`s of 10 and 20. |
70+
| `icon` | Optional. Class name for your PNG or SVG image (or font icon) displayed in the Page Builder panel alongside the label. If you don't provide an icon value, the Page Builder panel displays the content type name without an icon. |
71+
| `sortOrder` | Optional. The listed order within the menu group. For example, `sortOrder=21` puts the content type third in the `Elements` menu group, after the content types with `sortOrder` values of 10 and 20. |
7272
| `translate` | Identifies the attribute you want Magento to translate. Here, the `label` value is set for translation. |
7373

7474
## The `children` element
@@ -87,7 +87,7 @@ The `parents` element determines if other content types can be a parent to your
8787

8888
```xml
8989
<parents default_policy="deny">
90-
<parent name="column" policy="allow"/>
90+
<parent name="column" policy="allow"/>
9191
</parents>
9292
```
9393

@@ -103,10 +103,10 @@ Each of these views is defined as an `appearance` within the Banner configuratio
103103

104104
```xml
105105
<appearances>
106-
<appearance name="collage-left"...>
107-
<appearance name="collage-centered"...>
108-
<appearance name="collage-right"...>
109-
<appearance name="poster" default="true" ...>
106+
<appearance name="collage-left"...>
107+
<appearance name="collage-centered"...>
108+
<appearance name="collage-right"...>
109+
<appearance name="poster" default="true" ...>
110110
</appearances>
111111
```
112112

docs/create-basic-content-type/step-2-add-templates.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Conventions for adding content type templates are as follows.
1616

1717
```xml
1818
<appearances>
19-
<appearance name="collage-left"...>
20-
<appearance name="collage-centered"...>
21-
<appearance name="collage-right"...>
22-
<appearance name="poster" default="true" ...>
19+
<appearance name="collage-left"...>
20+
<appearance name="collage-centered"...>
21+
<appearance name="collage-right"...>
22+
<appearance name="poster" default="true" ...>
2323
</appearances>
2424
```
2525

@@ -33,8 +33,8 @@ The Quote example defines only one `appearance`. Therefore, by convention, set t
3333

3434
```xml
3535
<appearances>
36-
<appearance name="default"
37-
...
36+
<appearance name="default"
37+
...
3838
```
3939

4040
![Create config file](../images/step2-add-templates.png)
@@ -43,13 +43,13 @@ These files can be blank initially; they just need to exist in their proper loca
4343

4444
```xml
4545
<appearances>
46-
<appearance name="default"
46+
<appearance name="default"
4747
default="true"
4848
preview_template="Example_PageBuilderQuote/content-type/example-quote/default/preview"
4949
render_template="Example_PageBuilderQuote/content-type/example-quote/default/master"
5050
reader="Magento_PageBuilder/js/master-format/read/configurable">
5151
<elements...>
52-
</appearance>
52+
</appearance>
5353
</appearances>
5454
```
5555

@@ -74,24 +74,24 @@ The Quote `preview_template` (`preview.html`) is shown here in full, followed b
7474
class="pagebuilder-content-type"
7575
css="data.main.css"
7676
event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
77-
<render args="getOptions().template" />
78-
<blockquote attr="data.quote.attributes"
77+
<render args="getOptions().template" />
78+
<blockquote attr="data.quote.attributes"
7979
ko-style="data.quote.style"
8080
css="data.quote.css"
8181
data-bind="liveEdit: { field: 'quote_text', placeholder: $t('Enter Quote') }">
82-
</blockquote>
83-
<div class="quote-author"
82+
</blockquote>
83+
<div class="quote-author"
8484
attr="data.author.attributes"
8585
ko-style="data.author.style"
8686
css="data.author.css"
8787
data-bind="liveEdit: { field: 'quote_author', placeholder: $t('Enter Author') }">
88-
</div>
89-
<div class="quote-title"
88+
</div>
89+
<div class="quote-title"
9090
attr="data.author_title.attributes"
9191
ko-style="data.author_title.style"
9292
css="data.author_title.css"
9393
data-bind="liveEdit: { field: 'quote_author_desc', placeholder: $t('Enter Description') }">
94-
</div>
94+
</div>
9595
</div>
9696
```
9797

@@ -104,8 +104,8 @@ The value for `attr` is derived from the `element` name in the configuration fil
104104
```xml
105105
<!-- quote.xml -->
106106
<element name="quote">
107-
<html name="quote_text" converter="Magento_PageBuilder/js/converter/html/tag-escaper"/>
108-
<css name="quote_css"/>
107+
<html name="quote_text" converter="Magento_PageBuilder/js/converter/html/tag-escaper"/>
108+
<css name="quote_css"/>
109109
</element>
110110
```
111111

@@ -118,15 +118,15 @@ The `ko-style` attribute applies the `<style>` attributes from the form to a tem
118118
```xml
119119
<!-- quote.xml -->
120120
<element name="main">
121-
<style name="text_align" source="text_align"/>
122-
<style name="border" source="border_style" converter="Magento_PageBuilder/js/converter/style/border-style"/>
123-
<style name="border_color" source="border_color"/>
124-
<style name="background_color" source="background_color"/>
125-
<style name="border_width" source="border_width" converter="Magento_PageBuilder/js/converter/style/border-width"/>
126-
<style name="border_radius" source="border_radius" converter="Magento_PageBuilder/js/converter/style/remove-px"/>
127-
<style name="margins" storage_key="margins_and_padding" reader="Magento_PageBuilder/js/property/margins" converter="Magento_PageBuilder/js/converter/style/margins"/>
128-
<style name="padding" storage_key="margins_and_padding" reader="Magento_PageBuilder/js/property/paddings" converter="Magento_PageBuilder/js/converter/style/paddings"/>
129-
...
121+
<style name="text_align" source="text_align"/>
122+
<style name="border" source="border_style" converter="Magento_PageBuilder/js/converter/style/border-style"/>
123+
<style name="border_color" source="border_color"/>
124+
<style name="background_color" source="background_color"/>
125+
<style name="border_width" source="border_width" converter="Magento_PageBuilder/js/converter/style/border-width"/>
126+
<style name="border_radius" source="border_radius" converter="Magento_PageBuilder/js/converter/style/remove-px"/>
127+
<style name="margins" storage_key="margins_and_padding" reader="Magento_PageBuilder/js/property/margins" converter="Magento_PageBuilder/js/converter/style/margins"/>
128+
<style name="padding" storage_key="margins_and_padding" reader="Magento_PageBuilder/js/property/paddings" converter="Magento_PageBuilder/js/converter/style/paddings"/>
129+
...
130130
</element>
131131
```
132132

@@ -173,23 +173,24 @@ The Quote `render_template` (`master.html`) is shown here in full. The same attr
173173
```html
174174
<!--master.html-->
175175
<div attr="data.main.attributes">
176-
<blockquote attr="data.quote.attributes"
176+
<blockquote class="quote-content"
177+
attr="data.quote.attributes"
177178
ko-style="data.quote.style"
178179
css="data.quote.css"
179180
html="data.quote.html">
180-
</blockquote>
181-
<div class="quote-author"
181+
</blockquote>
182+
<div class="quote-author"
182183
attr="data.author.attributes"
183184
ko-style="data.author.style"
184185
css="data.author.css"
185186
html="data.author.html">
186-
</div>
187-
<div class="quote-title"
187+
</div>
188+
<div class="quote-title"
188189
attr="data.author_title.attributes"
189190
ko-style="data.author_title.style"
190191
css="data.author_title.css"
191192
html="data.author_title.html">
192-
</div>
193+
</div>
193194
</div>
194195
```
195196

@@ -216,8 +217,8 @@ The `html` value is derived from the configuration `element` name (`quote`) and
216217

217218
```xml
218219
<element name="quote">
219-
<html name="quote_text" converter="Magento_PageBuilder/js/converter/html/tag-escaper"/>
220-
...
220+
<html name="quote_text" converter="Magento_PageBuilder/js/converter/html/tag-escaper"/>
221+
...
221222
</element>
222223
```
223224

docs/create-basic-content-type/step-3-add-components.md

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ In your configuration file, reference your Admin `preview_component` (`preview.j
5050
```xml
5151
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5252
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_PageBuilder:etc/content_type.xsd">
53-
<type name="example_quote"
53+
<type name="example_quote"
5454
label="Quote"
5555
component="Magento_PageBuilder/js/content-type"
5656
preview_component="Example_PageBuilderQuote/js/content-type/example_quote/preview"
5757
master_component="Magento_PageBuilder/js/content-type/master">
5858
...
59-
</type>
59+
</type>
6060
</config>
6161
```
6262

@@ -76,37 +76,37 @@ The Quote `preview_component` (`preview.js`) example is shown here in full for
7676
define([
7777
'Magento_PageBuilder/js/content-type/preview',
7878
], function (PreviewBase) {
79-
'use strict';
80-
var $super;
81-
82-
function Preview(parent, config, stageId) {
79+
'use strict';
80+
var $super;
81+
82+
function Preview(parent, config, stageId) {
8383
PreviewBase.call(this, parent, config, stageId);
84-
}
85-
86-
Preview.prototype = Object.create(PreviewBase.prototype);
87-
$super = PreviewBase.prototype;
88-
89-
Preview.prototype.retrieveOptions = function retrieveOptions() {
84+
}
85+
86+
Preview.prototype = Object.create(PreviewBase.prototype);
87+
$super = PreviewBase.prototype;
88+
89+
Preview.prototype.retrieveOptions = function retrieveOptions() {
9090
var options = $super.retrieveOptions.call(this, arguments);
91-
91+
9292
// Change option menu icons
9393
options.remove.icon = "<i class='icon-admin-pagebuilder-error'></i>";
94-
94+
9595
// Change tooltips
9696
options.edit.title = "Open Editor";
9797
options.remove.title = "Delete";
9898
// options.move.title = "Move";
9999
// options.duplicate.title = "Duplicate";
100-
100+
101101
// Remove menu options
102102
// delete options.move;
103103
// delete options.duplicate;
104104
// delete options.edit;
105105
// delete options.remove;
106-
106+
107107
return options;
108-
};
109-
return Preview;
108+
};
109+
return Preview;
110110
});
111111
```
112112

@@ -118,15 +118,15 @@ The first thing we do in our preview component is extend Page Builder's `Preview
118118
define([
119119
'Magento_PageBuilder/js/content-type/preview',
120120
], function (PreviewBase) {
121-
'use strict';
122-
var $super;
123-
124-
function Preview(parent, config, stageId) {
121+
'use strict';
122+
var $super;
123+
124+
function Preview(parent, config, stageId) {
125125
PreviewBase.call(this, parent, config, stageId);
126-
}
127-
128-
Preview.prototype = Object.create(PreviewBase.prototype);
129-
$super = PreviewBase.prototype;
126+
}
127+
128+
Preview.prototype = Object.create(PreviewBase.prototype);
129+
$super = PreviewBase.prototype;
130130
```
131131
132132
You don't have to extend `Preview` this way, but if you do, you get access to both its public and protected functions. In our Quote example, we need access to one protected function, discussed next.
@@ -141,24 +141,24 @@ To do this, we need to override the protected `retrieveOptions()` function from
141141
142142
```js
143143
Preview.prototype.retrieveOptions = function retrieveOptions() {
144-
var options = $super.retrieveOptions.call(this, arguments);
145-
146-
// Change option menu icons
147-
options.remove.icon = "<i class='icon-admin-pagebuilder-error'></i>";
148-
149-
// Change tooltips
150-
options.edit.title = "Open Editor";
151-
options.remove.title = "Delete";
152-
// options.move.title = "Move";
153-
// options.duplicate.title = "Duplicate";
154-
155-
// Remove menu options
156-
// delete options.move;
157-
// delete options.duplicate;
158-
// delete options.edit;
159-
// delete options.remove;
160-
161-
return options;
144+
var options = $super.retrieveOptions.call(this, arguments);
145+
146+
// Change option menu icons
147+
options.remove.icon = "<i class='icon-admin-pagebuilder-error'></i>";
148+
149+
// Change tooltips
150+
options.edit.title = "Open Editor";
151+
options.remove.title = "Delete";
152+
// options.move.title = "Move";
153+
// options.duplicate.title = "Duplicate";
154+
155+
// Remove menu options
156+
// delete options.move;
157+
// delete options.duplicate;
158+
// delete options.edit;
159+
// delete options.remove;
160+
161+
return options;
162162
};
163163
```
164164

0 commit comments

Comments
 (0)