This commit is contained in:
2026-03-08 14:27:16 +03:00
parent 66c151653e
commit 11b58b68c3
22 changed files with 4652 additions and 204 deletions

View File

@@ -0,0 +1,125 @@
# 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-6` for 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
1. **Better Readability**: Information is stacked vertically instead of cramped horizontally
2. **Touch-Friendly**: Larger buttons with proper spacing for mobile interaction
3. **No Horizontal Scroll**: All content fits within the viewport
4. **Prioritized Information**: Most important data is shown first
5. **Flexible Actions**: Buttons adapt to available space with `flex-wrap`
### Responsive Breakpoints Used
- `lg` (1024px): Used for customers, vehicles, and maintenance visits
- `md` (768px): Used for expenses and users
- `sm` (640px): Used for padding and text sizing adjustments
### Button Layout Strategy
- Used `flex-1` with `min-w-[80px]` or `min-w-[100px]` to ensure buttons are usable
- Applied `flex-wrap` to 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):
1. `/customers` - Customer list with cards
2. `/vehicles` - Vehicle list with cards
3. `/maintenance-visits` - Maintenance visit list with cards
4. `/expenses` - Expense list with cards
5. `/financial-reports` - All charts and breakdowns
6. `/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:
1. Swipe gestures for mobile card actions
2. Pull-to-refresh functionality
3. Infinite scroll for mobile lists
4. Collapsible sections in cards for very long content
5. Search/filter sticky headers on mobile