perf: simplify kanban task card chrome
This commit is contained in:
parent
32b7bc3386
commit
e1e5b68e8a
1 changed files with 20 additions and 44 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { memo, useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
import { memo, useEffect, useMemo, useReducer, useState } from 'react';
|
||||||
|
|
||||||
import { useAppTranslation } from '@features/localization/renderer';
|
import { useAppTranslation } from '@features/localization/renderer';
|
||||||
import { OngoingIndicator } from '@renderer/components/common/OngoingIndicator';
|
import { OngoingIndicator } from '@renderer/components/common/OngoingIndicator';
|
||||||
|
|
@ -169,34 +169,14 @@ const TruncatedTitle = ({
|
||||||
}: {
|
}: {
|
||||||
text: string;
|
text: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
}): React.JSX.Element => {
|
}): React.JSX.Element => (
|
||||||
const ref = useRef<HTMLHeadingElement>(null);
|
<h5
|
||||||
const [isTruncated, setIsTruncated] = useState(false);
|
className={`line-clamp-2 text-xs font-medium text-[var(--color-text)] ${className ?? ''}`}
|
||||||
|
title={text}
|
||||||
const checkTruncation = useCallback(() => {
|
>
|
||||||
const el = ref.current;
|
{text}
|
||||||
if (el) {
|
</h5>
|
||||||
setIsTruncated(el.scrollHeight > el.clientHeight);
|
);
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip open={isTruncated ? undefined : false}>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<h5
|
|
||||||
ref={ref}
|
|
||||||
className={`line-clamp-2 text-xs font-medium text-[var(--color-text)] ${className ?? ''}`}
|
|
||||||
onMouseEnter={checkTruncation}
|
|
||||||
>
|
|
||||||
{text}
|
|
||||||
</h5>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent side="top" align="start">
|
|
||||||
{text}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const CancelTaskButton = ({
|
const CancelTaskButton = ({
|
||||||
taskId,
|
taskId,
|
||||||
|
|
@ -273,21 +253,17 @@ const TaskActionIconButton = ({
|
||||||
variant = 'outline',
|
variant = 'outline',
|
||||||
disabled = false,
|
disabled = false,
|
||||||
}: TaskActionIconButtonProps): React.JSX.Element => (
|
}: TaskActionIconButtonProps): React.JSX.Element => (
|
||||||
<Tooltip>
|
<Button
|
||||||
<TooltipTrigger asChild>
|
variant={variant}
|
||||||
<Button
|
size="icon"
|
||||||
variant={variant}
|
className={`size-6 shrink-0 rounded-full shadow-sm ${className}`}
|
||||||
size="icon"
|
aria-label={label}
|
||||||
className={`size-6 shrink-0 rounded-full shadow-sm ${className}`}
|
title={label}
|
||||||
aria-label={label}
|
onClick={onClick}
|
||||||
onClick={onClick}
|
disabled={disabled}
|
||||||
disabled={disabled}
|
>
|
||||||
>
|
{icon}
|
||||||
{icon}
|
</Button>
|
||||||
</Button>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent side="top">{label}</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const KanbanTaskCard = memo(
|
export const KanbanTaskCard = memo(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue