This project is a Course Assignment for JavaScript Frameworks at Noroff, focused on building a functional eCommerce store using React.
The primary goal of this project is to apply React skills to create a robust eCommerce platform. The application showcases several modern web development techniques and tools, enhancing both user experience and code quality.
- CSS framework: make use of
TailwindCSS for rapid styling and responsive design. - REST API: Implements basic API features, primarily focusing on GET requests for retrieving product data.
- React topics:
useState,useEffectandAbortController,custom hooks,Zustand(in the main branch), andUseContext(in the useContext branch). - State Management:
Zustandfor managing cart state, including cart persistence with local storage (main branch). - SEO: Enhanced with Helmet async package, allowing dynamic title and description for each page (main branch).
- Javascript Techniques:
- Array functions:
filter,mapandreduce. - Destructuring for cleaner code
- Development Tools: Uses
Viteas the bundler and follows a streamlined workflow with tools likeEslintandPrettier - Unit testing: leverage
vitestfor unit tests andbrowser/DOMtesting.
- Array functions:
- Responsive Design: Ensures optimal user experience across devices using media queries.
- Code Quality: Follows
DRY principles(Don’t Repeat Yourself) for structured and maintainable code. - Accessibility: Adheres to
WCAG(Web Content Accessibility Guidelines) standards for improved accessibility. - Developer Tools: Utilizes tools such as
VS code,DevTools,GitHub, andPostmanfor development and testing. - Code Validation: Employs validation tools to ensure standards compliance.
- Vertical Slices: The folder structure is organized by feature, each with its own components, styles, and tests for easier management.
- Mobile First: The design prioritizes mobile responsiveness, ensuring an optimal experience on mobile devices before adapting to larger screens.
While the course assignment required JavaScript, I chose to implement TypeScript to enhance code quality. This decision allows for strongly typed code and establishes clear API data contracts, improving maintainability and reducing potential errors.
- The application interacts with the Online Shop API. The API documentation can be found here.
- Online Shop API routes don't require authentication (for example: JWT token and an API Key).
- user can:
- view and search through Products
- Use an advanced look-ahead search feature for products.
- Check the number of items in the cart via the cart icon.
- view the individual product page.
- add a product to cart.
- View a detailed cart page with product listings and totals.
- Check for normal and discounted prices.
- Receive notification messages on the checkout page with navigation options.
- Contact the store via a contact form.
The web application code has been validated using the following tools:
To set up the development environment:
- Fill
.envfollowing.env.example: - Specify VITE_API_BASE_URL (the base API url
/online-shop/) - Ensure you have Node.js installed (> 20).
- Clone the repository.
- Run the following commands
> npm install
> npx vitest init browser
(> pnpm exec playwright install)
> npm run devIcons: React Icons