Files
donetick/src/utils/PlatformUtils.js
Mo Tarbin 953c62cc66 feat: Enhance UserPoints component with improved filtering and layout
- Updated UserPoints component to include a more user-friendly filter bar with enhanced styling.
- Added a summary section to display the current filter context.
- Refactored user selection and time period filtering logic for better clarity and performance.
- Improved the layout of points cards and history sections for better visual hierarchy.
- Integrated a bar chart for visual representation of points over time.
- Updated redeem points functionality with better user feedback.

feat: Add keyboard shortcuts in AddTaskModal for improved usability

- Implemented keyboard shortcuts for adding descriptions, subtasks, and due dates.
- Enhanced user experience by providing visual hints for keyboard shortcuts.
- Refactored task creation logic to streamline the process.

fix: Refactor ChoreActionMenu to handle mouse events and improve accessibility

- Added mouse enter and leave event handlers for better interaction feedback.
- Adjusted menu positioning for improved usability.

refactor: Update RichTextEditor to support focus handling from parent components

- Converted RichTextEditor to use forwardRef for better integration with parent components.
- Exposed focus and blur methods for external control.
- Improved image upload handling with better error management.

fix: Adjust SubTask component to handle Enter key behavior correctly

- Modified key event handling to prevent unintended task creation when holding meta or ctrl keys.
- Added autoFocus prop to new task input for better user experience.
2025-07-11 20:10:28 -04:00

64 lines
1.6 KiB
JavaScript

/**
* Utility functions for platform detection
*/
/**
* Detects if the current platform is macOS using modern APIs with fallback
* @returns {boolean} True if running on macOS, false otherwise
*/
export const isMacOS = () => {
// Modern approach using User-Agent Client Hints API
if (navigator.userAgentData) {
return navigator.userAgentData.platform === 'macOS'
}
// Fallback for older browsers
return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent)
}
/**
* Gets the appropriate keyboard shortcut text for the current platform
* @param {string} key - The key combination (e.g., 'F', 'K', 'S')
* @param {boolean} withCtrl - Whether to include Ctrl/Cmd modifier
* @param {boolean} withShift - Whether to include Shift modifier
* @returns {string} Platform-appropriate keyboard shortcut text
*/
export const getKeyboardShortcut = (
key,
withCtrl = true,
withShift = false,
) => {
let shortcut = ''
if (withCtrl) {
const modifier = isMacOS() ? '⌘' : 'Ctrl+'
shortcut += modifier
}
if (withShift) {
if (isMacOS()) {
shortcut += '⇧'
} else {
shortcut += 'Shift+'
}
}
shortcut += key
return shortcut
}
/**
* Gets common keyboard shortcuts for the current platform
*/
export const getCommonShortcuts = () => ({
search: getKeyboardShortcut('F'),
newTask: getKeyboardShortcut('K'),
selectAll: getKeyboardShortcut('A'),
multiSelect: getKeyboardShortcut('S'),
save: getKeyboardShortcut('S'),
copy: getKeyboardShortcut('C'),
paste: getKeyboardShortcut('V'),
undo: getKeyboardShortcut('Z'),
redo: getKeyboardShortcut('Z', true, true), // Ctrl/Cmd + Shift + Z
})