4.6 KiB
4.6 KiB
Mobile Responsive Tables Fix
Overview
Fixed mobile responsiveness issues for all data tables and lists across the application. The tables were causing layout problems on mobile devices due to horizontal overflow and cramped content.
Solution Implemented
Implemented a dual-view approach:
- Desktop (lg and above): Traditional table layout with all columns visible
- Mobile (below lg): Card-based layout with stacked information for better readability
Files Modified
1. Customer List (app/components/customers/CustomerList.tsx)
- Added responsive breakpoint at
lg(1024px) - Desktop: Full table with all columns
- Mobile: Card layout showing:
- Customer name and contact info
- Address
- Vehicle and visit counts
- Action buttons (View, Edit, Delete) in a flex layout
2. Vehicle List (app/components/vehicles/VehicleList.tsx)
- Added responsive breakpoint at
lg(1024px) - Desktop: Full table with DataTable component
- Mobile: Card layout showing:
- Plate number and vehicle details
- Specifications (body type, fuel, transmission)
- Owner information
- Last visit date
- Action buttons with flex-wrap for better spacing
3. Maintenance Visit List (app/components/maintenance-visits/MaintenanceVisitList.tsx)
- Added responsive breakpoint at
lg(1024px) - Desktop: Full table with DataTable component
- Mobile: Card layout showing:
- Visit date and time
- Vehicle and customer information
- Maintenance jobs description
- Cost and kilometers in a grid
- Payment status badge
- Action buttons
4. Expenses Route (app/routes/expenses.tsx)
- Added responsive breakpoint at
md(768px) - Desktop: Full table with DataTable component
- Mobile: Card layout showing:
- Expense description and category
- Amount prominently displayed
- Expense date and creation date in a grid
- Edit button full-width
- Fixed TypeScript errors with proper type guards
5. Financial Reports Route (app/routes/financial-reports.tsx)
- Made all sections responsive with proper text sizing
- Income by maintenance type: Responsive text sizes (xs/sm on mobile, sm/base on desktop)
- Expense breakdown: Same responsive treatment
- Top customers: Added truncation and flex-shrink to prevent overflow
- Monthly performance: Responsive grid and text sizing
- All cards use
p-4 sm:p-6for adaptive padding
6. User List (app/components/users/UserList.tsx)
- Added responsive breakpoint at
md(768px) - Desktop: Full table with DataTable component
- Mobile: Card layout showing:
- User name, username, and email with truncation
- Auth level and status badges
- Creation date
- Action buttons with flex-wrap
Key Features
Mobile Card Layout Benefits
- Better Readability: Information is stacked vertically instead of cramped horizontally
- Touch-Friendly: Larger buttons with proper spacing for mobile interaction
- No Horizontal Scroll: All content fits within the viewport
- Prioritized Information: Most important data is shown first
- Flexible Actions: Buttons adapt to available space with
flex-wrap
Responsive Breakpoints Used
lg(1024px): Used for customers, vehicles, and maintenance visitsmd(768px): Used for expenses and userssm(640px): Used for padding and text sizing adjustments
Button Layout Strategy
- Used
flex-1withmin-w-[80px]ormin-w-[100px]to ensure buttons are usable - Applied
flex-wrapto allow buttons to wrap on very small screens - Full-width buttons where appropriate (single action scenarios)
Testing Recommendations
Test the following routes on mobile devices (or browser dev tools):
/customers- Customer list with cards/vehicles- Vehicle list with cards/maintenance-visits- Maintenance visit list with cards/expenses- Expense list with cards/financial-reports- All charts and breakdowns/users- User list with cards
Test Scenarios
- Portrait and landscape orientations
- Different screen sizes (320px, 375px, 414px, 768px)
- Touch interactions with buttons
- Long text content (names, descriptions)
- Empty states
- Pagination controls
Browser Compatibility
- All modern browsers supporting Tailwind CSS breakpoints
- iOS Safari 12+
- Chrome Mobile 80+
- Firefox Mobile 80+
Performance Notes
- No additional JavaScript required
- Pure CSS responsive design using Tailwind utilities
- Minimal impact on bundle size
- Server-side rendering compatible
Future Enhancements
Consider adding:
- Swipe gestures for mobile card actions
- Pull-to-refresh functionality
- Infinite scroll for mobile lists
- Collapsible sections in cards for very long content
- Search/filter sticky headers on mobile