Centralized user settings system with custom theme creation capabilities.
hub/src/types/settings.ts - All settings types are centralized here
- UserSettings - Main settings container
- ThemeSettings - Theme configuration
- NotificationSettings - Notification preferences
- PrivacySettings - Privacy controls
- PlaybackSettings - Audio playback preferences
- CustomThemeDefinition - Custom theme structure- 10 Preset Themes: ember-noir, coastline-dawn, midnight-neon, royal-violet, sunlit-canvas, forest-echo, aurora-frost, crimson-stage, desert-mirage, retro-wave
- Custom Theme Creation: Users can create personalized themes
Navigate to /settings and click "Create Custom" to:
- Set theme name and description
- Choose light or dark mode
- Customize 7 palette colors:
- Background
- Surface
- Foreground
- Muted
- Border
- Primary
- Secondary
- Live color picker with hex input
- Save to user profile
- Delete custom theme
All settings are:
- Saved to
profiles.settingsJSON column in database - Automatically loaded on user login
- Applied across all components
PUT /api/user/profile/settings
Body: { settings: UserSettings }
GET /api/user/profile/me
Response includes: user.profile.settings
ALTER TABLE profiles ADD COLUMN settings JSON DEFAULT NULL;File: hubx/add_settings_column.sql
import { useAuth } from '@/contexts/AuthContext';
import { UserSettings } from '@/types/settings';
const { user } = useAuth();
const settings = user?.profile?.settings as UserSettings;
// Access specific settings
const theme = settings?.theme;
const notifications = settings?.notifications?.enabled;import { useTheme } from '@/contexts/ThemeContext';
const {
activeTheme, // Current active theme
themes, // All preset themes
customTheme, // User's custom theme
setTheme, // Switch theme
setCustomTheme // Save custom theme
} = useTheme();hubx/src/models/Profile.ts- Added settings columnhubx/src/routes/user/profile.ts- Added PUT /settings endpointhubx/migrations/20260123000000-add-settings-to-profile.js- Migration file
hub/src/types/settings.ts- NEW: Centralized settings typeshub/src/types/user.ts- Updated to use UserSettingshub/src/types/index.ts- Export settings types
hub/src/contexts/ThemeContext.tsx- Added custom theme supporthub/src/lib/profileApi.ts- Added updateSettings function
hub/src/app/settings/page.tsx- Complete settings page with custom theme editor
// Save notification settings
await updateSettings({
notifications: {
enabled: true,
email: true,
releaseUpdates: true
}
});
// Create custom theme
await updateSettings({
theme: 'custom',
customTheme: {
id: 'custom',
name: 'My Theme',
mode: 'dark',
palette: {
background: '#000000',
surface: '#111111',
// ... other colors
}
}
});- Type Safety: All settings have proper TypeScript types
- Centralized: Single source of truth for settings structure
- Extensible: Easy to add new settings categories
- Persistent: All settings saved to database
- User-Friendly: Visual theme editor with live preview
- Flexible: Supports both preset and custom themes