-
Notifications
You must be signed in to change notification settings - Fork 25
Styleguide
Ryan Johnson edited this page May 2, 2018
·
7 revisions
Contribution standards and conventions
For consistency, use spaces instead of tabs for indentation.
| Preferred | Maximum |
|---|---|
| 80 chars | 120 chars |
- 80 characters or less is preferred
- 120 characters is absolute maximum line length
- URLs are the only exception to this rule
We must prefix all definitions with hx or Hx to avoid namespace conflicts and to ensure maximum compatibility with 3rd party libraries.
| Format | Example | |
|---|---|---|
| Element Name | hx-kebab-case |
hx-checkbox, hx-icon, etc. |
| Element Class | HXUpperCamelElement |
HXCheckboxElement, HXIconElement, etc. |
| CSS Class | .hxLowerCamelCase |
.hxSuccess, .hxSpan-12, .hxFilled, etc. |
Based on observation, consumers find it more natural to type <hx-parent-child> rather than <hx-parentchild>.
- Strive to name custom elements after applicable ARIA roles, if possible.
- e.g.
<hx-tablist>is named after thetablistARIA role.
- e.g.
- Be consistent across elements within the same component.
- For example:
-
<hx-tabcontent>and<hx-tabset>don't match any ARIA role -
<hx-tab>,<hx-tablist>, and<hx-tabpanel>matchtab,tablist, andtabpanelroles (respectively) - Staying consistent with the non-kebabcase format across Tab elements reduces cognitive overhead.
-
- For example:
Recommended:
<hx-parent>
<hx-parent-child>...</hx-parent-child>
</hx-parent>Avoid:
<hx-parent>
<hx-parentchild>...</hx-parentchild>
</hx-parent>All custom element assets should follow the Custom Element Class naming format, followed by the file extension.
| Format | Example | |
|---|---|---|
| Appearance | HXUpperCamelElement.less |
HXCheckboxElement.less, HXRevealElement.less, etc. |
| Behavior | HXUpperCamelElement.js |
HXCheckboxElement.js, HXRevealElement.js, etc. |
| Structure | HXUpperCamelElement.html |
HXCheckboxElement.html, HXRevealElement.html, etc. |