@jisc/jisc-react-components v1.2.0-alpha
React UI components
A library of components based on React and Material UI that are re-usable.
This library is designed to help React developers create UI components that are accessible, usable, and conforms to Jisc branding guidelines.
Project contents
- The base project
jisc-react-componentsis the component library that can be installed by the end users (eg developers working a React website). - A playground project where developers of this project can test components.
- Storybook server
- Terraform intrastructure code in the
terraform/directory
Local set up for developers
Pre-requisites
Node v14.x
Yarn v1.22.x
Recommended developer set-up
IDE: Visual Studio Code
Plugins:
- Prettier: by installing this and enabling format on save, the code will automatically be formatted with the included Prettier config file. To enable auto format in VSCode:
- Install the Prettier plugin
- In your IDE, press CMD + SHIFT + P (you should get a pop-up with a greater than sign
>) - Type in "preferences" and select "Preferences: Open settings (JSON)"
- Ensure that the following fields are set:
"editor.defaultFormatter": "esbenp.prettier-vscode"
"[javascript]": {
"editor.formatOnSave": true
}"editor.formatOnSave": true
Bear in mind that Prettier works as well with some other editors. If the editor that you are using is not supported, please run yarn format.
Set up the component library jisc-react-components
- Clone the repository:
git clone git@github.com:JiscSD/jisc-react-components.git cd jisc-react-components- Ensure your Node version and yarn versions correspond to the pre-requisies above
yarn install
Additional commands
These should be run in the root directory of the jisc-react-components directory
yarn startbuilds the library and watches for updates to then re-buildyarn check-formatchecks whether the files are formatted correctlyyarn formatformats all files according to the prettier configyarn testruns lint, build, and unit tests including coverageyarn test:buildtests whether the project is able to build correctlyyarn test:ciruns tests designed for the continuous integration pipeline, including lint, build, prettier, unit tests, and test coverageyarn test:coverageruns the unit tests and coverage to check how much of the code is covered by unit testsyarn test:lintruns the lint testyarn test:unitruns the unit tests whilst watching for changesyarn storybookstarts the storybook serveryarn test:vregruns the visual regression testsyarn vreg-approveapproves the current status of visual regression tests
Set up the playground application
- From the root directory of
jisc-react-componentsthencd playground yarn installyarn start
Visual Regression
Prerequisites:
- Make sure you have the latest packages installed by running:
yarn installin the base folder. - Have docker daemon running how to install docker
The codebuild pipeline will run on every commit pushed to remote on AWS, but if you need to run it locally you can:
- Run
yarn test:vreg - Check the
.lokifolder to see if there were any differences (tests will fail if this happens).
Approving the diferences:
- You should have run the visual regression test as stated above first.
- If you're happy with the changes in the difference folder just run
yarn test:vreg-approvethat will update the reference files. - Run
yarn test:vregand see how all the visual regression tests pass now. - Commit the updated reference files to git.
For more information about Loki you can check their documentation page.
On the pull request you can see the visual regression pipeline on every commit as seen here jisc-ui-loki:

You can see the generated report at https://jisc-ui-loki.s3.eu-west-1.amazonaws.com/pr/PR_ID_NUMBER/report.html (replace PR_ID_NUMBER in the url)
Usage
Install the following packages:
// If using yarn
yarn add @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons @fortawesome/react-fontawesome @material-ui/core
// If using npm
npm install @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons @fortawesome/react-fontawesome @material-ui/coreBasic example:
import { JiscThemeProvider, PageHeader } from '@jisc/jisc-react-components';
function App() {
return (
<JiscThemeProvider>
<PageHeader title="Hello world" />
</JiscThemeProvider>
);
}
export default App;Developing components
Git Hooks
This project uses git hooks configured by using the npm package called husky algonside lint-staged. This means that every time you commit code to the repository some scripts/actions will be fired before letting you commit, if any of them fail, the commit will be discarded. These are:
- On Commit (
yarn test):- On the staged files (
yarn lint-staged):- Linting all the codebase with
ESLint - Formatting the codebase with
prettier
- Linting all the codebase with
- Build the library (
yarn test:build) - Audit the dependencies (
yarn audit) - Run all the tests + coverage (
yarn test:coverage)
- On the staged files (
- On Push: N/A
(on the right you can read the actual command that will automatically run, you can run them invidually before commiting your code)
Development guidelines
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago