Skip to content

Commit ddd83ad

Browse files
committed
PB-73: Create Appearances example and documentation
Draft for review
1 parent 8a576c2 commit ddd83ad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Appearances provide different layout and styling options for a content type. For
55
This topic shows how to add appearances to existing content types. An overview of the steps and the files you need to add are illustrated here:
66

77
![How to add an appearance](../images/how-to-add-appearance.svg)
8+
89
_Steps for adding appearances_
910

1011
Even though this topic describes how to add appearances to Page Builder's native content types, the steps can be applied to adding more appearances to your custom content types as well.
@@ -14,11 +15,13 @@ Even though this topic describes how to add appearances to Page Builder's native
1415
First, we need a way select an appearance within the Admin UI. In Page Builder, we use the `VisualSelect` class. This class provides the UI for selecting different appearances. For example, the `VisualSelect` class for the Banner provides four appearances to choose from:
1516

1617
![Banner visual selector](../images/banner-visual-selector.png)
18+
1719
_Visual selector for Banner_
1820

1921
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:
2022

2123
![Add VisualSelect class](../images/add-visualselect-class.png)
24+
2225
_File and location for the VisualSelect class_
2326

2427
Within the `di.xml` file, add a `VisualSelect` class using the Banner's `VisualSelect` class name (`<virtualType name="AppearanceSourceBanner"`), as shown here:
@@ -54,6 +57,7 @@ The following table describes the configuration arguments for each appearance op
5457
| `title` | Display name for the appearance option. Banner example: Poster. |
5558
| `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 |
5659
| `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. |
60+
{:style="table-layout:auto"}
5761

5862
To add more appearance options, simply create more ` item` arrays, as shown here:
5963

@@ -101,19 +105,22 @@ You can use whatever tool you want to create your SVG. Just make sure you follow
101105
| background `rect y` | 21 |
102106
| background `rect fill` | #524D49 |
103107
| other `rect fill` properties | #FFF |
108+
{:style="table-layout:fixed"}
104109

105110
## Step 2: Add appearance configurations
106111

107112
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:
108113

109114
![Appearance configurations](../images/appearance-configurations.png)
115+
110116
_Appearance configurations explained_
111117

112118
The same concept applies to `styles`, `attributes`, and `css` elements. These elements ensure that the form settings (both content and styles) get applied to the templates as expected.
113119

114120
To add a new Banner appearance configuration, create a content type config file named `banner.xml`, as shown here:
115121

116122
![Appearance configuration config file](../images/appearance-config-file.png)
123+
117124
_Add additional appearances to Banner content type_
118125

119126
{: .bs-callout .bs-callout-info }
@@ -171,25 +178,29 @@ _Adding a form to an appearance_
171178
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:
172179

173180
![Appearance configuration config file](../images/appearance-templates-banner.png)
181+
174182
_Banner appearance templates_
175183

176184
Each template set is located within a folder named after the appearance for which they are used. The folder names must match the appearance names assigned in the content type's config file.
177185

178186
To create appearance templates for additional Banner appearances, such as the `simple-poster` appearance described in steps 1 and 2, you must add a new appearance folder for your module's templates, as shown here:
179187

180188
![Appearance templates](../images/appearance-templates-additional.png)
189+
181190
_Adding additional appearance templates_
182191

183192
## Step 5: Add appearance styles
184193

185194
Appearances use different CSS/LESS files to create different visual styles for a content type. For example, the Banner content type uses a different `.less` file for each appearance, as shown here:
186195

187196
![Appearance stylesheets](../images/appearance-css-banner.png)
197+
188198
_Banner stylesheets_
189199

190200
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:
191201

192202
![Additional appearance stylesheets](../images/appearance-css-additional.png)
203+
193204
_Adding additional stylesheets_
194205

195206
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:
@@ -205,6 +216,4 @@ Using appearances to extend Page Builder's native content types represents one o
205216

206217
## Example Module
207218

208-
An example module for this topic is available for download in the `pagebuilder-examples` repository here:
209-
210-
https://github.com/magento-devdocs/pagebuilder-examples/tree/master/Example/PageBuilderBannerAppearance
219+
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).

0 commit comments

Comments
 (0)