mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Saving more entity data to HotbarItem Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding generic MaterialTooltip component Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Move HotbarCell to separate component Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Abstract out HotbarEntityIcon from HotbarIcon Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Styling disabled hotbar items Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Migration for adding extra data to hotbar items Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Testing migration Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Some cleaning up Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Bump migration version Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Bump app version in package.json Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
33 lines
821 B
TypeScript
33 lines
821 B
TypeScript
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 = () => {
|
|
setAnimating(!className.includes("isDraggingOver"));
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={cssNames("HotbarCell", { animating }, className)}
|
|
onAnimationEnd={onAnimationEnd}
|
|
onClick={onClick}
|
|
ref={innerRef}
|
|
{...rest}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|