fix: all cards in lists animate on label toggle at same time
This commit is contained in:
parent
8c610b11bf
commit
559fcbc0e4
@ -103,9 +103,9 @@ export const ListCardDetails = styled.div<{ complete: boolean }>`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const labelVariantExpandAnimation = keyframes`
|
const labelVariantExpandAnimation = keyframes`
|
||||||
0% {min-width: 40px; height: 8px;}
|
0% {min-width: 40px; width: 40px; height: 8px;}
|
||||||
50% {min-width: 56px; height: 8px;}
|
50% {min-width: 56px; width: auto; height: 8px;}
|
||||||
100% {min-width: 56px; height: 16px;}
|
100% {min-width: 56px; width: auto; height: 16px;}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const labelTextVariantExpandAnimation = keyframes`
|
const labelTextVariantExpandAnimation = keyframes`
|
||||||
@ -115,9 +115,9 @@ const labelTextVariantExpandAnimation = keyframes`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const labelVariantShrinkAnimation = keyframes`
|
const labelVariantShrinkAnimation = keyframes`
|
||||||
0% {min-width: 56px; height: 16px;}
|
0% {min-width: 56px; width: auto; height: 16px;}
|
||||||
50% {min-width: 56px; height: 8px;}
|
50% {min-width: 56px; width: auto; height: 8px;}
|
||||||
100% {min-width: 40px; height: 8px;}
|
100% {min-width: 40px; width: 40px; height: 8px;}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const labelTextVariantShrinkAnimation = keyframes`
|
const labelTextVariantShrinkAnimation = keyframes`
|
||||||
@ -137,6 +137,7 @@ export const ListCardLabel = styled.span<{ variant: 'small' | 'large' }>`
|
|||||||
? css`
|
? css`
|
||||||
height: 8px;
|
height: 8px;
|
||||||
min-width: 40px;
|
min-width: 40px;
|
||||||
|
width: 40px;
|
||||||
& ${ListCardLabelText} {
|
& ${ListCardLabelText} {
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
@ -146,13 +147,13 @@ export const ListCardLabel = styled.span<{ variant: 'small' | 'large' }>`
|
|||||||
: css`
|
: css`
|
||||||
height: 16px;
|
height: 16px;
|
||||||
min-width: 56px;
|
min-width: 56px;
|
||||||
|
width: auto;
|
||||||
`}
|
`}
|
||||||
|
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
max-width: 198px;
|
max-width: 198px;
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 4px 4px 0;
|
margin: 0 4px 4px 0;
|
||||||
width: auto;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -51,9 +51,12 @@ type Props = {
|
|||||||
onCardLabelClick?: () => void;
|
onCardLabelClick?: () => void;
|
||||||
onCardMemberClick?: OnCardMemberClick;
|
onCardMemberClick?: OnCardMemberClick;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
|
setToggleLabels?: (toggle: false) => void;
|
||||||
onEditCard?: (taskGroupID: string, taskID: string, cardName: string) => void;
|
onEditCard?: (taskGroupID: string, taskID: string, cardName: string) => void;
|
||||||
onCardTitleChange?: (name: string) => void;
|
onCardTitleChange?: (name: string) => void;
|
||||||
labelVariant?: CardLabelVariant;
|
labelVariant?: CardLabelVariant;
|
||||||
|
toggleLabels?: boolean;
|
||||||
|
toggleDirection?: 'shrink' | 'expand';
|
||||||
};
|
};
|
||||||
|
|
||||||
const Card = React.forwardRef(
|
const Card = React.forwardRef(
|
||||||
@ -64,6 +67,9 @@ const Card = React.forwardRef(
|
|||||||
taskID,
|
taskID,
|
||||||
taskGroupID,
|
taskGroupID,
|
||||||
complete,
|
complete,
|
||||||
|
toggleLabels = false,
|
||||||
|
toggleDirection = 'shrink',
|
||||||
|
setToggleLabels,
|
||||||
onClick,
|
onClick,
|
||||||
labels,
|
labels,
|
||||||
title,
|
title,
|
||||||
@ -82,10 +88,6 @@ const Card = React.forwardRef(
|
|||||||
$cardRef: any,
|
$cardRef: any,
|
||||||
) => {
|
) => {
|
||||||
const [currentCardTitle, setCardTitle] = useState(title);
|
const [currentCardTitle, setCardTitle] = useState(title);
|
||||||
const [toggleLabels, setToggleLabels] = useState(false);
|
|
||||||
const [toggleDirection, setToggleDirection] = useState<'shrink' | 'expand'>(
|
|
||||||
labelVariant === 'large' ? 'shrink' : 'expand',
|
|
||||||
);
|
|
||||||
const $editorRef: any = useRef();
|
const $editorRef: any = useRef();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -159,8 +161,6 @@ const Card = React.forwardRef(
|
|||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (onCardLabelClick) {
|
if (onCardLabelClick) {
|
||||||
setToggleLabels(true);
|
|
||||||
setToggleDirection(labelVariant === 'large' ? 'shrink' : 'expand');
|
|
||||||
onCardLabelClick();
|
onCardLabelClick();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -168,7 +168,11 @@ const Card = React.forwardRef(
|
|||||||
{labels &&
|
{labels &&
|
||||||
labels.map(label => (
|
labels.map(label => (
|
||||||
<ListCardLabel
|
<ListCardLabel
|
||||||
onAnimationEnd={() => setToggleLabels(false)}
|
onAnimationEnd={() => {
|
||||||
|
if (setToggleLabels) {
|
||||||
|
setToggleLabels(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
variant={labelVariant ?? 'large'}
|
variant={labelVariant ?? 'large'}
|
||||||
color={label.labelColor.colorHex}
|
color={label.labelColor.colorHex}
|
||||||
key={label.id}
|
key={label.id}
|
||||||
|
@ -123,6 +123,11 @@ const SimpleLists: React.FC<SimpleProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const [currentComposer, setCurrentComposer] = useState('');
|
const [currentComposer, setCurrentComposer] = useState('');
|
||||||
|
const [toggleLabels, setToggleLabels] = useState(false);
|
||||||
|
const [toggleDirection, setToggleDirection] = useState<'shrink' | 'expand'>(
|
||||||
|
cardLabelVariant === 'large' ? 'shrink' : 'expand',
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoardContainer>
|
<BoardContainer>
|
||||||
<BoardWrapper>
|
<BoardWrapper>
|
||||||
@ -162,12 +167,23 @@ const SimpleLists: React.FC<SimpleProps> = ({
|
|||||||
{taskProvided => {
|
{taskProvided => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
|
toggleDirection={toggleDirection}
|
||||||
|
toggleLabels={toggleLabels}
|
||||||
labelVariant={cardLabelVariant}
|
labelVariant={cardLabelVariant}
|
||||||
wrapperProps={{
|
wrapperProps={{
|
||||||
...taskProvided.draggableProps,
|
...taskProvided.draggableProps,
|
||||||
...taskProvided.dragHandleProps,
|
...taskProvided.dragHandleProps,
|
||||||
}}
|
}}
|
||||||
onCardLabelClick={onCardLabelClick}
|
setToggleLabels={setToggleLabels}
|
||||||
|
onCardLabelClick={() => {
|
||||||
|
setToggleLabels(true);
|
||||||
|
setToggleDirection(
|
||||||
|
cardLabelVariant === 'large' ? 'shrink' : 'expand',
|
||||||
|
);
|
||||||
|
if (onCardLabelClick) {
|
||||||
|
onCardLabelClick();
|
||||||
|
}
|
||||||
|
}}
|
||||||
ref={taskProvided.innerRef}
|
ref={taskProvided.innerRef}
|
||||||
taskID={task.id}
|
taskID={task.id}
|
||||||
complete={task.complete ?? false}
|
complete={task.complete ?? false}
|
||||||
|
Loading…
Reference in New Issue
Block a user