Skip to content

Commit 3f1ddd9

Browse files
authored
Merge pull request #387 from magento-obsessive-owls/PB-73
PB-73: Create Appearances example and documentation
2 parents cd86f30 + daba867 commit 3f1ddd9

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

docs/how-to/how-to-add-appearance.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to add an appearance
22

3-
Appearances provide different layout and styling options for a content type. For example, the Banner content type has four appearances. Each appearance shows a different layout for the Banner's text and button.
3+
Appearances provide different layout and styling options for a content type. For example, the Banner content type has four appearances. Each appearance shows a different layout for the Banner's included text and button.
44

55
This topic shows how to add appearances to Page Builder's native content types. An overview of the steps and the files you need to add are illustrated here:
66

@@ -18,7 +18,7 @@ First, we need a way select an appearance within the Admin UI. In Page Builder,
1818

1919
_Visual selector for Banner_
2020

21-
To add a new appearance option for one of Page Builder's native content types, like the Banner, create a new `di.xml` file in your module, as shown here:
21+
To add a new appearance option for one of Page Builder's native content types (such as the Banner), create a new `di.xml` file in your module, as shown here:
2222

2323
![Add VisualSelect class](../images/add-visualselect-class.png)
2424

@@ -51,7 +51,7 @@ The following table describes the configuration arguments for each appearance op
5151
| --------------- | ------------------------------------------------------------ |
5252
| `optionsData` | Grouping array for all the appearance options of a content type. |
5353
| `item array` | Grouping array of properties that define an appearance option. We recommend you match the `name` of the item array to the option's `value` string. In our example, the `item` array's name is `simple-poster`, which matches the option's value string `simple-poster`. |
54-
| `value` | The `value` string should match the appearance name defined in the content type's configuration file. Page Builder uses this value to link the option to the appearance.|
54+
| `value` | String that matches the appearance name defined in the content type's configuration file. Page Builder uses this string value to link the option to the appearance.|
5555
| `title` | Display name for the appearance option. Banner example: Poster. |
5656
| `icon` | Path to the `.svg` icon for the appearance: `view/adminthtml/web/css/images/content-type/[content-type-name]/appearance/*.svg`. See [Creating an icon for your appearance](#create-an-appearance-icon) |
5757
| `noticeMessage` | (Not shown in example.) The `noticeMessage` displays a message below the appearance options when the appearance is selected. For example, two of the Row appearances (`full-width` and `full-bleed`) define `noticeMessage` strings that display when selected. |
@@ -75,11 +75,11 @@ _Example of additional appearance options_
7575

7676
### Create an appearance icon
7777

78-
Appearance icons are `.svg` files that graphically depict the layout of an appearance. Add all the appearance icons for your content type within the following directory: `css/images/content-type/[content-type-name]/appearance/`.
78+
Appearance icons are `.svg` files that graphically depict the layout of an appearance. Add your additional appearance icons to your module's css appearance directory (`css/images/content-type/[content-type-name]/appearance/`). Additional appearance icons for the Banner would be added as shown here:
7979

8080
![Add appearance icons](../images/appearance-icon-location.png)
8181

82-
_Add appearance icons for Banner content type_
82+
_Additional appearance icons for Banner_
8383

8484
You can use any design tool to create your SVG. But if you want to match your appearance icons to Page Builder's icons _perfectly_, use the SVG structure and dimensions shown here:
8585

@@ -96,7 +96,7 @@ You can use any design tool to create your SVG. But if you want to match your ap
9696
```
9797
_SVG appearance template_
9898

99-
These specific dimensions ensure that your icon fits seamlessly with the existing appearance icons:
99+
These specific dimensions ensure that your icon fits seamlessly with Page Builder's existing appearance icons:
100100

101101
| Property | Value |
102102
| ------------------------------ | ----------- |
@@ -114,7 +114,7 @@ These specific dimensions ensure that your icon fits seamlessly with the existin
114114

115115
## Step 2: Add appearance configurations
116116

117-
Appearance configurations connect the data entered in a content type's form to its HTML templates. For example, the Heading content type has an `<html>` config element (`<html name="heading_text" />`) that maps the text entered into the content type's `heading_text` form field (`<field name="heading_text" formElement="input">`) to the Heading's Knockout template binding (`html="data.main.html"`), as illustrated here:
117+
Appearance configurations connect the data entered in a content type's form to its HTML templates. For example, the Heading content type has an `<html>` config element (`<html name="heading_text" />`) that maps the text entered into the content type's `heading_text` field (`<field name="heading_text" formElement="input">`) to the Heading's Knockout template binding (`html="data.main.html"`), as illustrated here:
118118

119119
![Appearance configurations](../images/appearance-configurations.png)
120120

@@ -129,7 +129,7 @@ To add a new Banner appearance configuration, create a content type config file
129129
_Add additional appearances to Banner content type_
130130

131131
{: .bs-callout .bs-callout-info }
132-
This procedure applies to any native content type you want to extend. In other words, you can use the file name (`heading.xml`) and type name (`<type name="heading">`) of any native Page Builder content type to extend it based on Magento's XML merging behavior.
132+
This procedure applies to any native content type you want to extend. In other words, you can use the file name (such as `heading.xml`) and type name (such as `<type name="heading">`) of any content type to extend it based on Magento's XML merging behavior.
133133

134134
An example `banner.xml` config file for a new `simple-poster` appearance is shown here:
135135

@@ -165,7 +165,7 @@ _Additional simple-poster appearance for the Banner content type_
165165

166166
Appearances for a content type can share the same form or use different forms. For example, the Products content type uses two different forms, one for each appearance. The Grid appearance uses the `pagebuilder_products_form.xml` to provide options for displaying products in a grid. While the Carousel appearance uses the `pagebuilder_products_carousel_form.xml` to provide extra options for displaying products in a carousel.
167167

168-
When you select an appearance with its own form, Page Builder replaces the content type's form (defined in the `<type>` element) with the appearance's form. But when you select an appearance that does not have a form defined, the appearance switches back to using the content type's form.
168+
When you select an appearance with a form, Page Builder replaces the content type's form (defined in the `<type>` element) with the appearance's form. But when you select an appearance that does _not_ have a form defined, the appearance switches back to using the content type's form.
169169

170170
```xml
171171
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...>
@@ -174,7 +174,7 @@ When you select an appearance with its own form, Page Builder replaces the conte
174174
```
175175
_Content type form used by default for all appearances_
176176

177-
To add a form for an appearance, add a `<form>` element as a child of the `<appearance>` element in your content type's config file. As mentioned, the Products content type does this for its Carousel appearance, shown here:
177+
To add a form for an appearance, add a `<form>` element as a child of the `<appearance>` element in your content type's config file. As mentioned, the Products content type uses a form for its Carousel appearance, as shown here:
178178

179179
```xml
180180
<appearance name="carousel"
@@ -189,19 +189,20 @@ _Adding a form to an appearance_
189189

190190
## Step 4: Add appearance templates
191191

192-
Appearances use different HTML templates to create different layouts and apply different styles to those layouts. For example, the Banner content type uses four sets of `preview.html` and `master.html` templates to create the visual differences for each content type:
192+
Appearances use different HTML templates to create different layouts. They also use templates to apply different styles to the same layouts. For example, the Banner uses four sets of `preview.html` and `master.html` templates, one set for each appearance:
193193

194194
![Appearance configuration config file](../images/appearance-templates-banner.png)
195195

196196
_Banner appearance templates_
197197

198+
{: .bs-callout .bs-callout-info }
198199
Notice how Page Builder organizes the Banner templates by appearance name. We recommend the same practice when adding templates for your appearances.
199200

200-
To create appearance templates for additional Banner appearances, such as the `simple-poster` appearance described in steps 1 and 2, add a new appearance folder for your module's templates, as shown here:
201+
To create templates for additional Banner appearances, such as the `simple-poster` described in steps 1 and 2, add a new appearance folder with your `master.html` and `preview.html` templates, as shown here:
201202

202203
![Appearance templates](../images/appearance-templates-additional.png)
203204

204-
_Adding additional appearance templates_
205+
_Add additional templates to `template/content-type/[content-type-name]/[appearance-name]`_
205206

206207
## Step 5: Add appearance styles
207208

@@ -211,11 +212,11 @@ Appearances use different CSS/LESS files to create different visual styles for a
211212

212213
_Banner stylesheets_
213214

214-
To create a LESS stylesheet for an additional Banner appearances, such as the `simple-poster`, you must add a new appearance folder for your module's templates, as shown here:
215+
To create a stylesheet for an additional Banner appearance, such as the `simple-poster`, add a folder named `banner` and a `.less` file with the name of the appearance, as shown here:
215216

216217
![Additional appearance stylesheets](../images/appearance-css-additional.png)
217218

218-
_Adding additional stylesheets_
219+
_Add additional stylesheets to `css/source/content-type/[content-type-name]/`_
219220

220221
The `_module.less` file is an import file that ensures the additional stylesheet gets added to the existing Banner styles. The `_module.xml` file for our `simple-poster.less` file looks like this:
221222

@@ -224,10 +225,10 @@ The `_module.less` file is an import file that ensures the additional stylesheet
224225
```
225226
_Use _module.less for import statements_
226227

227-
## Conclusion
228-
229-
Using appearances to extend Page Builder's native content types represents one of Page Builder's best practices for creating a variety of new content building blocks based on existing content types. We hope this topic has helped adequately describe this best practice.
230-
231228
## Example Module
232229

233230
An example module for this topic is available for download in the [pagebuilder-examples repository](https://github.com/magento-devdocs/pagebuilder-examples/tree/master/Example/PageBuilderBannerAppearance).
231+
232+
## Conclusion
233+
234+
Using appearances to extend Page Builder's native content types represents one of Page Builder's best practices for creating a variety of new content building blocks based on existing content types.

0 commit comments

Comments
 (0)