feat(ui): fix IAIDndImage button styles when upload disabled

This commit is contained in:
psychedelicious 2023-06-07 00:48:39 +10:00
parent 58fec84858
commit 8b6c0be259

View File

@ -12,11 +12,8 @@ import { ImageDTO } from 'services/api';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import IAIDropOverlay from './IAIDropOverlay'; import IAIDropOverlay from './IAIDropOverlay';
import { PostUploadAction, imageUploaded } from 'services/thunks/image'; import { PostUploadAction, imageUploaded } from 'services/thunks/image';
import { FileRejection, useDropzone } from 'react-dropzone'; import { useDropzone } from 'react-dropzone';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { useAppToaster } from 'app/components/Toaster';
import { useTranslation } from 'react-i18next';
import { reject } from 'lodash-es';
type IAIDndImageProps = { type IAIDndImageProps = {
image: ImageDTO | null | undefined; image: ImageDTO | null | undefined;
@ -111,6 +108,17 @@ const IAIDndImage = (props: IAIDndImageProps) => {
const setNodeRef = useCombinedRefs(setDroppableRef, setDraggableRef); const setNodeRef = useCombinedRefs(setDroppableRef, setDraggableRef);
const uploadButtonStyles = isUploadDisabled
? {}
: {
cursor: 'pointer',
bg: 'base.800',
_hover: {
bg: 'base.750',
color: 'base.300',
},
};
return ( return (
<Flex <Flex
sx={{ sx={{
@ -122,7 +130,7 @@ const IAIDndImage = (props: IAIDndImageProps) => {
minW: minSize, minW: minSize,
minH: minSize, minH: minSize,
userSelect: 'none', userSelect: 'none',
cursor: 'grab', cursor: isDragDisabled || !image ? 'auto' : 'grab',
}} }}
{...attributes} {...attributes}
{...listeners} {...listeners}
@ -180,20 +188,15 @@ const IAIDndImage = (props: IAIDndImageProps) => {
<Flex <Flex
sx={{ sx={{
minH: minSize, minH: minSize,
bg: 'base.800',
w: 'full', w: 'full',
h: 'full', h: 'full',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
borderRadius: 'base', borderRadius: 'base',
cursor: 'pointer',
transitionProperty: 'common', transitionProperty: 'common',
transitionDuration: '0.1s', transitionDuration: '0.1s',
color: 'base.500', color: 'base.500',
_hover: { ...uploadButtonStyles,
bg: 'base.750',
color: 'base.300',
},
}} }}
{...getRootProps()} {...getRootProps()}
> >