Updated channel editor & fixes

This commit is contained in:
Sacha Weatherstone
2021-10-27 07:17:50 +11:00
parent 8a9c0a268a
commit 672d23d19c
27 changed files with 530 additions and 249 deletions
+49
View File
@@ -0,0 +1,49 @@
import React from 'react';
import { FiCheck } from 'react-icons/fi';
type DefaulButtonProps = JSX.IntrinsicElements['button'];
export interface IconButtonProps extends DefaulButtonProps {
icon: React.ReactNode;
confirmAction?: () => void;
}
export const IconButton = ({
icon,
confirmAction,
...props
}: IconButtonProps): JSX.Element => {
const [hasConfirmed, setHasConfirmed] = React.useState(false);
const handleConfirm = (): void => {
if (confirmAction) {
if (hasConfirmed) {
void confirmAction();
}
setHasConfirmed(true);
setTimeout(() => {
setHasConfirmed(false);
}, 3000);
}
};
return (
<div
className="my-auto text-gray-500 dark:text-gray-400"
onClick={handleConfirm}
>
<button
type="button"
className={`p-2 rounded-md active:scale-95 ${
hasConfirmed
? 'bg-red-500'
: 'hover:bg-gray-200 dark:hover:bg-gray-600'
}`}
{...props}
>
{hasConfirmed ? <FiCheck /> : icon}
<span className="sr-only">Refresh</span>
</button>
</div>
);
};