Overview
The UI module is responsible for rendering the review grid, managing the visual presentation of review cards, and coordinating UI updates across the application. It integrates with DataStore, Filters, Search, and Stats modules.Methods
init()
Initializes the UI module and all dependent modules.Returns a promise that resolves when UI is initialized
- Initializes DataStore (loads reviews)
- Renders initial review grid
- Initializes Filters module
- Initializes Stats module
- Initializes Search module
- Sets up real-time update listener
renderReviews()
Renders all review cards to the grid with current filters and search applied.- Shows loading spinner if
DataStore.isLoadingis true - Applies search query if active
- Applies restaurant filter if active
- Renders review cards
- Adds “Add New Review” card at the end
- Updates statistics
Review Card Structure
Each review card includes:Photo Section
- Full-width dish photo (h-48 object-cover)
- Average rating badge (top-right overlay)
- White backdrop-blur badge design
Content Section
- Restaurant name (bold heading)
- Dish name (gray subtitle)
- Reviewer names with icon
- Date with calendar icon
Interactions
- Click opens detail modal
- Hover shadow effect (card-hover class)
- Rounded corners (rounded-2xl)
Card HTML Structure
Add New Review Card
The “Add New Review” card appears at the end of the grid:Design
- Gradient background (purple to pink)
- Dashed border
- Centered plus icon and text
- Fixed height (h-80)
Interaction
- Click opens add modal (
Modal.toggleAddModal()) - Hover shadow effect
Loading State
WhenDataStore.isLoading is true:
Filter and Search Integration
Search Integration
Filter Integration
Reviewer Name Formatting
"Gian"- Only Gian reviewed"Yami"- Only Yami reviewed"Gian y Yami"- Both reviewed
Event Handlers
Card Click Event
Add Card Click Event
Dependencies
DataStore
Data management and review operations
Filters
Restaurant filtering functionality
Utils
Utility functions (calculateAverageRating, escapeHtml)
Modal
Modal display for review details and forms
Stats
Statistics display updates
Search
Search functionality integration
DOM Elements
Required HTML Elements
Styling Classes
Tailwind CSS Classes Used
Card Container
bg-white rounded-2xl shadow-lg hover:shadow-xl card-hover transition-all duration-300 overflow-hidden cursor-pointerImage Overlay
bg-white/90 backdrop-blur-sm rounded-full px-3 py-1Add Card
bg-gradient-to-br from-purple-100 to-pink-100 border-2 border-dashed border-purple-300Complete Usage Example
Performance Notes
- Review grid is completely re-rendered on each update
- Search and filter operations happen before rendering
- Stats are updated after rendering completes
- Loading state prevents rendering until data is ready
Source Code
Source:workspace/source/src/js/modules/ui.js:1