GabrielLuZz/rickAndMorie
A lightweight React app that consumes the Rick and Morty API and displays characters in a responsive card grid. Includes pagination via arrow icons, conditional card styling based on character status, and name truncation for long titles. Built with CSS Modules and React hooks for clean and modular UI logic.
Rick and Morty Characters Explorer
Português
Visão geral
Este projeto é uma aplicação front-end criada com Create React App (React 18), que busca personagens da Rick and Morty API e os apresenta em uma grade de cards. A navegação entre páginas é feita através de ícones de seta, e o card muda de cor conforme o status do personagem (vivo ou não).
Tecnologias
- React 18 (Create React App)
- Fetch API (requisições HTTP)
- CSS Modules para estilos por componente
- React Icons (ícones de navegação)
- Google Fonts (Nunito)
Funcionalidades
- Listagem de personagens da Rick and Morty API com paginação.
- Navegação entre páginas usando setas (anterior e próxima).
- Card de personagem com:
- Imagem
- Nome truncado quando maior que 12 caracteres
- Espécie
- Cores de fundo/título variando conforme o status (Alive vs outros)
Requisitos
- Node.js 14+ e npm
Instalação e execução
-
Instale as dependências:
npm install
-
Inicie o servidor de desenvolvimento:
npm start
Acesse http://localhost:3000 no navegador.
-
Build de produção:
npm run build
-
Testes:
npm test
Scripts disponíveis
npm start— inicia o ambiente de desenvolvimentonpm test— roda os testes em modo watchnpm run build— gera o build de produçãonpm run eject— expõe as configurações do Create React App (irreversível)
Estrutura de pastas
rickAndMorie/
├── public/
│ ├── index.html
│ └── ...
├── src/
│ ├── App.js
│ ├── App.css
│ ├── index.js
│ ├── index.css
│ ├── components/
│ │ ├── Characters/
│ │ │ ├── index.jsx
│ │ │ └── style.module.css
│ │ └── CharCard/
│ │ ├── index.jsx
│ │ └── style.module.css
│ └── ...
└── package.json
Como funciona (breve explicação técnica)
- O estado
currentPagecomeça emhttps://rickandmortyapi.com/api/character/?page=1. - Um
useEffectobservacurrentPagee fazfetchpara obterresults(lista de personagens) einfo(links de paginaçãoprev/next). - Os personagens são enviados para o componente
Characters, que renderiza uma lista deCharCards. CharCardaplica truncamento do nome (> 12 caracteres) e cores condicionais de acordo comstatus.- Ícones de seta (react-icons) chamam
previousPageenextPage, atualizandocurrentPagecominfo.preveinfo.nextquando disponíveis.
Possíveis melhorias
- Campo de busca por nome, filtros por status/espécie.
- Indicadores de carregamento e mensagens de erro amigáveis.
- Scroll infinito ou paginação mais visível.
- Testes unitários de componentes e acessibilidade.
- Melhoria de acessibilidade (texto alternativo descritivo nas imagens, foco visível nas setas, etc.).
Créditos
English
Overview
This is a React front-end (Create React App, React 18) that fetches characters from the Rick and Morty API and displays them in a grid of cards. Pagination is handled via arrow icons, and card colors reflect the character status (alive vs others).
Tech stack
- React 18 (Create React App)
- Fetch API for HTTP requests
- CSS Modules for component-scoped styling
- React Icons (navigation arrows)
- Google Fonts (Nunito)
Features
- Character listing from the Rick and Morty API with pagination.
- Navigate between pages using left/right arrows.
- Character card with:
- Image
- Name truncated when longer than 12 characters
- Species
- Background/title colors based on status (Alive vs others)
Requirements
- Node.js 14+ and npm
Setup and run
-
Install dependencies:
npm install
-
Start development server:
npm start
Open http://localhost:3000 in your browser.
-
Production build:
npm run build
-
Tests:
npm test
Available scripts
npm start— start development modenpm test— run tests in watch modenpm run build— create production buildnpm run eject— eject CRA config (irreversible)
Folder structure
rickAndMorie/
├── public/
│ ├── index.html
│ └── ...
├── src/
│ ├── App.js
│ ├── App.css
│ ├── index.js
│ ├── index.css
│ ├── components/
│ │ ├── Characters/
│ │ │ ├── index.jsx
│ │ │ └── style.module.css
│ │ └── CharCard/
│ │ ├── index.jsx
│ │ └── style.module.css
│ └── ...
└── package.json
How it works (short technical summary)
- The
currentPagestate starts athttps://rickandmortyapi.com/api/character/?page=1. - A
useEffectwatchescurrentPageand performs afetchto obtainresults(characters) andinfo(pagination linksprev/next). - Characters are passed to the
Characterscomponent, which renders a list ofCharCards. CharCardtruncates names longer than 12 characters and applies conditional colors according tostatus.- Arrow icons (react-icons) call
previousPageandnextPage, updatingcurrentPagewithinfo.prevandinfo.nextwhen available.
Future improvements
- Search by name and filters by status/species.
- Loading indicators and friendlier error messages.
- Infinite scroll or clearer pagination UI.
- Component unit tests and accessibility improvements.
- Better accessibility (descriptive image alt text, visible focus on arrows, etc.).