This is a template for a React project with a basic setup for a development environment. It enforce a good practice for a React project by using several tools and libraries.
To get started with this project, you need to follow the steps below.
This react project uses bun as a package manager and vite as a build tool. You need to have bun installed on your machine. You can install it by following the instructions on the official website. You also need to have node.js installed on your machine. You can install it by following the instructions on the official website.
First you need to clone the repository on your machine. You can do this by running the following command in your terminal:
ssh:
git clone git@github.com:Junale/react-template.githttps:
git clone https://github.com/Junale/react-template.gitThen you need to install the dependencies by running the following command in the root of the project:
bun installTo run the project, you need to run the following command in the root of the project:
bun run devThis project uses ESLint and Prettier for linting and formatting the code. You can run the following command in the root of the project to lint and format the code:
bun run lintUsing vscode, you can install the ESLint and Prettier extensions to lint and format the code automatically.
If you want to contribute to this project, you can follow the steps below:
-
Create an issue on the repository to discuss/describe the changes you want to make.
-
Create a new branch following the pattern
feat/<issue-number>/<short-description>for new features orfix/<issue-number>/<short-description>for bug fixes. -
Make the changes you want to make.
-
Create a pull request to the
mainbranch. -
Wait for the review of the pull request.
-
After the review, the pull request will be merged.
This project uses a simple architecture to uptimize for easy testing and maintenance. The architecture is described below.
The project is divided into several folders. Each folder has a specific purpose. The folders are described below:
- .github/: Contains GitHub-specific configurations, including workflows for CI/CD.
- .storybook/: Configuration files for Storybook, a tool for developing UI components in isolation.
- public/: Static assets that are served directly, such as images and HTML files.
- src/: The main source code of the project, including components, logic, and styles.
- logic/: Contains business logic, types and higher-order components.
- ui/: UI components.
- test/: Contains test files and stories for components.
The components are divided into two categories: UI and Logic. This makes it easier to test the components and to maintain the project. This will allow you to test the logic of the components without having to test the UI and vice versa.
The UI components are the components that are responsible for the visual representation of the application. These components should not contain any logic. They should only receive props and render the UI based on these props.
The UI components uses TailwindCSS for styling. TailwindCSS is a utility-first CSS framework that allows you to build custom designs without having to write custom CSS. You can find more information about TailwindCSS on the official website.
The logic components are the components that are responsible for the business logic of the application. These components should not contain any UI. They should only contain the logic of the application. They consists of Higher-Order Components (HOC) which are functions that take a component and return a new component with additional logic. You can find more information about HOC on the official React documentation.
This project uses Storybook for testing the components. Storybook is a tool for developing UI components in isolation. It allows you to develop components without having to run the entire application. You can find more information about Storybook on the official website.
This tool can be run in two ways:
- Development mode: This mode allows you to develop the components in isolation. You can run this mode by running the following command in the root of the project:
bun run storybook- Automated tests: This mode allows you to run automated tests for the components. You can run this mode by running the following command in the root of the project:
bun run test-storybookThis project uses GitHub Actions for CI/CD. GitHub Actions is a tool that allows you to automate tasks in your GitHub repository. You can find more information about GitHub Actions on the official website.
The project has workflows for testing that are triggered when a pull request is created or when a push is made to the main branch. The workflows are defined in the .github/workflows folder.
This project is licensed under the MIT License - see the LICENSE file for details.