Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Component design:
How to use a component:
This guide will help developers understand what is a component and how to use them.
A component is a certain element or block of a design that can be edited and reused multiple times in a project. For example: tabs, buttons, accordion, etc.
Each component consists of:
A PHP template that has a dynamic html layout, depending on the variables passed to this template. It is located in the _core/stm-lms-templates/components folder.
SCSS style file, which after compilation is connected to the php template of the component and is in charge of the adaptive display of the component on the page. It is located in the _core/assets/scss/components folder.
In some cases - a Javascript file with code, which is connected to the php template of the component is necessary for the correct operation of the component. It is located in the _core/assets/es6/components folder.
The component template is added to the page through the STM_LMS_Templates::show_lms_template() template insertion function;
The path to the component is written into the function (by default, the path always starts from the folder with templates _core/stm-lms-templates) and the variables necessary for the correct operation and display of the component are passed in an array.
Important: This guide has PHP code and is meant for developers. We share the code as a friendly gesture but don't provide support for code customization or third-party development.
If necessary, you can also insert the component using any other function that allows you to insert PHP templates and pass variables into them.
Example of inserting a template into a page:
The necessary styles and javascript files are already connected in the component template.
Some components contain javascript and some do not. This is to avoid conflicts when the component is used differently on the page.
In case the component does not contain javascript, you will need to connect it to the page where you plan to use the component.
An example of a component template:
It's important to realize that a component is a template that is overused in different parts of the project. You cannot add situational styles such as indentation, alignment, etc. to the code of the component itself. It should always be inserted in "clean form", otherwise there will inevitably be conflicts when reusing it.
If you need to add such styles, make a wrapper for the component (a container in which the component will be inserted), and set all the necessary styles to that container.
Example:
To change the style or state of a component, you add a CSS modifier class. The modifier class is added in the component's template, based on the variables you pass in (for example: dark_mode: false, style: 'nav-sm').
Example:
But sometimes there are cases when you need to modify a component via javascript, like changing the style, or color theme of the component or highlighting the active tab when you click on it. For such cases, all the names of modifier classes are contained in the comments at the top of the component template. You can assign them via custom JavaScript code on the page.
Example:
Component design:
\How to use a component:
Component design:
How to use a component:
Component design (has different styles and sizes):
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component:
Component design:
How to use a component: