Skip to content

Commit 5ead7c9

Browse files
committed
MAGEDOC-3421: Add docs for content type icon
1 parent 0cb41bf commit 5ead7c9

20 files changed

+258
-63
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Overview
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
Page Builder comes with several content types (controls) you can use to build your storefront pages. In this tutorial, you will add a new content type: a **Quote** control, which you can use to show customer testimonials or other types of quotations within your storefront.
94

105
![Page Builder Content Types](../images/panel-horizontal.png)
@@ -19,8 +14,6 @@ And the same three Quote controls are shown rendered here on a mock testimonial
1914

2015
![StorefrontTestimonials](../images/StorefrontTestimonials.png)
2116

22-
23-
2417
## Quote module
2518

2619
As with most things in Magento, content types for Page Builder are housed in modules. The convention for naming modules that are solely dedicated to Page Builder, such as our Quote content type, is to prefix all the content type name with `PageBuilder`. This helps visually group content type modules within your vendor directory. Of course, this convention doesn't apply If you are adding a content type as part of an existing module.
@@ -35,14 +28,14 @@ After registering your module (`bin/magento setup:upgrade`) you will be ready to
3528

3629
The steps for creating the Quote content type are illustrated and described below. The reality is not quite this linear, but these steps do represent the basic phases and flow for building new Page Builder content types.
3730

38-
![Creating Custom Content Types](../images/content-type-overview.png)
31+
![Creating Custom Content Types](../images/content-type-overview.svg)
3932

4033
1. **Add configuration**: Create an XML file to define your content type and reference the other files that control the appearance and behavior of your content type.
4134
2. **Add templates**: Create HTML templates that define the appearance of your content types on the Admin stage (`preview.html`) and the storefront (`master.html`).
4235
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`).
4336
4. **Add form**: Create a UI component form and a layout so Admin users can edit your content type within the Page Builder editor.
4437
5. **Add styles**: Create LESS files to style your content types when rendered in the Admin UI and on the storefront.
45-
6. **Add frontend widget**: Create a JavaScript file to control the UI behavior (user interactivity) of your content type on the storefront.
38+
6. **Add icon**: Create an SVG icon to visually identify your content type within the Page Builder panel.
4639

4740
## Quote file structure
4841

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Step 1: Add configuration
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
The configuration file defines the settings and references to your content type files. You will return to this file often to update references and change settings during the development process.
94

105
Files referenced from the configuration include the HTML templates, the JavaScript components, the icon displayed for your content type in the Page Builder panel, and the UI component form for your content type editor within the Admin.
@@ -72,7 +67,7 @@ The `type` element defines the key properties of your content type. The attribut
7267
| `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`. |
7368
| `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`. |
7469
| `form` | UI component form that provides the form controls for editing your content type. |
75-
| `icon` | Optional. PNG or SVG image 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. |
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. |
7671
| `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. |
7772
| `translate` | Identifies the attribute you want Magento to translate. Here, the `label` value is set for translation. |
7873

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Step 2: Add templates
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
Content type templates are the HTML files (HTML fragments) that define how your content type *appears* on both the Admin stage and within your storefront. The combination of these templates (one `preview.html` and one `master.html`) creates an `appearance`. As discussed in the previous configuration step, you must have at least one `appearance` (two templates) defined for your content type. But like the Banner, you can define several appearances for users to choose from as shown here:
94

105
![banner-appearances](../images/banner-appearances.png)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Step 3: Add components (optional)
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
In this step, we will create a preview component in order to customize the options menu for our Quote. The options menu is the popup menu that appears when you mouseover a content type, as shown here:
94

105
![Create config file](../images/options-menu-default.png)

docs/create-basic-content-type/step-4-add-form.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Step 4: Add form
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
In this step, we will create a UI component form. This form will give users another way to enter text for the quote and style its appearance.
94

105
## About forms

docs/create-basic-content-type/step-5-add-styles.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Step 5: Add styles
22

3-
***
4-
The development of this tutorial is currently **IN PROGRESS**.
5-
6-
***
7-
83
In this step, we will create CSS styles (using LESS) so that we can give end-users different options for customizing the Quote's appearance in the Admin and on the storefront.
94

105
## About styles
116

12-
Page Builder specifies two ways to
7+
Page Builder provides you with two ways to add styles to your content types:
8+
9+
1310

1411
Describe how the Quote content type combines the usage of style files from end-user specification of classes in forms, to non-interactive styles used in the templates.
1512

@@ -36,8 +33,6 @@ CSS classes from your LESS files are typically used within your HTML templates.
3633

3734
![Create config file](../images/css-classes-input-field.png)
3835

39-
40-
4136
```xml
4237
<elements>
4338
<element name="main">

docs/create-basic-content-type/step-6-add-frontend-widget.md

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Step 6: Add icon
2+
3+
In this last step, we will create a panel icon for our Quote content type so that it has a unique but visually consistent identity alongside Page Builder's native font icons. When finished, the panel icon for our Quote content type will look something like this:
4+
5+
![Create config file](../images/step6-quote-panel-icon.png)
6+
7+
## About icons
8+
9+
The icons used for Page Builder's built-in content types are actually font icons. You could create your own font icons and use those within your module in a similar manner, but we recommend a simpler, more straightforward way by using SVG or PNG images instead.
10+
11+
A summary of the steps for creating and adding this icon are listed here:
12+
13+
1. Create your SVG or PNG icon.
14+
2. Create a CSS class for the icon.
15+
3. Reference the icon class in the config file.
16+
17+
## Create your icon
18+
19+
As mentioned, you can create a PNG or an SVG icon, but we recommend creating SVG icons for their smaller size and resolution independent rendering in browsers and mobile devices. Use the following specifications to create a panel icon that integrates seemlessly with the existing panel icons.
20+
21+
![Create config file](../images/step6-icon-properties.png)
22+
23+
As the illustration shows, the artboard represents the actual width and height of your icon when it is exported from your graphics application (16 x 16px). The artwork represents the content of your icon. Following these dimensions ensures your icons will match the size and positioning of the existing Page Builder icons within the panel.
24+
25+
When finished, add your icon to your `images` directory as follows:
26+
27+
![Create config file](../images/step6-add-icon.png)
28+
29+
## Create CSS class for icon
30+
31+
The next step to integrating your icon into the panel is creating a CSS class that references your SVG file. This class should be added to your LESS file in `adminhtml` as shown here:
32+
33+
![Create config file](../images/step6-icon-style.png)
34+
35+
The CSS for integrating SVG and PNG images with the font icons used by Page Builder can be a bit tricky in terms of matching size and positioning. As such, we recommend the following CSS rule set and conventions, changing only the content url path to your icon:
36+
37+
```css
38+
.icon-pagebuilder-quote {
39+
content: url(../Example_PageBuilderQuote/css/images/content-type/example-quote/appearance/icon-pagebuilder-quote.svg);
40+
width: 18px;
41+
height: 18px;
42+
margin-bottom: -1px;
43+
}
44+
```
45+
46+
| Attribute | Description |
47+
| --------------- | ------------------------------------------------------------ |
48+
| `class name` | To match the class names of Page Builder's native icons, we recommend prefixing your icon names with `icon-pagebuilder` as we have done with our Quote icon. |
49+
| `content` | The relative path to your SVG or PNG icon when rendered from `pub/static`. More details follow below. |
50+
| `width` | Sets the width of the content area that most closely matches the widths of Page Builder icon fonts. |
51+
| `height` | Sets the height of the content area that most closely matches the widths of Page Builder icon fonts. |
52+
| `margin-bottom` | Pulls the SVG or PNG image down within the panel container to more closely match the positioning of Page Builder's font icon. |
53+
54+
### Content path to icon image
55+
56+
When you add the relative content path to your SVG or PNG image, you must start from the consolidated `styles.css` within `pub/static` as shown below.
57+
58+
![Create config file](../images/step6-icon-link-static.png)
59+
60+
In the case of our Quote icon, the relative path must be set as:
61+
62+
```css
63+
.icon-pagebuilder-quote {
64+
content: url(../Example_PageBuilderQuote/css/images/content-type/example-quote/appearance/icon-pagebuilder-quote.svg);
65+
...
66+
}
67+
```
68+
69+
This referencing your image from your CSS icon class ensures that the link to your image will be created in the static output and the icon will resolve in the browser.
70+
71+
## Add icon class to config file
72+
73+
The last step is to add our icon's class name to our config file. Previous to this step, we used an existing icon class: `icon-pagebuilder-heading`. Now we can replace this class with our new class: `icon-pagebuilder-quote`, as shown here:
74+
75+
```xml
76+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_PageBuilder:etc/content_type.xsd">
77+
<type name="example_quote"
78+
label="Quote"
79+
group="elements"
80+
component="Magento_PageBuilder/js/content-type"
81+
preview_component="Example_PageBuilderQuote/js/content-type/example-quote/preview"
82+
master_component="Magento_PageBuilder/js/content-type/master"
83+
form="pagebuilder_example_quote_form"
84+
icon="icon-pagebuilder-quote"
85+
sortOrder="21"
86+
translate="label"
87+
>
88+
```
89+
90+
That's it. Now you can regenerate your static assets, empty your browser cache, and do a hard reload of your Admin page to see your new icon in the panel.
91+
92+
93+
94+

docs/create-basic-content-type/whats-next.md

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

docs/getting-started/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ See [Install Page Builder](install-pagebuilder.md)
2828
* [Step 3: Add components](../create-basic-content-type/step-3-add-components.md)
2929
* [Step 4: Add editor](../create-basic-content-type/step-4-add-form.md)
3030
* [Step 5: Add styles](../create-basic-content-type/step-5-add-styles.md)
31-
* [Step 6: Add frontend widget](../create-basic-content-type/step-6-add-frontend-widget.md)
31+
* [Step 6: Add icon](../create-basic-content-type/step-6-add-icon.md)
3232
* [What's next](../create-basic-content-type/whats-next.md)
3333

3434
### Configurations

0 commit comments

Comments
 (0)