Editable/dynamic template style system


 Hello everyone,

In this post we will see style system for editable template. Basically a template-author can select css style from available style on page/component once the css is present in the client library. developer write the css and keep it in client library now template-author can use the style as per their requirement. Template-author can decide and achieve any style from available styles they want to apply on page. Template-author and developer can define the behavior of the component or page.

Before proceeding please go though the editable template blog Editable template (rjaem.blogspot.com)

we have 2 types of style system.

Page level style system

Component level style system

Page level style system: this style will get apply on body tag of the page. for example, we add the any font color, font family or font size on page level style system it will get applied on the template body so it will apply on the all the fonts available on the page. We should use page level policy for background image or background color like css where we need to have a common css styling all over the page.

follow below steps apply Page policy on template

Go template Structure mode--> Page Information-->Page policy --> Styles tab--> Allowed Style : Enter the below details in this section.

we can have multiple styles under one page policy for that we have to give add allowed style in policy for the style we want to add.

Allowed Styles : Group name for styling, the same name will appear on page in Styles popup.
Styles: This Click Add --> 2 empty boxes will appear left box is for style name and right box is for css class. style name will appear on page under allowed style and css class has to be present in client library.
we can see the same in below screenshots.





Component level Style system: This style will get apply on the particular component where we have added the policy.
Note: Component need to have design dialog to get style system for it.
Follow below steps to apply component level Style system --> Go to template in structure mode--> go to layout container where you have allowed the component --> click on Policy icon of the component --> Styles tab --> Enter the same we do for page level style system.
Go to page -->you can see the brush icon on component -->On click of brush icon you see the style options what you have added from component policy.
we can select multiple style for component that we need to check Style can be combined checkbox while creating policies.
CSS is loading from client-base.css, I am adding the client library on template page policy.
style.css
.style-green-background{ background-color: #11a836; } .style-red-background{ background-color: #e02a3b; } .font-style-normal{ font-style: normal; } .font-style-italic{ font-style: italic; } .font-style-oblique{  font-style: oblique; } .text-decoration-underline{  text-decoration: underline; } .text-decoration-line-through{ text-decoration: line-through; } 
css.txt
style.css
KEEP EDUCATING YOURSELF!!!!

Comments

Popular posts from this blog

AEM in docker

Sling API vs JCR API

Creating or finding .M2 folder