B2YBooks Online Store - Client-side Implementation
This project is a client-side web application for B2YBooks, an online bookstore. The application allows users to browse books, search and filter book listings, add items to a shopping cart, and toggle between light/dark modes. The implementation uses core web technologies (HTML, CSS, and JavaScript) without any third-party frameworks or libraries.
Key features include:
- Dynamic loading of book data from JSON
- Search functionality with highlighting
- Category filtering with dropdown menu
- Shopping cart with quantity selection
- Dark mode toggle
- Responsive design
- Modern web browser (Chrome, Firefox, Edge, or Safari latest versions)
- Web server for local testing (optional but recommended to avoid CORS issues with JSON loading) e.g. Windows 10
- Download the project zip file
- Extract all files to a directory on your computer
- Ensure the folder structure maintains these relative paths:
images/
- contains all book cover thumbnailsdata/books.json
- contains the book datacss/styles.css
- contains all stylingjs/script.js
- contains all JavaScript functionality
Install Node.jshttp-server
in the command prompt. It will provide you url(s) to access your project from your browser, you usually can access your project from this address: "http://127.0.0.1:8080".
- Displays website header with title and dark mode toggle
- Shows search bar and category filter dropdown
- Presents book listings in a table format with:
- Thumbnail images
- Title, author, publication year
- Star ratings
- Price, publisher, and category
- Checkbox for selection
-
Dynamic Data Loading:
- Data is achieved from
data.json
, then is processed and rendered in the table
- Data is achieved from
-
Search Function:
- Search as user types
- Highlights matching rows without filtering
- Throw alert for no searching result
-
Filter Function:
- Dropdown with all available categories plus "All" option
- Throw alert for no books found in the category selected by user
-
Shopping Cart:
- Single book selection at a time
- Quantity input appears when adding to cart
- Cart total updates dynamically
- Reset function with confirmation dialog
- Keep cart quantity even if user refresh the page
-
Dark Mode:
- Toggle button at top of page
- Adjusts colors for background, text
- Empty search results
- No matches for selected filter category
- Invalid quantity inputs
- Cart reset confirmation
- HTML: Semantic structure with clear sections
- CSS: Organized with comments, using variables for colors
- JavaScript: Modular functions with clear responsibilities
- All code is properly commented for readability