React Components
The Iquea frontend uses a component-based architecture with reusable, type-safe React components. All components are located insrc/components/.
Component Overview
The application includes three main reusable components:Navbar
Main navigation with search and cart
Footer
Site footer with newsletter signup
ProductoCard
Product display card
Navbar Component
TheNavbar component provides the main site navigation with authentication-aware features.
Component Code
src/components/Navbar.tsx
Key Features
- Authentication-aware - Shows different UI based on
isAuthenticatedstate - Search functionality - Toggleable search bar that navigates to product search
- React Icons - Uses Material Design and Feather icons
- Navigation - React Router
LinkanduseNavigatefor client-side routing
Usage Example
App.tsx
Footer Component
TheFooter provides site-wide footer with newsletter signup and social links.
Component Code
src/components/Footer.tsx
Key Features
- Newsletter form - Controlled form with email state
- Social links - Instagram, Facebook, Pinterest
- Contact info - Phone, email, address
- Dynamic copyright - Uses
new Date().getFullYear()
ProductoCard Component
Reusable product card component for displaying products in lists.Component Code
src/components/ProductoCard.tsx
Props Interface
Producto type includes:
producto_id- Unique product IDnombre- Product nameprecioCantidad- Price amountprecioMoneda- Currency (e.g., “EUR”)imagen_url- Product image URLes_destacado- Featured product flagstock- Available inventorycategoria- Category object withnombre
Usage Example
ProductList.tsx
Styling Approach
All components use pure CSS with a BEM-like naming convention:Benefits
- No framework overhead - Smaller bundle size
- Full control - Custom styling without constraints
- Scoped styles - Component-specific CSS files
- Maintainable - Clear naming convention
Component Best Practices
Type Safety
Type Safety
All components use TypeScript with explicit prop interfaces:
React Hooks
React Hooks
Components use modern React hooks:
useStatefor local stateuseNavigatefor programmatic navigationuseAuthanduseCartfor context consumption
Accessibility
Accessibility
Components include accessibility features:
aria-labelattributes on icon buttons- Semantic HTML (
<header>,<nav>,<footer>) loading="lazy"on images
Performance
Performance
- Lazy loading images with
loading="lazy" - Conditional rendering to minimize DOM nodes
- Functional components for better performance
Next Steps
View State Management
Learn how components consume authentication and cart state using React Context