1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Move HotbarCell to separate component

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-05-06 11:49:57 +03:00
parent ca83695ca6
commit e2220f95de

View File

@ -0,0 +1,36 @@
import "./hotbar-menu.scss";
import "./hotbar.commands";
import React, { HTMLAttributes, ReactNode, useState } from "react";
import { cssNames } from "../../utils";
interface Props extends HTMLAttributes<HTMLDivElement> {
children?: ReactNode;
index: number;
innerRef?: React.LegacyRef<HTMLDivElement>;
}
export function HotbarCell({ innerRef, children, className, ...rest }: Props) {
const [animating, setAnimating] = useState(false);
const onAnimationEnd = () => { setAnimating(false); };
const onClick = () => {
if (className.includes("isDraggingOver")) {
return;
}
setAnimating(true);
};
return (
<div
className={cssNames("HotbarCell", { animating }, className)}
onAnimationEnd={onAnimationEnd}
onClick={onClick}
ref={innerRef}
{...rest}
>
{children}
</div>
);
}