|
| 1 | +# DSpace Angular Code Conventions |
| 2 | + |
| 3 | +DSpace has established coding conventions or best practices that all contributions must follow in order |
| 4 | +to be accepted. |
| 5 | + |
| 6 | +These code conventions describe the best practices for design and implementation of DSpace code, helping ensure that all DSpace components have a consistent layout and follow the essential Web Content Accessibility Guidelines ([WCAG](https://www.w3.org/WAI/standards-guidelines/wcag/)). |
| 7 | +The best practices for formatting your code are defined in our separate [Code Style Guidelines](CODE_STYLE.md). |
| 8 | + |
| 9 | +For additional guidelines, see the wiki documentation for [User Interface Design Principles & Accessibility](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility). |
| 10 | + |
| 11 | +1. [Enforcement of Guidelines](#enforcement-of-guidelines) |
| 12 | +2. [Angular Guidelines](#angular-guidelines) |
| 13 | + 1. [Templates in Base Theme should only use default Bootstrap styling](#templates-in-base-theme-should-only-use-default-Bootstrap-styling) |
| 14 | + 2. [Required Bootstrap Components must use `ng-bootstrap` library](#required-bootstrap-components-must-use-ng-bootstrap-library) |
| 15 | + 3. [Document methods and classes using TypeDoc](#document-methods-and-classes-using-typedoc) |
| 16 | + 4. [Align with DSpace's User Interface Design Guidelines](#align-with-dspaces-user-interface-design-guidelines) |
| 17 | +3. [Accessibility Guidelines](#accessibility-guidelines) |
| 18 | + 1. [Align with WCAG (Web Content Accessibility Guidelines) AA criteria](#align-with-wcag-web-content-accessibility-guidelines-aa-criteria) |
| 19 | + 2. [Align with DSpace's User Interface Accessibility Guidelines](#align-with-dspaces-user-interface-accessibility-guidelines) |
| 20 | + |
| 21 | + |
| 22 | +## Enforcement of Guidelines |
| 23 | + |
| 24 | +Enforcement of these code conventions is handled in two ways: |
| 25 | +* Some guidelines are enforced strictly via static code tools such as ESLint. Where possible, we prefer to automate enforcement. |
| 26 | +* All guidelines are enforced during code review by the assigned reviewers. |
| 27 | + |
| 28 | +## Angular Guidelines |
| 29 | + |
| 30 | +### Templates in Base Theme should only use default Bootstrap styling |
| 31 | + |
| 32 | +All templates in the Base Theme ([/src/app](/src/app) directories) should only use default Bootstrap styling. Documentation at: https://getbootstrap.com/docs/4.6/getting-started/introduction/ |
| 33 | +* Exceptions may be made for accessibility purposes. For example, Bootstrap notes their [default color scheme does not always have sufficient color contrast](https://getbootstrap.com/docs/4.0/getting-started/accessibility/#color-contrast). |
| 34 | + |
| 35 | +### Required Bootstrap Components must use `ng-bootstrap` library |
| 36 | + |
| 37 | +When Bootstrap Components (accordion, dropdown, etc …) are required you MUST use the included `ng-bootstrap` library. Documentation at: https://ng-bootstrap.github.io/#/components/accordion/examples |
| 38 | + |
| 39 | +### Document methods and classes using TypeDoc |
| 40 | + |
| 41 | +Write [TypeDoc](https://typedoc.org/) comments for all new (or modified) public methods and classes, as well as for large or complex private methods. |
| 42 | + |
| 43 | +### Align with DSpace's User Interface Design Guidelines |
| 44 | + |
| 45 | +In order to ensure consistent layout and behavior on all pages, please refer to the [User Interface Design Guidelines](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility#UserInterfaceDesignPrinciples%26Accessibility-UserInterfaceDesignGuidelines). This documentation provides more details regarding User Interface layout/design and the elements (or components) used by the DSpace User Interface. |
| 46 | + |
| 47 | +## Accessibility Guidelines |
| 48 | + |
| 49 | +### Align with WCAG (Web Content Accessibility Guidelines) AA criteria |
| 50 | + |
| 51 | +The DSpace User Interface strives to align with [WCAG](https://www.w3.org/WAI/standards-guidelines/wcag/) AA criteria. Some AAA criteria may also be supported. For more information see [Accessibility documentation](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408944958/Accessibility). |
| 52 | + |
| 53 | +The use of the Bootstrap framework can help in achieving some WCAG goals such as ‘Visual Presentation’ (AAA), 'Parsing' (A), ‘Orientation’ (AA), ‘Reflow’ (AA) and ‘Text Spacing’ (AA). See the Bootstrap chapter ["Accessibility"](https://getbootstrap.com/docs/4.0/getting-started/accessibility/) for an explanation of WCAG and where to find additional information. |
| 54 | + |
| 55 | +### Align with DSpace's User Interface Accessibility Guidelines |
| 56 | + |
| 57 | +Refer to the [User Interface Accessibility Guidelines](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility#UserInterfaceDesignPrinciples%26Accessibility-UserInterfaceAccessibilityGuidelines) for more detailed recommendations regarding HTML structure, ARIA labelling and more. |
0 commit comments