Frontier Components comprises a range of components which implement common interaction patterns based on Angular and Material Design specification.
To assist in the creation of a Frontier Software Component following the Frontier Software standards we have created a CLI (@frontier/ftr-ngx-cli) that works with the Angular CLI to create a basic component that should be used as a starting point for any component you create.
The components are stored in a monorepo controlled by Lerna. By using the Frontier Software CLI your project will contain the necessary configuration to support the monorepo.
We automatically generate documentation using compodoc. The Frontier Software CLI will also prepare your component to work with the documentation generation process.
As much as possible Frontier Software components build on Angular Material components. Please consider theming or extending an existing Material component before you write your own component from scratch.
Pull the Frontier Software component library repo (ngx-components) from the web-component project. The repo can be found at this URL which can be used to pull the component library
https://frontiersoftware.visualstudio.com/web-component/_git/ngx-componentsBeing a monorepo housing a component library there is no develop branch since it does not follow gitflow conventions. Create your feature branches directly from the master branch. Pull requests push changes directly to master.
The components are published to a private NPM repository hosted by Azure DevOps. This repository also acts as a proxy to the normal NPM repository so it will contain NPM packages other than Frontier Software components. All Frontier Software components are in the @frontier Org. Filter by @frontier to see only Frontier Software components.
To set up the connection to the Frontier Software NPM repository go to the link below, select NPM and follow the instructions.
https://frontiersoftware.visualstudio.com/web-component/_packaging?_a=connect&feed=WebLibraryIt is recommended you install the Frontier Software component CLI globally. To do this run the following command
npm install -g @frontier/ftr-ngx-cli@latestYou can also run this command to update to the latest CLI when there is a new version.
NB. To use the CLI you must also set up the connection to the Frontier Software private NPM repository otherwise installing some dependent packages will fail.
In the folder where you pulled the Frontier Software component library repo, open a command prompt and change to the packages folder. All components that are under the control of Lerna exist in this folder.
In this folder type ngxc new {component name} where component name is the name of the component you want to create. You do not need to add the @frontier Org, this will be added automatically for you. So, as an example, to create a component called @frontier/my-component, you would simply type the following in the packages folder.
ngxc new my-componentThis will create a basic component, a demo application, and add some standard packages and tooling to your component project.
Once the creation script finishes your component will be in the folder @frontier-my-component. Change to this folder and run the npm start command. This will start the demo project that was created for your component. The following output will be displayed.
ftr-my-component works!All paths mentioned in this section are relative to the components folder. In the example above the components folder is packages/@frontier-my-component.
projects/ftr-{component name}/src/libIn this folder there will be a component and a service. This is where you will develop your component.
NB. The project name for the component is prefixed with
ftr-so if you originally createdmy-componentthe project will be namedftr-my-component.
projects/demo/srcThis folder contains a simple project that uses your new component. This project has 2 purposes.
An empty markdown file is created. Please put general documentation for the component in here.
projects/ftr-{component name}/src/lib/{component name}.component.md@angular/flex-layout@angular/cdk@angular/material@frontier/common-libWhen building your component please use @angular/flex-layout to position your html elements. A good tool for understanding flex-layout's use can be found here. The flex-layout documentation can be found here. Use flex-layout to also control responsiveness.
The @frontier/common-lib contains common fonts and styles used by most components. It would be unusual for a component not to use the common-lib.
Popular files contained in common-lib are:
ftr-base-styles.scss
Sets the Lato font and alternatives which is the Frontier Software standard font.
Sets box-sizing: border-box
ftr-theme.scss
Contains the global theme for the Material components.
ftr-colours.scss
Contains all the standard colour constants that should be used in the component or application.
ftr-utility.scss
Holds some very common stylesheet classes.
NB. The
ftr-all-iconsfont contained incommon-libis no longer updated. It is now in theftr-iconcomponent which is updated automatically when the UX team add new icons. Please use that instead. inftr-icon, as well as theftr-all-icons, you will find the icons as CSV and available as Material Icons.
NB. The
common-libalso contains some legacy styles and fonts such as theftr-all-iconfont andftr-button. Before using styles fromcommon-libplease consider if there is a Material equivalent that can be used.
It is recommended that you use the Angular CLI to add standard angular pieces (components, services, directives, pipes etc.) to your component. For example to add a new service to the @frontier/my-component component you should use the following command in the components root folder (@frontier-my-component).
ng generate service my-new-service --project ftr-my-componentNB. The project name for the component is prefixed with
ftr-so if you originally createdmy-componentthe project will be namedftr-my-component.
If you add something like a new component or service to your component and you want it to be accessible when your component is used make sure you update the public-api.ts with a reference to your new code.
projects/ftr-{component name}/src/public-api.tsWe strive for 100% coverage of components by unit tests. Some times it is not possible to cover all code but at least 80% should be covered.
When you run npm test a code coverage report will be generated. That report is placed in the coverage/ftr-{component name} folder. For example my-component's coverage report will be available by opening
@frontier-my-component/coverage/ftr-my-component/index.htmlNB. You do not have to create unit tests for the demo project. It is ignored during the testing process.
Ensure the following commands run successfully before you create your pull request. The CI process will run these and expect them to pass.
npm testnpm run lintnpm run buildnpm run build:demoThe demo build is run because it is built and uploaded to blob storage to be used as the live demo for the generated documentation.
In some cases it is desirable to disable the live demo in the documentation. For instance the web-api demo requires a connection to a real BRE which is not possible.
To disable the live demo
build:demo script from the package.json in the root folder of the component.example-url comment in the main component file of your component.Do the reverse of these instructions to re-enable the live demo.
The components use semantic versioning. The version number is taken from the package.json file in the component project folder. For example for the my-component project
@frontier-my-component/projects/ftr-my-component/package.jsonDuring normal development you should not need to manipulate the version number manually. The publish process will use the version in the package.json file as a seed value and update the third number to be the next available version. For Example
package.json file contains the version 2.3.12.3.142.3.15If you want to change the first or second number in the version you must do this manually. For example
package.json file contains the version 2.3.1 package.json version to 3.0.1 and include in your pull request 2.3.143.0.13.0.2, 3.0.3, 3.0.4 etc.It is encouraged that the developer should expand on the automatically generated documentation where possible. This is achieved by using JSDoc tags in the source code of the component.
Also by adding markdown to the ftr-{component name}-component.md file and the README.md file in the component project folder.
compodoc talking about JSDoc JSDoc tagsTo preview your generated documentation run
npm run generatedocsNB. You must install compodoc globally to generate the docs. Use
npm install -g @compodoc/compodoc