-
Notifications
You must be signed in to change notification settings - Fork 25
Styleguide
Ryan Johnson edited this page Mar 6, 2019
·
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-tab-list>is named after thetablistARIA role.
- e.g.
- Avoid abbreviations
- e.g.,
<hx-foobar-control>is preferred over<hx-foobar-ctrl>
- e.g.,
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. |