Frontend library of components. This is our custom component library for the consent app consisting of UI components without any business logic. We make use storybook to render the components to help with rendering the component library.
Each component has it's own <component>.stories.tsx
file containing the corresponding storybook config
for the component with all the different states of the component included in it.
Whenever we write a new component, along with the .tsx
and the styles.scss
files we also need to include
<component>.stories.tsx
file to incorporate the storybook configuration.
This project needs the version of node
as specified in the respective package.json.
The app will run on port 6000 by default as configured in the start:dev
script.
yarn workspace lib-components start:dev
The app is tested primarily through unit tests using jest and
react-testing-library.
Unit testing React components uses shallow approach. This helps in testing components in a detached manner independent
of the ui-*
client apps.
Running unit tests in coverage mode:
yarn workspace lib-components test:unit
Coverage report is generated in coverage
folder.
Running unit tests in watch mode during development:
yarn workspace lib-components test:unit:watch
The app can be built using:
yarn workspace lib-components build
The build is generated in the build
folder.
body
:- can have a single
header
or multiple headers - can container a single
nav
or multiple navs - should contain a single
aside
if required - should contain a single
footer
- can have a single
section
:- can have multiple
articles
ordivs
etc. - should not contain another
section
inside - should not have a
footer
- can have multiple
article
:- should be a self-container unit. So we will no longer have sections inside articles
- if there are any header components inside an article, it should be enclosed within the
header
tag and not divs span etc. - it can contain multiple
divs
spans
etc.
<section class="section-1">
<article class="article-1">
<header>...</header>
<div class="article-1__header">...</div>
...
</article>
<article class="article-2">
<header>...</header>
<div class="article-2__header"></div>
...
</article>
<div class="div-1">
<span class="div-1__span">...</div>
...
</div>
<button class="section-1__button"></button> --> Note: same with spans, p, etc.
</section>
- The app is linted through custom
eslint
rules specified globally. Additionally, we make use ofprettier
andstylelint
to automate as much as possible.
yarn workspace lib-components lint