Skip to content

Commit 86d8d00

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

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

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

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Step 5: Add styles
22

3-
In this step, we will create CSS styles (using LESS) to define the Quote's base appearance as well as a selection of styles that end-users can use for their own customizations.
3+
In this step, we will create CSS styles (using LESS) to define the Quote's base appearance. We will also create several optional CSS classes that end-users can apply to our Quote.
44

55
## About styles
66

77
Page Builder provides two ways to style your content type's HTML templates using LESS:
88

9-
1. Using the standard `class` attribute to define the base look and feel of a content type.
9+
1. You can use the standard `class` attribute to define the base look and feel of a content type.
1010

11-
2. Using the `css` attribute to provide end-users with CSS customization options.
11+
2. You can use the `css` attribute to provide end-users with CSS customization options.
1212

1313
### `class` attribute
1414

1515
The `class` attribute is the typical, non-dynamic way to including static class styles in HTML templates. This means the `class` will always be present to define the "built-in" styles for your content type. Styles assigned to `class` cannot be changed by the content editor. In contrast, using the `css` attribute lets users add or change certain CSS class styles to customize your content type.
1616

1717
### `css` attribute
1818

19-
The `css` attribute is how Page Builder gives end-users the option to customize the appearance of your content type using CSS classes. As the developer, you determine the list of CSS classes you want to provide as options.
19+
The `css` attribute gives end-users the option to customize the appearance of your content type using CSS classes. As the developer, you determine the list of CSS classes you want to provide as options.
2020

2121
Unlike the `class` attribute, which always includes the defined classes, the `css` attribute provides a binding to a form field in your content type. End-users then use that form field to add the CSS class values that are in turn applied to the HTML template.
2222

@@ -30,13 +30,13 @@ The `pagebuilder_base_form` has a form field for the `css` attribute already bui
3030

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

33-
As the notice below the field indicates, the end-user can enter multiple classes, which are all then applied to the element in the template to which the `css` attribute is bound.
33+
As the field notice indicates, the end-user can enter more than one CSS class into the field. Page Builder then applies each class to the HTML element you bind with the `css` attribute.
3434

3535
## Add LESS files
3636

3737
The first thing we need to do is add our LESS files to appropriate places in our module, according to convention. The conventions for LESS files and how they work within Page Builder are identical to how they work in core Magento.
3838

39-
To ensure that Magento can merge your content type styles with all the other styles, you need to add a single LESS file named `_module.less` to both your `adminhtml/web/css/source` and `frontend/web/css/source` directories as shown here:
39+
To ensure that Magento can merge your content type styles with all the other styles, you must add a single LESS file named `_module.less` to both your `adminhtml/web/css/source` and `frontend/web/css/source` directories as shown here:
4040

4141
![Create config file](../images/step5-add-styles-module.png)
4242

@@ -50,23 +50,25 @@ Magento uses the `_module.less` file to merge your content type's styles into th
5050

5151
![Create config file](../images/step5-merged-styles.png)
5252

53-
For our Quote content type, add a file called `_import.less` for both the Admin and storefront in the following locations:
53+
For our Quote content type, add a file named `_import.less` to the `adminhtml/web/css/source/content-type/example-quote/` and `frontend/web/css/source/content-type/example-quote/` areas as shown here:
5454

5555
![Create config file](../images/step5-add-styles.png)
5656

5757
These files will contain the actual styles for our Quote control type.
5858

59-
You can name your LESS file (or files) whatever you want as long as you import them using the correct path and name in your `_module.less` files. For example, since we are only using one file (`_imports.less`) in each area, the contents of our `_module.less` files for both areas are identical:
59+
You can name your LESS file (or files) whatever you want, as long as you import them using the correct path and name in your `_module.less` files. For example, since we are only using one file name (`_imports.less`) for the files in each area, the contents of our `_module.less` files for both areas are identical:
6060

6161
```css
6262
@import "content-type/example-quote/_import.less";
6363
```
6464

65-
If you want to break your styles into multiple LESS files, feel free to do so as long as you import each file in your `_module.less` file to ensure they get merged with the rest of the styles in Magento.
65+
You can also break your styles into multiple LESS files. Import each file in your `_module.less` file so that they all get merged with the rest of the Magento styles.
66+
67+
If you break your styles into multiple LESS files, make sure you `@import` each file in your `_module.less` file.
6668

6769
## Add `class` styles
6870

69-
The `class` styles used for our Quote content type are provided in full here:
71+
The following sample shows the `class` styles used for our Quote content type:
7072

7173
```css
7274
// Content type's base styling
@@ -118,7 +120,7 @@ div {
118120
}
119121
```
120122

121-
These styles are referenced by the `class` attributes in both our Admin preview template (`preview.html`) and our master format storefront template (`master.html`) as shown here:
123+
The `class` attributes reference these styles in both our Admin preview template (`preview.html`) and our master format storefront template (`master.html`) as shown here:
122124

123125
```html
124126
<!--preview.html-->
@@ -139,13 +141,13 @@ These styles are referenced by the `class` attributes in both our Admin preview
139141
</div>
140142
```
141143

142-
This all standard stuff for styling the core appearance of our content type. So let's move on to adding the `css` bindings that gives our Quote some end-user customization options.
144+
Next, we will add the `css` bindings that give our Quote some end-user customization options.
143145

144146
## Add `css` style binding
145147

146-
Part of using the `css` binding option is deciding what CSS styling options you want to give end-users, unique from the styling and customization options provided by the `pagebuilder_base_form` and `pagebuilder_base_form_with_background_attributes` form fields (such as alignments, borders, paddings, margins, backgrounds, and more).
148+
Part of using the `css` binding option is deciding what CSS styling options you want to give end-users. The two base forms (`pagebuilder_base_form` and `pagebuilder_base_form_with_background_attributes`) already provide end-users with several styling options such as alignments, borders, paddings, margins, and various background properties. So you will want to use the `css` binding for other changes not covered by the base forms.
147149

148-
For our Quote content type, we will provide users with the option to change the color of the Quote's text using CSS styles. Let's start by defining our CSS styles in our `_import.less files`.
150+
For our Quote content type, we will use the `css` binding to enable users to change the color of the Quote's text using CSS styles. Let's start by defining our CSS styles in our `_import.less` files.
149151

150152
### Define CSS
151153

@@ -176,7 +178,7 @@ The simplest way to provide end-user CSS styling for our Quote is to add a text
176178
</field>
177179
```
178180

179-
However, this method puts the burden on the end-user to know what CSS class names they can enter. Even if we give them the name of the classes that can be used, there is the problem of entry errors like misspellings and a variety of other entry problems. So we will not use this method.
181+
However, this method puts the burden on the end-user to know and successfully enter the valid CSS class names. So we will not use this method.
180182

181183
Instead, we will use a simple `selector` to define and limit the color options available to end-users for coloring our Quote text, as shown here:
182184

@@ -222,15 +224,15 @@ Instead, we will use a simple `selector` to define and limit the color options a
222224
</field>
223225
```
224226

225-
When rendered in the form editor, the selector field provides users with a simple color list to select from which applies the class name as the selected value:
227+
When rendered in the form editor, the selector field provides users with a simple color list. Page Builder applies the class name as the selected value:
226228

227229
![Create config file](../images/step5-quote-color-selector.png)
228230

229231
Next we need to setup the bindings.
230232

231233
### Add configuration bindings
232234

233-
To create the binding between the CSS class values selected in our `quote_css` form field and our template, wee need to do two things:
235+
To create the binding between the CSS class values selected in our `quote_css` form field and our template, we need to do two things:
234236

235237
1. Add a `<css>` binding element to the `quote` element in our `example_quote.xml` configuration file.
236238
2. Add a `css` binding attribute to the `<blockquote>` element in our HTML template files (`preview.html` and `master.html`).
@@ -245,7 +247,7 @@ To create the binding between the CSS class values selected in our `quote_css` f
245247
</element>
246248
```
247249

248-
**Template file entry:** Now we want the value from our `quote_css` field to be applied to our Quote's HTML templates. As noted previously, this is done using the `css` attribute (`css="data.quote.css"`) to point to the `<css>` element in the config file, as shown here, applied to the `<blockquote>`:
250+
**Template file entry:** Now we want the value from our `quote_css` field to be applied to our Quote's HTML templates. As noted previously, this is done using the `css` attribute (`css="data.quote.css"`) to point to the `<css>` element in the config file. In the following example, the `css` attribute has been applied to the `<blockquote>` element:
249251

250252
```html
251253
<!--preview.html-->
@@ -258,7 +260,11 @@ To create the binding between the CSS class values selected in our `quote_css` f
258260

259261
## Quote styles
260262

261-
The `_import.less` file for the Admin preview template is provided here in full:
263+
The full file contents for both the `adminhtml` and `frontend` LESS files are provided below.
264+
265+
### LESS for `adminhtml`
266+
267+
The `_import.less` file content for the Admin preview template:
262268

263269
```css
264270
// Content type's base styling
@@ -317,7 +323,9 @@ div {
317323
.purple-quote { color: #990099; &:before { color: #990099; } }
318324
```
319325

320-
The `_import.less` file for the master format storefront template is provided here in full:
326+
### LESS for `frontend`
327+
328+
The `_import.less` file content for the master format storefront template:
321329

322330
```css
323331
// Content type's base styling

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Step 6: Add an icon
22

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:
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 like this:
44

55
![Create config file](../images/step6-quote-panel-icon.png)
66

77
## About icons
88

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.
9+
The icons used for Page Builder's built-in content types are actually font icons. Although you could create your own font icons and use those within your module, we recommend a using SVG or PNG images instead.
1010

11-
A summary of the steps for creating and adding this icon are listed here:
11+
To create and add an icon, you must:
1212

1313
1. Create your SVG or PNG icon.
1414
2. Create a CSS class for the icon.

0 commit comments

Comments
 (0)