You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/create-basic-content-type/step-5-add-styles.md
+28-20Lines changed: 28 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
# Step 5: Add styles
2
2
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.
4
4
5
5
## About styles
6
6
7
7
Page Builder provides two ways to style your content type's HTML templates using LESS:
8
8
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.
10
10
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.
12
12
13
13
### `class` attribute
14
14
15
15
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.
16
16
17
17
### `css` attribute
18
18
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.
20
20
21
21
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.
22
22
@@ -30,13 +30,13 @@ The `pagebuilder_base_form` has a form field for the `css` attribute already bui
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.
34
34
35
35
## Add LESS files
36
36
37
37
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.
38
38
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:
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:
These files will contain the actual styles for our Quote control type.
58
58
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:
60
60
61
61
```css
62
62
@import"content-type/example-quote/_import.less";
63
63
```
64
64
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.
66
68
67
69
## Add `class` styles
68
70
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:
70
72
71
73
```css
72
74
// Content type'sbase styling
@@ -118,7 +120,7 @@ div {
118
120
}
119
121
```
120
122
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:
122
124
123
125
```html
124
126
<!--preview.html-->
@@ -139,13 +141,13 @@ These styles are referenced by the `class` attributes in both our Admin preview
139
141
</div>
140
142
```
141
143
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.
143
145
144
146
## Add `css` style binding
145
147
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.
147
149
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.
149
151
150
152
### Define CSS
151
153
@@ -176,7 +178,7 @@ The simplest way to provide end-user CSS styling for our Quote is to add a text
176
178
</field>
177
179
```
178
180
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 enterthe valid CSS class names. So we will not use this method.
180
182
181
183
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:
182
184
@@ -222,15 +224,15 @@ Instead, we will use a simple `selector` to define and limit the color options a
222
224
</field>
223
225
```
224
226
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:
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:
234
236
235
237
1. Add a `<css>` binding element to the `quote` element in our `example_quote.xml` configuration file.
236
238
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
245
247
</element>
246
248
```
247
249
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:
249
251
250
252
```html
251
253
<!--preview.html-->
@@ -258,7 +260,11 @@ To create the binding between the CSS class values selected in our `quote_css` f
258
260
259
261
## Quote styles
260
262
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:
Copy file name to clipboardExpand all lines: docs/create-basic-content-type/step-6-add-icon.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Step 6: Add an icon
2
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:
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:
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.
10
10
11
-
A summary of the steps for creating and adding this icon are listed here:
0 commit comments