Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ansurm/react-card-grid

Coding challenge solution for a Frontend Developer role, demonstrating various skills related to Frontend Development.
https://github.com/ansurm/react-card-grid

aws cicd css react s3 typescript

Last synced: 17 days ago
JSON representation

Coding challenge solution for a Frontend Developer role, demonstrating various skills related to Frontend Development.

Awesome Lists containing this project

README

        

# ๐ŸŽด React Card Grid Application

## Table of Contents

- [๐Ÿ“ Overview](#-overview)
- [๐Ÿ‘€ Preview](#-preview)
- [โœจ Features](#-features)
- [๐Ÿ› ๏ธ Technologies Used](#%EF%B8%8F-technologies-used)
- [๐Ÿ—๏ธ Project Structure](#%EF%B8%8F-project-structure)
- [๐Ÿš€ Getting Started](#-getting-started)
- [๐Ÿ“‹ Prerequisites](#-prerequisites)
- [โš™๏ธ Installation](#%EF%B8%8F-installation)
- [๐Ÿ–ฅ๏ธ Usage](#%EF%B8%8F-usage)
- [๐Ÿšข Deployment](#-deployment)
- [๐Ÿงช Testing](#-testing)
- [โ™ฟ Accessibility](#-accessibility)
- [๐Ÿš€ Next Steps](#-next-steps)
- [๐Ÿ“„ License](#-license)

## ๐Ÿ“ Overview

This React application displays a responsive grid of GIFs fetched from the Giphy API. It features a dynamic layout that adjusts based on screen size, modal functionality for detailed views, and adheres to accessibility best practices.

## ๐Ÿ‘€ Preview


React Card Grid Application Preview

## โœจ Features

- ๐Ÿ“ฑ Responsive grid layout of GIFs with dynamic rendering:
- Number of cards adjusts based on screen size
- Utilizes a resize event listener for real-time adaptation
- Renders 20 cards for smaller screens and 50 for larger screens (width >= 1920px)
- ๐Ÿ” Modal view for detailed GIF display
- โ™ฟ Accessibility features including:
- Keyboard navigation using Tab and Arrow keys for efficient browsing
- Screen reader compatibility for improved accessibility
- Visual focus indicators on GridCards to highlight the selected card during keyboard navigation and mouse hovers
- โณ Loading indicators during API fetches:
- SkeletonLoaders displayed in GridCards during initial API call and subsequent fetches
- SkeletonLoader shown in Modal while GIF details are being loaded
- Provides visual feedback to users, enhancing perceived performance and user experience

## ๐Ÿ› ๏ธ Technologies Used

- โš›๏ธ React (with Hooks)
- ๐Ÿ“˜ TypeScript
- โšก Vite
- ๐Ÿ’… styled-components
- ๐ŸŒ CSS Grid
- ๐Ÿ–ผ๏ธ Giphy API
- ๐Ÿงช Jest and React Testing Library

## ๐Ÿ—๏ธ Project Structure

The project follows a well-organized structure to enhance maintainability and scalability. Here's an overview of the main directories and files:

```
src/
โ”œโ”€โ”€ assets/
โ”‚ โ””โ”€โ”€ icons/
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ Card/
โ”‚ โ”œโ”€โ”€ ErrorIndicator/
โ”‚ โ”œโ”€โ”€ GifGrid/
โ”‚ โ”œโ”€โ”€ Loaders/
โ”‚ โ”œโ”€โ”€ Modal/
โ”‚ โ”œโ”€โ”€ NoResults/
โ”‚ โ””โ”€โ”€ Pagination/
โ”œโ”€โ”€ utils/
โ”‚ โ””โ”€โ”€ api/
โ”‚ โ””โ”€โ”€ constants.ts
โ”‚ โ””โ”€โ”€ types.ts
โ”œโ”€โ”€ App.tsx
โ”œโ”€โ”€ app.styles.ts
โ”œโ”€โ”€ index.css
โ”œโ”€โ”€ main.tsx
โ””โ”€โ”€ vite-env.d.ts
```

- ๐Ÿ“ `assets/`: Contains static assets like icons used in the application.
- ๐Ÿ“ `components/`: Houses all React components used in the app, each in its own directory with associated styles.
- ๐ŸŽด `Card/`: Renders individual GIF cards.
- โ— `ErrorIndicator/`: Displays error messages
- ๐Ÿ–ผ๏ธ `GifGrid/`: Manages the grid layout of GIF cards.
- โณ `Loaders/`: Contains loading indicators and skeleton loaders.
- ๐Ÿ” `Modal/`: Handles the detailed view of a selected GIF.
- ๐Ÿšซ `NoResults/`: Shows a message when no results are found.
- ๐Ÿ“„ `Pagination/`: Manages pagination controls.
- ๐Ÿ› ๏ธ `utils/`: Contains utility functions and API-related code.
- ๐ŸŒ `api/`: Handles API calls to the Giphy service.
- ๐Ÿ“„ `constants.ts`: Contains constants used throughout the application.
- ๐Ÿ“„ `types.ts`: Contains TypeScript types used throughout the application.
- ๐Ÿ“„ `App.tsx`: The main application component.
- ๐Ÿ’… `app.styles.ts`: Styled components for the main App component.
- ๐ŸŽจ `index.css`: Global CSS styles.
- ๐Ÿš€ `main.tsx`: Entry point of the application.
- ๐Ÿ“ `vite-env.d.ts`: TypeScript declarations for Vite.

This structure promotes a modular approach, making it easier to maintain and extend the application. Each component is self-contained with its own styles and logic, following best practices for React development.

## ๐Ÿš€ Getting Started

### ๐Ÿ“‹ Prerequisites

- ๐Ÿ“ฆ Node.js (version 12 or later)
- ๐Ÿ“ฆ npm or yarn

### โš™๏ธ Installation

1. Clone the repository:

```
git clone https://github.com/your-username/react-card-grid-app.git
```

2. Navigate to the project directory:

```
cd react-card-grid-app
```

3. Install dependencies:

```
npm install
```

or

```
yarn install
```

4. Copy the `.env.example` file to create a `.env` file in the root directory and add your Giphy API key:
```
VITE_GIPHY_API_KEY=your_api_key_here
VITE_GIPHY_API_URL=https://api.giphy.com/v1/gifs
```

## ๐Ÿ–ฅ๏ธ Usage

To start the development server:

```
npm start
```

or

```
yarn start
```

The application will be available at `http://localhost:5173`.

## ๐Ÿšข Deployment

This project is deployed on Amazon S3 and CloudFront through a CI/CD pipeline using GitHub Actions. The deployment process is automated and triggered on every push to the main branch. Here's an overview of the deployment steps:

1. The GitHub Actions workflow is defined in the `.github/workflows/deploy.yml` file.
2. When code is pushed to the main branch, the workflow is triggered.
3. The workflow runs on an Ubuntu latest environment.
4. It checks out the code, installs dependencies, and builds the project using npm.
5. During the build process, environment variables (including API keys) are securely injected from GitHub Secrets.
6. After a successful build, the AWS CLI is set up using a GitHub Action.
7. The built files are then synced to an Amazon S3 bucket using the `aws s3 sync` command.
8. Finally, a CloudFront invalidation is created to ensure the latest version of the site is served to users.

The entire process ensures that the latest version of the application is always available on the production environment.

๐ŸŒ Checkout the live site here: https://dj4xvloye0w0y.cloudfront.net/

## ๐Ÿงช Testing

In Progress โณ

Visit [Test Coverage PR](https://github.com/AnsurM/react-card-grid-challenge/pull/21) to check current progress.

## โ™ฟ Accessibility

The application is designed with accessibility in mind, following WAI-ARIA 1.3 patterns. Key features include:

- โŒจ๏ธ Keyboard navigation for all interactive elements using Tab and Arrow keys
- ๐Ÿ” Proper focus management
- ๐Ÿ”Š Screen reader compatibility for all components
- ๐Ÿ—๏ธ Semantic HTML structure for all components

## ๐Ÿš€ Next Steps

As we continue to improve and expand this application, here are some key areas we're focusing on:

### ๐Ÿ”ง Refactoring

- Move functions such as resize, keypress, and clickOutside listeners to reusable hooks to reduce code duplication and improve maintainability.

### ๐Ÿงช Testing

- Implement extensive unit, end-to-end, and integration tests as the app grows, ensuring robust functionality and easier maintenance.
- Visit [Test Coverage PR](https://github.com/AnsurM/react-card-grid-challenge/pull/21) to check current progress.

### ๐Ÿ”ฌ Enhancements

- Integrate feature flags for easier deployment and A/B testing.
- Implement observability tools like Sentry and SonarCloud for better monitoring and code quality analysis.

### ๐Ÿ–ผ๏ธ Performance Optimization

- Research and implement image caching strategies to improve load times and reduce bandwidth usage.

### ๐Ÿ”„ Continuous Integration

- Set up GitHub Actions to perform automated tests in the cloud and generate reports for test coverage.

### ๐Ÿ›ก๏ธ Error Handling

- Implement an Error Boundary to gracefully handle errors and prevent the entire application from crashing.

These next steps will help us improve the application's performance, maintainability, and overall user experience.

## ๐Ÿ“„ License

This project is licensed under the MIT License.