| 
 | 1 | +# Theme Migration Guide  | 
 | 2 | + | 
 | 3 | +This update adds purple theming and dark/light mode support to the DirectAdmin Email Forwarder application.  | 
 | 4 | + | 
 | 5 | +## Changes Made  | 
 | 6 | + | 
 | 7 | +### 1. Color Scheme  | 
 | 8 | +- Changed primary color from blue to purple (`#6f42c1` for light mode, `#8e44ad` for dark mode)  | 
 | 9 | +- Updated navigation bar to use purple tones  | 
 | 10 | +- All buttons and links now use purple color scheme  | 
 | 11 | + | 
 | 12 | +### 2. Dark Mode Support  | 
 | 13 | +- Added CSS custom properties (variables) for theme support  | 
 | 14 | +- Created dark mode color palette  | 
 | 15 | +- Added theme toggle in Settings page  | 
 | 16 | + | 
 | 17 | +### 3. Database Changes  | 
 | 18 | +- Added `theme_preference` column to `user` table  | 
 | 19 | +- Stores user's preferred theme ('light' or 'dark')  | 
 | 20 | +- Defaults to 'light' theme for new and existing users  | 
 | 21 | + | 
 | 22 | +## Installation  | 
 | 23 | + | 
 | 24 | +### For Existing Installations  | 
 | 25 | + | 
 | 26 | +1. **Run the database migration script:**  | 
 | 27 | +   ```bash  | 
 | 28 | +   python add_theme_column.py  | 
 | 29 | +   ```  | 
 | 30 | +   This will add the `theme_preference` column to existing user accounts.  | 
 | 31 | + | 
 | 32 | +2. **Restart the application:**  | 
 | 33 | +   ```bash  | 
 | 34 | +   # If using Docker  | 
 | 35 | +   docker-compose restart  | 
 | 36 | +     | 
 | 37 | +   # If running directly  | 
 | 38 | +   # Stop and restart your Flask application  | 
 | 39 | +   ```  | 
 | 40 | + | 
 | 41 | +### For New Installations  | 
 | 42 | +No additional steps needed - the database will be created with the new column automatically.  | 
 | 43 | + | 
 | 44 | +## Features  | 
 | 45 | + | 
 | 46 | +### Theme Toggle  | 
 | 47 | +- Located in Settings page under "Appearance" section  | 
 | 48 | +- Toggle switch to change between light and dark themes  | 
 | 49 | +- Changes apply immediately  | 
 | 50 | +- Preference is saved to the database and persists across sessions  | 
 | 51 | + | 
 | 52 | +### Purple Color Scheme  | 
 | 53 | +- Navigation bar: Dark purple (`#4a2c70` for light mode, `#2d1b45` for dark mode)  | 
 | 54 | +- Primary buttons: Purple (`#6f42c1` for light mode, `#8e44ad` for dark mode)  | 
 | 55 | +- Links and accents: Purple theme throughout  | 
 | 56 | + | 
 | 57 | +### Dark Mode  | 
 | 58 | +- Dark background colors for better readability in low light  | 
 | 59 | +- Inverted text colors while maintaining good contrast  | 
 | 60 | +- All components support both light and dark themes  | 
 | 61 | + | 
 | 62 | +## Technical Details  | 
 | 63 | + | 
 | 64 | +### CSS Variables Used  | 
 | 65 | +```css  | 
 | 66 | +:root {  | 
 | 67 | +  --primary-color: #6f42c1;  | 
 | 68 | +  --primary-hover: #5a359a;  | 
 | 69 | +  --background-color: #f5f5f5;  | 
 | 70 | +  --surface-color: #ffffff;  | 
 | 71 | +  --text-color: #333333;  | 
 | 72 | +  --nav-background: #4a2c70;  | 
 | 73 | +  /* ... and more */  | 
 | 74 | +}  | 
 | 75 | + | 
 | 76 | +[data-theme="dark"] {  | 
 | 77 | +  --primary-color: #8e44ad;  | 
 | 78 | +  --background-color: #1a1a1a;  | 
 | 79 | +  --surface-color: #2d2d2d;  | 
 | 80 | +  --text-color: #e0e0e0;  | 
 | 81 | +  --nav-background: #2d1b45;  | 
 | 82 | +  /* ... and more */  | 
 | 83 | +}  | 
 | 84 | +```  | 
 | 85 | + | 
 | 86 | +### Database Schema Addition  | 
 | 87 | +```sql  | 
 | 88 | +ALTER TABLE user ADD COLUMN theme_preference VARCHAR(20) DEFAULT 'light';  | 
 | 89 | +```  | 
 | 90 | + | 
 | 91 | +### API Endpoints  | 
 | 92 | +- `GET /settings/api/da-config` - Returns user's theme preference along with other config  | 
 | 93 | +- `POST /settings/api/theme` - Updates user's theme preference  | 
 | 94 | + | 
 | 95 | +## Troubleshooting  | 
 | 96 | + | 
 | 97 | +### Migration Script Issues  | 
 | 98 | +If the migration script fails:  | 
 | 99 | +1. Check database connectivity  | 
 | 100 | +2. Ensure the application is not running during migration  | 
 | 101 | +3. Manually add the column:  | 
 | 102 | +   ```sql  | 
 | 103 | +   ALTER TABLE user ADD COLUMN theme_preference VARCHAR(20) DEFAULT 'light';  | 
 | 104 | +   UPDATE user SET theme_preference = 'light' WHERE theme_preference IS NULL;  | 
 | 105 | +   ```  | 
 | 106 | + | 
 | 107 | +### Theme Not Applying  | 
 | 108 | +1. Clear browser cache  | 
 | 109 | +2. Check if user is logged in  | 
 | 110 | +3. Verify the `data-theme` attribute is set on the `<body>` element  | 
 | 111 | +4. Check browser console for JavaScript errors  | 
 | 112 | + | 
 | 113 | +## Compatibility  | 
 | 114 | +- All modern browsers support CSS custom properties  | 
 | 115 | +- Falls back gracefully to light theme if JavaScript is disabled  | 
 | 116 | +- Mobile responsive design maintained for both themes  | 
0 commit comments