Code conventions

Strictly using the following conventions in your routes and components template give you the benefit to automatically extract all the html class names nicely formatted in index--auto.scss file with the commands:

Compact version of npx acanto extract-route myroute:

npx acanto ex-r myroute

Compact version of npx acanto extract-component MyComponent:

npx acanto ex-c MyComponent

Class names#


Core elements are very generic and of common use case. They are usually used repeatedly in the same page and across the same website. Their flexibility should allow to use them even without alteration across different projects. They should be in fact responsible of basic and common elements and UI like forms, images, buttons, typography, ecc. Their class naming follows this pattern:



Components are quite specific pieces of UI that are usually reused within the same project and can, but not necessarily need, to be reused accross different projects. They should be responsible of specific functionalities and should be configurable from outside enought to allow their reuse in the same project. Usual use cases for components are pieces of UI like the Header, the Footer, Cards, Sliders, ecc. Their class naming follows this pattern:



Routes contain code that is always scoped and outputted only to its specific template. So by default JS and SCSS code written here cannot interfere with other routes/pages. It's often handy to divide a page in sections and namespace them to organize the code. Sections of a page often look like .intro:, .details:, .products:, .featured:, etc. Their class naming follows this pattern:



Class names for state and behaviour#

Class names that denote states or behaviour are shorter and descriptive like:


Regarding the use of colon#

In SCSS the : needs to be escaped by a backslash as such Mycomponent\:, while in JS using the $ or $$ or escape functions to deal with DOM selectors the colon : is automatically escaped. Otherwise it needs to be escaped as such querySelector(".Mycomponent\\:").