Refine upload styles, date/query behavior
This commit is contained in:
parent
0f31433f72
commit
9faef7e1f2
@ -5,10 +5,10 @@ import { useRef, useState } from 'react';
|
|||||||
import { CopyExif } from '@/lib/CopyExif';
|
import { CopyExif } from '@/lib/CopyExif';
|
||||||
import exifr from 'exifr';
|
import exifr from 'exifr';
|
||||||
import { clsx } from 'clsx/lite';
|
import { clsx } from 'clsx/lite';
|
||||||
import Spinner from './Spinner';
|
|
||||||
import { ACCEPTED_PHOTO_FILE_TYPES } from '@/photo';
|
import { ACCEPTED_PHOTO_FILE_TYPES } from '@/photo';
|
||||||
import { FiUploadCloud } from 'react-icons/fi';
|
import { FiUploadCloud } from 'react-icons/fi';
|
||||||
import { MAX_IMAGE_SIZE } from '@/services/next-image';
|
import { MAX_IMAGE_SIZE } from '@/services/next-image';
|
||||||
|
import LoaderButton from './primitives/LoaderButton';
|
||||||
|
|
||||||
const INPUT_ID = 'file';
|
const INPUT_ID = 'file';
|
||||||
|
|
||||||
@ -36,7 +36,8 @@ export default function ImageInput({
|
|||||||
showUploadStatus?: boolean
|
showUploadStatus?: boolean
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}) {
|
}) {
|
||||||
const ref = useRef<HTMLCanvasElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||||
|
|
||||||
const [image, setImage] = useState<HTMLImageElement>();
|
const [image, setImage] = useState<HTMLImageElement>();
|
||||||
const [filesLength, setFilesLength] = useState(0);
|
const [filesLength, setFilesLength] = useState(0);
|
||||||
@ -57,26 +58,24 @@ export default function ImageInput({
|
|||||||
loading && 'pointer-events-none cursor-not-allowed',
|
loading && 'pointer-events-none cursor-not-allowed',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span
|
<LoaderButton
|
||||||
className={clsx(
|
type="button"
|
||||||
'button primary normal-case',
|
isLoading={loading}
|
||||||
loading && 'disabled'
|
className="primary"
|
||||||
)}
|
icon={<FiUploadCloud
|
||||||
|
size={17}
|
||||||
|
className="translate-y-[0.5px]"
|
||||||
|
/>}
|
||||||
aria-disabled={loading}
|
aria-disabled={loading}
|
||||||
|
onClick={() => inputRef.current?.click()}
|
||||||
|
hideTextOnMobile={false}
|
||||||
>
|
>
|
||||||
<span className="w-4 inline-flex items-center mr-1">
|
|
||||||
{loading
|
|
||||||
? <Spinner color="text" className="translate-y-[0.5px]" />
|
|
||||||
: <FiUploadCloud
|
|
||||||
size={17}
|
|
||||||
className="translate-y-[0.5px] shrink-0"
|
|
||||||
/>}
|
|
||||||
</span>
|
|
||||||
{loading
|
{loading
|
||||||
? 'Uploading'
|
? 'Uploading'
|
||||||
: 'Upload Photos'}
|
: 'Upload Photos'}
|
||||||
</span>
|
</LoaderButton>
|
||||||
<input
|
<input
|
||||||
|
ref={inputRef}
|
||||||
id={INPUT_ID}
|
id={INPUT_ID}
|
||||||
type="file"
|
type="file"
|
||||||
className="!hidden"
|
className="!hidden"
|
||||||
@ -100,7 +99,7 @@ export default function ImageInput({
|
|||||||
|
|
||||||
const isPng = callbackArgs.extension === 'png';
|
const isPng = callbackArgs.extension === 'png';
|
||||||
|
|
||||||
const canvas = ref.current;
|
const canvas = canvasRef.current;
|
||||||
|
|
||||||
// Specify wide gamut to avoid data loss while resizing
|
// Specify wide gamut to avoid data loss while resizing
|
||||||
const ctx = canvas?.getContext(
|
const ctx = canvas?.getContext(
|
||||||
@ -227,7 +226,7 @@ export default function ImageInput({
|
|||||||
</div>}
|
</div>}
|
||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
ref={ref}
|
ref={canvasRef}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'bg-gray-50 dark:bg-gray-900/50 rounded-md',
|
'bg-gray-50 dark:bg-gray-900/50 rounded-md',
|
||||||
'border border-gray-200 dark:border-gray-800',
|
'border border-gray-200 dark:border-gray-800',
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export default function LoaderButton(props: {
|
|||||||
<span className={clsx(
|
<span className={clsx(
|
||||||
'min-w-[1.25rem] h-4',
|
'min-w-[1.25rem] h-4',
|
||||||
styleAs === 'button' ? 'translate-y-[-0.5px]' : 'translate-y-[0.5px]',
|
styleAs === 'button' ? 'translate-y-[-0.5px]' : 'translate-y-[0.5px]',
|
||||||
'inline-flex justify-center',
|
'inline-flex justify-center shrink-0',
|
||||||
)}>
|
)}>
|
||||||
{isLoading
|
{isLoading
|
||||||
? <Spinner
|
? <Spinner
|
||||||
|
|||||||
@ -52,11 +52,11 @@ export const getWheresFromOptions = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (takenBefore) {
|
if (takenBefore) {
|
||||||
wheres.push(`taken_at > $${valuesIndex++}`);
|
wheres.push(`taken_at < $${valuesIndex++}`);
|
||||||
wheresValues.push(takenBefore.toISOString());
|
wheresValues.push(takenBefore.toISOString());
|
||||||
}
|
}
|
||||||
if (takenAfterInclusive) {
|
if (takenAfterInclusive) {
|
||||||
wheres.push(`taken_at <= $${valuesIndex++}`);
|
wheres.push(`taken_at >= $${valuesIndex++}`);
|
||||||
wheresValues.push(takenAfterInclusive.toISOString());
|
wheresValues.push(takenAfterInclusive.toISOString());
|
||||||
}
|
}
|
||||||
if (query) {
|
if (query) {
|
||||||
|
|||||||
@ -98,8 +98,8 @@
|
|||||||
@apply
|
@apply
|
||||||
text-invert
|
text-invert
|
||||||
bg-gray-900 dark:bg-gray-100
|
bg-gray-900 dark:bg-gray-100
|
||||||
disabled:text-gray-300 disabled:dark:text-gray-700
|
disabled:bg-main
|
||||||
disabled:bg-white disabled:dark:bg-black
|
disabled:text-gray-400 disabled:dark:text-gray-600
|
||||||
disabled:border-gray-200 disabled:dark:border-gray-700
|
disabled:border-gray-200 disabled:dark:border-gray-700
|
||||||
border-gray-900 dark:border-gray-100
|
border-gray-900 dark:border-gray-100
|
||||||
active:bg-gray-700 active:border-gray-700
|
active:bg-gray-700 active:border-gray-700
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user