A modern, responsive e-commerce website for electronic products and personal devices built with semantic HTML5, native CSS3, and vanilla JavaScript.
View Live Demo ยป
- Multi-page Navigation: Smooth client-side routing without page refreshes
- Responsive Design: Optimized for mobile, tablet, and desktop devices
- Product Catalog: Filterable product grid with detailed product pages
- Shopping Cart: Add/remove items with quantity management
- Contact Form: Functional contact form with validation
- Modern UI: Clean design with smooth animations and hover effects
- Semantic Elements: Uses proper HTML5 semantic tags for better accessibility and SEO
<header>,<nav>,<main>,<section>,<footer><article>for product cards- Proper heading hierarchy (h1-h4)
- Accessibility: ARIA labels, alt attributes, and semantic markup
- SEO Optimized: Meta tags, structured content, and semantic HTML
- CSS Custom Properties: Comprehensive design system with CSS variables
- Color palette with primary, secondary, and accent colors
- Typography scale with consistent font sizes
- Spacing system using 8px grid
- Border radius and shadow definitions
- Flexbox & Grid: Modern layout techniques
- CSS Grid for product layouts and responsive design
- Flexbox for component alignment and navigation
- Responsive Design: Mobile-first approach with breakpoints
- Tablet: 768px and below
- Mobile: 480px and below
- Animations: Smooth transitions and micro-interactions
- Hover effects on cards and buttons
- Page transition animations
- Loading states and feedback
- Client-side Routing: Hash-based routing system
- URL management with
window.location.hash - Dynamic page rendering without server requests
- URL management with
- State Management: Application state handling
- Shopping cart state persistence
- Current page and filter states
- DOM Manipulation: Dynamic content rendering
- Template literals for HTML generation
- Event delegation and handling
- Local Storage: Cart persistence across sessions
passionfruit-website/
โโโ index.html # Main HTML structure
โโโ style.css # All CSS styling and responsive design
โโโ main.js # JavaScript functionality and routing
โโโ package.json # Project configuration and dependencies
โโโ public/
โ โโโ passion-fruit-1.svg # Passionfuit logo asset
โโโ README.md # Project documentation
The HTML file serves as the foundation with a semantic structure:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags, title, and SEO optimization -->
</head>
<body>
<header class="header">
<!-- Navigation with brand and menu -->
</header>
<main id="app">
<!-- Dynamic content insertion point -->
</main>
<footer class="footer">
<!-- Site footer with links and contact info -->
</footer>
</body>
</html>Key Elements:
- Header: Contains navigation with logo and menu items
- Main: Dynamic content area where pages are rendered
- Footer: Static footer with company information and links
The CSS is organized using a systematic approach:
:root {
--primary-color: #1a202c;
--secondary-color: #f56500;
--accent-color: #38b2ac;
/* Typography, spacing, and component variables */
}- Base Styles: Reset, typography, and global styles
- Layout Components: Header, navigation, footer
- UI Components: Buttons, cards, forms, modals
- Page-Specific Styles: Homepage hero, product grids, cart
- Responsive Utilities: Media queries and responsive helpers
/* Mobile-first approach */
.product-grid {
display: grid;
grid-template-columns: 1fr; /* Mobile default */
}
@media (min-width: 768px) {
.product-grid {
grid-template-columns: repeat(2, 1fr); /* Tablet */
}
}
@media (min-width: 1024px) {
.product-grid {
grid-template-columns: repeat(3, 1fr); /* Desktop */
}
}The JavaScript is structured in a modular approach:
const products = [
// Product data with specifications and images
];
let cart = [];
let currentPage = 'home';function initializeRouter() {
window.addEventListener('hashchange', handleRoute);
window.addEventListener('load', handleRoute);
}
function handleRoute() {
const hash = window.location.hash.slice(1) || 'home';
const [page, params] = hash.split('?');
showPage(page, params);
}function showPage(page, params = '') {
const app = document.getElementById('app');
switch(page) {
case 'home':
pageContent = renderHomePage();
break;
case 'shop':
pageContent = renderShopPage(category);
break;
// Additional pages...
}
app.innerHTML = pageContent;
}function renderProductCard(product) {
return `
<div class="product-card" onclick="navigateTo('product', 'id=${product.id}')">
<!-- Product card HTML template -->
</div>
`;
}- Primary:
#1a202c(Deep Navy) - Headers, text, primary elements - Secondary:
#f56500(Vibrant Orange) - CTAs, highlights, brand accent - Accent:
#38b2ac(Teal) - Links, secondary actions - Grays: 50-900 scale for backgrounds, borders, and text hierarchy
- Font Family: Inter with system font fallbacks
- Scale: 0.75rem to 3rem with consistent line heights
- Weights: 400 (regular), 500 (medium), 600 (semibold), 700 (bold), 800 (extrabold)
- Base Unit: 8px grid system
- Scale: 4px, 8px, 12px, 16px, 20px, 24px, 32px, 40px, 48px, 64px, 80px
- Hash-based routing for single-page application behavior
- URL parameter parsing for product IDs and categories
- Browser history management
- Add/remove items with quantity management
- Local storage persistence
- Real-time cart count updates
- Cart summary with total calculation
- Category-based filtering
- Dynamic product grid updates
- URL state management for filters
- Placeholder images from Pexels
- Lazy loading for performance
- Responsive image sizing with
object-fit
- Contact form with validation
- Form submission simulation
- User feedback with notifications
- Node.js (for development server)
- Modern web browser
- Clone or download the project files
- Navigate to the project directory
- Install dependencies:
npm install
Start the development server:
npm run devThe website will be available at http://localhost:5173
Create a production build:
npm run build- Modern Browsers: Chrome 60+, Firefox 60+, Safari 12+, Edge 79+
- CSS Features: CSS Grid, Flexbox, Custom Properties
- JavaScript: ES6+ features (arrow functions, template literals, destructuring)
- Lazy Loading: Images load only when needed
- CSS Optimization: Efficient selectors and minimal reflows
- JavaScript: Event delegation and efficient DOM manipulation
- Responsive Images: Appropriate sizing for different devices
- User authentication and accounts
- Payment integration
- Product search functionality
- Wishlist feature
- Product reviews and ratings
- Advanced filtering (price range, brand, etc.)
- Progressive Web App (PWA) features
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
Built with โค๏ธ by Daniel Tadeo Evantiyasa - 1313624028 - ILKOM 2024