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:devThe 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:unitCoverage report is generated in coverage folder.
Running unit tests in watch mode during development:
yarn workspace lib-components test:unit:watchThe app can be built using:
yarn workspace lib-components buildThe build is generated in the build folder.
body:- can have a single
headeror multiple headers - can container a single
navor multiple navs - should contain a single
asideif required - should contain a single
footer
- can have a single
section:- can have multiple
articlesordivsetc. - should not contain another
sectioninside - 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
headertag and not divs span etc. - it can contain multiple
divsspansetc.
<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
eslintrules specified globally. Additionally, we make use ofprettierandstylelintto automate as much as possible.
yarn workspace lib-components lint