feat(task-management): enhance task timer synchronization and color handling
- Updated `CustomColordLabel` and `CustomNumberLabel` components to improve color handling by removing the alpha channel logic and implementing a dynamic text color based on background luminance. - Enhanced task management slice to preserve timer state when fetching tasks, ensuring active timers are maintained across updates. - Modified socket handlers to synchronize timer state between task slices, improving consistency in task time tracking. - Refactored `useTaskTimer` hook to streamline local and Redux state synchronization for timer management.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Tooltip } from 'antd';
|
||||
import { NumbersColorMap, ALPHA_CHANNEL } from '@/shared/constants';
|
||||
import { NumbersColorMap } from '@/shared/constants';
|
||||
|
||||
interface CustomNumberLabelProps {
|
||||
labelList: string[];
|
||||
@@ -12,24 +12,17 @@ interface CustomNumberLabelProps {
|
||||
const CustomNumberLabel = React.forwardRef<HTMLSpanElement, CustomNumberLabelProps>(
|
||||
({ labelList, namesString, isDarkMode = false, color }, ref) => {
|
||||
// Use provided color, or fall back to NumbersColorMap based on first digit
|
||||
const baseColor = color || (() => {
|
||||
const backgroundColor = color || (() => {
|
||||
const firstDigit = namesString.match(/\d/)?.[0] || '0';
|
||||
return NumbersColorMap[firstDigit] || NumbersColorMap['0'];
|
||||
})();
|
||||
|
||||
// Add alpha channel to the base color
|
||||
const backgroundColor = baseColor + ALPHA_CHANNEL;
|
||||
|
||||
return (
|
||||
<Tooltip title={labelList.join(', ')}>
|
||||
<span
|
||||
ref={ref}
|
||||
className="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium cursor-help"
|
||||
style={{
|
||||
backgroundColor,
|
||||
color: baseColor,
|
||||
border: `1px solid ${baseColor}`,
|
||||
}}
|
||||
style={{ backgroundColor, color: 'white' }}
|
||||
>
|
||||
{namesString}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user