claude-usage-widget/preload.js
Claude 3b5ef59c32 Release v1.4.2: Comprehensive UI customization and settings overhaul
Major Features:
- Added complete UI element visibility controls (show/hide any element independently)
- Added system tray icon with live usage percentage display
- Added customizable tray icon colors and update interval (10-300 seconds)
- Added application settings (start on boot, start minimized, close to tray)
- Added theme customization (backgrounds, text colors, borders, opacity controls)
- Added configurable update intervals for both UI and tray (10-300 seconds)
- Added static color mode option for progress bars
- Added dynamic window resizing based on visible elements

UI/UX Improvements:
- Improved settings organization with collapsible sections
- Consistent typography and spacing throughout settings panel
- Larger, bolder section headers for better visual hierarchy
- Removed donations button from settings
- Element visibility controls for both Current Session and Weekly Limit sections
- Master toggles for entire sections
- Independent toggles for labels, bars, percentages, circles, and time text

Bug Fixes:
- Fixed element centering and responsive layout
- Fixed timer container visibility handling when children are hidden
- Fixed slider overlap with text above
- Fixed window resizing to properly fit content
- Fixed manual resizing while maintaining centered content

Technical Changes:
- Changed UI update interval from 1-10 minutes to 10-300 seconds
- Standardized all settings to use .setting-group wrapper class
- Removed inline styles in favor of CSS classes
- Improved CSS organization with consistent spacing rules
- Added proper flexbox centering for responsive layouts
- Window constraints: 320-600px width, 96-180px height
- Resizable window with content-based auto-sizing

Documentation:
- Comprehensive README update with all v1.4.2 features
- Added screenshot placeholders for user documentation
- Detailed settings explanations
- Troubleshooting section expanded
- Version history updated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-24 19:37:35 -05:00

77 lines
3.3 KiB
JavaScript

const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
// Credentials management
getCredentials: () => ipcRenderer.invoke('get-credentials'),
saveCredentials: (credentials) => ipcRenderer.invoke('save-credentials', credentials),
deleteCredentials: () => ipcRenderer.invoke('delete-credentials'),
// Window controls
minimizeWindow: () => ipcRenderer.send('minimize-window'),
closeWindow: () => ipcRenderer.send('close-window'),
openLogin: () => ipcRenderer.send('open-login'),
openSettings: () => ipcRenderer.send('open-settings'),
// Window position
getWindowPosition: () => ipcRenderer.invoke('get-window-position'),
setWindowPosition: (position) => ipcRenderer.invoke('set-window-position', position),
setWindowHeight: (height) => ipcRenderer.send('set-window-height', height),
setWindowSize: (size) => ipcRenderer.send('set-window-size', size),
// Event listeners
onLoginSuccess: (callback) => {
ipcRenderer.on('login-success', (event, data) => callback(data));
},
onRefreshUsage: (callback) => {
ipcRenderer.on('refresh-usage', () => callback());
},
onSessionExpired: (callback) => {
ipcRenderer.on('session-expired', () => callback());
},
onSilentLoginStarted: (callback) => {
ipcRenderer.on('silent-login-started', () => callback());
},
onSilentLoginFailed: (callback) => {
ipcRenderer.on('silent-login-failed', () => callback());
},
// API
fetchUsageData: () => ipcRenderer.invoke('fetch-usage-data'),
openExternal: (url) => ipcRenderer.send('open-external', url),
// Color preferences
getColorPreferences: () => ipcRenderer.invoke('get-color-preferences'),
setColorPreferences: (preferences) => ipcRenderer.invoke('set-color-preferences', preferences),
notifyColorChange: (preferences) => ipcRenderer.invoke('notify-color-change', preferences),
onColorsChanged: (callback) => {
ipcRenderer.on('colors-changed', (event, preferences) => callback(preferences));
},
// Tray icon
sendUsageToMain: (data) => ipcRenderer.send('usage-data-update', data),
getTraySettings: () => ipcRenderer.invoke('get-tray-settings'),
setTraySettings: (settings) => ipcRenderer.send('set-tray-settings', settings),
getTrayUpdateInterval: () => ipcRenderer.invoke('get-tray-update-interval'),
setTrayUpdateInterval: (seconds) => ipcRenderer.send('set-tray-update-interval', seconds),
// Theme settings
getThemeSettings: () => ipcRenderer.invoke('get-theme-settings'),
setThemeSettings: (theme) => ipcRenderer.invoke('set-theme-settings', theme),
notifyThemeChange: (theme) => ipcRenderer.invoke('notify-theme-change', theme),
onThemeChanged: (callback) => {
ipcRenderer.on('theme-changed', (event, theme) => callback(theme));
},
// App settings
getAppSettings: () => ipcRenderer.invoke('get-app-settings'),
setAppSettings: (settings) => ipcRenderer.invoke('set-app-settings', settings),
// UI visibility settings
getUIVisibility: () => ipcRenderer.invoke('get-ui-visibility'),
setUIVisibility: (visibility) => ipcRenderer.invoke('set-ui-visibility', visibility),
onUIVisibilityChanged: (callback) => {
ipcRenderer.on('ui-visibility-changed', (event, visibility) => callback(visibility));
}
});