bardius / nx-vite-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quality Gate Status Maintainability Rating Reliability Rating Security Rating Coverage

Nx Vite ReactJs Typescript Jest Stprybook Cypress

SonarCloud Snyk Dependabot GitHub Actions Conventional Commits

Nx monorepo for Vite & ReactJs

This is of a monorepo that contains library and application examples based on Nx, Typescript, ReactJs and Vite.

Data Table

Required NodeJs version

Ideally, you will have nvm. In that case you will get the required version automatically if you execute:

nvm use

Else wise please use NodeJs 20.11.0.

Installing the tooling

Setting up the project is pretty straight forward. You can execute:

npm run setup

This will install all dependencies and allow you to build the application.

Start the Data Table sample app

Starting the app locally can be done with a single command:

npm run start:data-table

or Nx command directly:

nx serve data-table

Open your browser and navigate to http://localhost:4200/.

Start Storybook

Starting the app locally can be done with a single command:

npm run storybook

or Nx command directly:

nx run common-ui:storybook

Open your browser and navigate to http://localhost:4400/.

Execute Unit tests

A single command will execute unit tests for all packages and report coverage:

npm run test

or Nx command directly:

nx run-many -t test --verbose

Execute E2E tests

A single command will execute Cypress E2E tests for data-table package:

npm run e2e

or to run in headed mode:

npm run e2e:headed

or Nx command directly:

nx run data-table-e2e:e2e

Repo structure

Monorepo source code is broken down into libraries (under libs folder) and applications (under apps folder). Each package has its source code under src folder.

There is a library package for common presentational components, called "common-ui" (libs/common-ui).

There is a package for the Data Table application, called "data-table" (apps/data-table).

Data Table application

This simple react application is using React router to serve a home page and handle errors or 404 urls. Salt Design System by JP. Morgan is being used to provide a consistent layout and branding. Ramda is used as lightweight utility library.

The home page contains a data table with sorting feature, preloaded sorting for all columns, and dummy data (FinancialInstrumentsTable).

The data table is reusing the presentational components from the "common-ui" package, extends/overrides for default row/cell renderers via configuration and uses headless component for multiple sorting feature with preloaded sortBy values.

Sorting feature

Sorting can be applied in all columns with default or custom sort comparator functions per column. Based on configuration it can be turned on/off, have custom comparator and pre-populate a sort by state.

Multiple sorting rules can apply simultaneously with a priority order.

Custom renderers

Table component allows extends/overrides for default row & cell renderers that are provided by the "common-ui" package.

Common UI library

This is a collection of presentational components required to compose a table within a simple page layout.

Salt Design System by JP. Morgan is being used to provide a consistent layout and branding. Additional styling has been done with Sass.

Storybook has been configured and a story for Table component has been created as sample.

DX tooling

Few tools have been configured and being used to improve the development experience in this project:

About

License:MIT License


Languages

Language:TypeScript 73.5%Language:SCSS 14.0%Language:CSS 7.5%Language:JavaScript 3.4%Language:Shell 1.1%Language:HTML 0.5%