Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
This document summarizes MontageJS-specific naming conventions and recommendations for modules, components, and CSS classes. Please refer to these conventions when creating MontageJS packages or contributing to the MontageJS framework.
We chose these conventions for the following reasons:
- To reduce the effort to read and understand the markup structure of our source code.
- To increase code usability because you can double-click each part of the code to quickly select and edit it. (Try it:
- To avoid name collisions due to multiple selectors.
All module and package names are written in lowercase letters or numbers and delimited by dashes (for example, child-package).
User interface components are stored in the ui directory of your MontageJS project and identified by a .reel extension.
The following naming conventions apply for
- Component names are always spelled in lowercase letters.
- If an official W3C HTML element exists, the component's name matches the name of that element; for example,
button.reel) for a
- If an official HTML equivalent does not exist, assign a name that captures the function or meaning of the component; for example,
- Input elements follow a dash-delimited
"element-type"pattern; for example,
CSS class names follow a dash-delimited
org-Component-childElement pattern. For example, for the progress bar it would be:
More specifically, the following conventions apply:
All CSS classes are prefixed with montage + dash:
Component names follow the namespace identifier (
montage-) and always start with an uppercase letter; for example,
<button data-montage-id "button" class="montage-Button">
If a component name consists of more than one word, each new word also starts with an uppercase letter, a convention commonly referred to as upper camel case ("CamelCaps") formatting; for example,
Composite components (components with children) follow this convention:
If a component has a child element, the child's name is written in lowercase (to signal the distinction between parent and child) and follows the component’s name separated by a dash; for example,
montage-InputRange-thumb. Be sure to use the same name for children as the native pseudo (Shadow DOM) elements if known; for example: -webkit-progress-bar. Angelina Fabbro put together a nice reference list of pseudo element selectors used in WebKit.
If a child element consists of concatenated words, its name is written in lower camelCase; for example,
If a component has multiple levels of child elements, each child is separated from the other by a dash; for example,
Note: There is no limit as to how many levels of child elements can be used, but if the whole CSS class becomes too long, it might be a good idea to break it into subcomponents.
If a class name represents a state or a variation, a double-dash is used; for example, (states)