From 1a9086852aad17afba4574ad0c814bda4ea2f89d Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Sun, 3 May 2026 17:18:46 +0300 Subject: minor upload update --- src/app/upload/page.tsx | 2 ++ src/components/upload/Dropzone.tsx | 68 +++++++++++++++++++++++++---------- src/components/upload/SourceInput.tsx | 3 +- src/components/upload/Switches.tsx | 24 +++++++++++++ src/components/upload/TagsInput.tsx | 12 ++++--- src/components/upload/index.ts | 1 + 6 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 src/components/upload/Switches.tsx (limited to 'src') diff --git a/src/app/upload/page.tsx b/src/app/upload/page.tsx index d0f096f..a390199 100644 --- a/src/app/upload/page.tsx +++ b/src/app/upload/page.tsx @@ -6,6 +6,7 @@ import { FileDropzone, TagsInput, SourceInput, + Switches, } from '@/components/upload'; import { PUBLISH_DISCLAIMER } from '@/lib/consts'; @@ -28,6 +29,7 @@ export default function Upload() { + {PUBLISH_DISCLAIMER} diff --git a/src/components/upload/Dropzone.tsx b/src/components/upload/Dropzone.tsx index 6980f5c..5c882be 100644 --- a/src/components/upload/Dropzone.tsx +++ b/src/components/upload/Dropzone.tsx @@ -3,40 +3,70 @@ import Dropzone from 'react-dropzone'; import UploadIcon from '@icons/upload.svg'; import { Button } from '@/components/ui'; -import { useRef, useState } from 'react'; +import { useEffect, useState } from 'react'; export function FileDropzone() { - // const [files, setFiles] = useState([]); - const hiddenInputRef = useRef(null); + const [file, setFile] = useState(null); + const [preview, setPreview] = useState(null); + + useEffect(() => { + return () => { + if (preview) URL.revokeObjectURL(preview); + }; + }, [preview]); + return ( { - // setFiles((prev) => [...prev, ...acceptedFiles]); + multiple={false} + accept={{ 'image/*': [] }} + onDrop={(acceptedFiles) => { + const f = acceptedFiles[0]; + if (!f) return; + + const url = URL.createObjectURL(f); + + setFile(f); + setPreview(url); }} > {({ getRootProps, getInputProps }) => (
- -
- - - Выбери файлы на компьютере или перетащи сюда. JPG, - PNG до 20MB. - - - {hiddenInputRef.current?.files?.length ?? 0} - +
+ {!preview ? ( +
+ + + Выбери файлы на компьютере или перетащи + сюда. JPG, PNG до 20MB. + +
+ ) : ( + preview + )}
-
)} diff --git a/src/components/upload/SourceInput.tsx b/src/components/upload/SourceInput.tsx index fbc8f52..c93c4b6 100644 --- a/src/components/upload/SourceInput.tsx +++ b/src/components/upload/SourceInput.tsx @@ -1,6 +1,5 @@ 'use client'; import { Input } from '@/components/ui'; -import React from 'react'; export function SourceInput() { return ( @@ -8,7 +7,7 @@ export function SourceInput() { ИСТОЧНИК ) => { + onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); } diff --git a/src/components/upload/Switches.tsx b/src/components/upload/Switches.tsx new file mode 100644 index 0000000..76f9d6d --- /dev/null +++ b/src/components/upload/Switches.tsx @@ -0,0 +1,24 @@ +'use client'; + +import { Switch } from '@/components/ui/switch'; + +export function Switches() { + return ( +
+
+

NSFW

+ +
+ +
+

СГЕНЕРИРОВАНО ИИ

+ +
+ +
+

Я ЯВЛЯЮСЬ АВТОРОМ

+ +
+
+ ); +} diff --git a/src/components/upload/TagsInput.tsx b/src/components/upload/TagsInput.tsx index cdff794..4dcc595 100644 --- a/src/components/upload/TagsInput.tsx +++ b/src/components/upload/TagsInput.tsx @@ -1,11 +1,10 @@ 'use client'; import React, { useState } from 'react'; -import { Tag, WithContext } from 'react-tag-input'; import ExclamationIcon from '@icons/exclamation.svg'; import XIcon from '@icons/x.svg'; import { Button } from '@/components/ui'; - +import { WithContext, Tag, SEPARATORS } from 'react-tag-input'; export function TagsInput() { const [tags, setTags] = useState([]); @@ -30,8 +29,9 @@ export function TagsInput() { { setTags((prev) => { return [...prev, tag]; @@ -51,7 +51,7 @@ export function TagsInput() { inputFieldPosition="inline" classNames={{ tagInputField: 'outline-none text-light-violet', - tag: 'bg-violet px-2.5 py-1.25 flex gap-1.25 rounded-[10px] w-fit items-center', + tag: 'bg-violet px-2.5 py-0 h-[29px] flex gap-1.25 rounded-[10px] w-fit items-center', selected: 'flex gap-2.5 flex-wrap items-center', }} removeComponent={RemoveTag} @@ -75,7 +75,9 @@ class RemoveTag extends React.Component { document.getElementById('tags-input')?.focus(); }} > - +
+ +
); } diff --git a/src/components/upload/index.ts b/src/components/upload/index.ts index 022fe11..6eb84f6 100644 --- a/src/components/upload/index.ts +++ b/src/components/upload/index.ts @@ -2,3 +2,4 @@ export * from './UploadMenu'; export * from './Dropzone'; export * from './TagsInput'; export * from './SourceInput'; +export * from './Switches'; -- cgit v1.3-3-g829e