REFACTOR frontend

This commit is contained in:
2025-05-30 14:43:53 +02:00
parent fdaef02ef9
commit 1802659f43
8 changed files with 51 additions and 36 deletions

View File

@@ -0,0 +1,21 @@
import React from "react";
type props = {
children: React.ReactNode;
label: String;
}
const Selector = ({children, label}: props) => {
return (
<div className={"flex items-center gap-2"}>
<label
className={"w-full"}>
{ label }
</label>
<div className="w-px h-6 bg-gray-400 mx-3" />
{children}
</div>
)
}
export default Selector;

View File

@@ -1,4 +1,5 @@
import type { VideoMetadata } from "../utils/types.ts"; import type { VideoMetadata } from "../../utils/types.ts";
import Selector from "../Selector.tsx";
import clsx from "clsx"; import clsx from "clsx";
type prop = { type prop = {
@@ -33,11 +34,8 @@ export default function ClipConfig({setMetadata, className}: prop) {
return ( return (
<div className={clsx("flex flex-col gap-2 p-10 rounded-md", className)}> <div className={clsx("flex flex-col gap-2 p-10 rounded-md", className)}>
<h2 className={"text-3xl font-bold text-gray-800 mb-4"}>Export Settings</h2> <h2 className={"text-3xl font-bold text-gray-800 mb-4"}>Export Settings</h2>
<div className="flex items-center gap-2">
<label htmlFor="resolution" <Selector label={"Resolution"}>
className={"w-full"}
>Resolution: </label>
<div className="w-px h-6 bg-gray-400 mx-3" />
<select id="resolution" <select id="resolution"
name="resolution" name="resolution"
defaultValue="1280,720" defaultValue="1280,720"
@@ -50,13 +48,9 @@ export default function ClipConfig({setMetadata, className}: prop) {
<option value="854,480">480p</option> <option value="854,480">480p</option>
<option value="640,360">360p</option> <option value="640,360">360p</option>
</select> </select>
</div> </Selector>
<div className="flex items-center gap-2"> <Selector label={"FPS"}>
<label htmlFor="fps"
className={"w-full"}
>FPS: </label>
<div className="w-px h-6 bg-gray-400 mx-3" />
<select id="fps" <select id="fps"
name="fps" name="fps"
defaultValue="30" defaultValue="30"
@@ -66,20 +60,17 @@ export default function ClipConfig({setMetadata, className}: prop) {
<option value="30">30</option> <option value="30">30</option>
<option value="15">15</option> <option value="15">15</option>
</select> </select>
</div> </Selector>
<div className="flex items-center gap-2"> <Selector label={"File Size"}>
<label className={"w-full"}>
File Size (mb):
</label>
<div className="w-px h-6 bg-gray-400 mx-3" />
<input type="number" <input type="number"
min="1" min="1"
defaultValue="10" defaultValue="10"
onChange={updateFileSize} onChange={updateFileSize}
className={"border-black bg-gray-200 p-2 rounded-md w-full"} className={"border-black bg-gray-200 p-2 rounded-md w-full"}
/> />
</div> </Selector>
</div> </div>
) )
} }

View File

@@ -2,7 +2,7 @@ import RangeSlider from 'react-range-slider-input';
import 'react-range-slider-input/dist/style.css'; import 'react-range-slider-input/dist/style.css';
import {useRef} from "react"; import {useRef} from "react";
import clsx from 'clsx'; import clsx from 'clsx';
import type { VideoMetadata } from "../utils/types.ts"; import type { VideoMetadata } from "../../utils/types.ts";
type Props = { type Props = {
videoRef: HTMLVideoElement | null; videoRef: HTMLVideoElement | null;

View File

@@ -1,4 +1,5 @@
import BlueButton from "./buttons/BlueButton.tsx"; import BlueButton from "../buttons/BlueButton.tsx";
import React from "react";
type props = { type props = {
dataSend: React.MouseEventHandler<HTMLButtonElement>; dataSend: React.MouseEventHandler<HTMLButtonElement>;

View File

@@ -1,6 +1,6 @@
import {useEffect} from "react"; import {useEffect} from "react";
import clsx from 'clsx'; import clsx from 'clsx';
import type { VideoMetadata } from "../utils/types.ts"; import type { VideoMetadata } from "../../utils/types.ts";
type Props = { type Props = {
videoRef: HTMLVideoElement | null; videoRef: HTMLVideoElement | null;

View File

@@ -1,7 +1,7 @@
import { useEffect, useState} from "react"; import { useEffect, useState} from "react";
import { Volume1, Volume2, VolumeX, Play, Pause } from 'lucide-react'; import { Volume1, Volume2, VolumeX, Play, Pause } from 'lucide-react';
import clsx from 'clsx'; import clsx from 'clsx';
import type { VideoMetadata } from "../utils/types.ts"; import type { VideoMetadata } from "../../utils/types.ts";
type Props = { type Props = {

View File

@@ -1,13 +1,13 @@
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import Playbar from "./../components/Playbar"; import Playbar from "./../components/video/Playbar";
import PlaybackSlider from "./../components/PlaybackSlider"; import PlaybackSlider from "./../components/video/PlaybackSlider";
import ClipRangeSlider from "./../components/ClipRangeSlider"; import ClipRangeSlider from "./../components/video/ClipRangeSlider";
import ClipConfig from "./../components/ClipConfig"; import ClipConfig from "./../components/video/ClipConfig";
import ExportWidget from "../components/video/ExportWidget.tsx";
import {editFile, getMetadata, processFile, getProgress} from "../utils/endpoints" import {editFile, getMetadata, processFile, getProgress} from "../utils/endpoints"
import type { VideoMetadata } from "../utils/types.ts"; import type { VideoMetadata } from "../utils/types.ts";
import Box from "../components/Box.tsx"; import Box from "../components/Box.tsx";
import ExportWidget from "../components/ExportWidget.tsx";
const ClipEdit = () => { const ClipEdit = () => {
const { id } = useParams(); const { id } = useParams();
@@ -104,7 +104,7 @@ const ClipEdit = () => {
<Playbar <Playbar
video={videoRef.current} video={videoRef.current}
videoMetadata={metadata} videoMetadata={metadata}
className={"w-full accent-primary text-text"} className={"w-full accent-primary"}
/> />
<PlaybackSlider <PlaybackSlider
@@ -120,7 +120,7 @@ const ClipEdit = () => {
videoMetadata={metadata} videoMetadata={metadata}
setSliderValue={setPlaybackValue} setSliderValue={setPlaybackValue}
setMetadata={setOutputMetadata} setMetadata={setOutputMetadata}
className={"w-full mb-10 bg-primary"} className={"w-full mt-2 bg-primary"}
/> />
</Box>} </Box>}
@@ -129,7 +129,8 @@ const ClipEdit = () => {
dataSend={sendData} dataSend={sendData}
handleDownload={handleDownload} handleDownload={handleDownload}
downloadable={downloadable} downloadable={downloadable}
progress={progress} /> progress={progress}
/>
</Box> </Box>
</div> </div>
); );

View File

@@ -2,6 +2,7 @@ import {useState} from "react";
import {useNavigate} from "react-router-dom"; import {useNavigate} from "react-router-dom";
import { uploadFile } from "../utils/endpoints" import { uploadFile } from "../utils/endpoints"
import BlueButton from "../components/buttons/BlueButton.tsx"; import BlueButton from "../components/buttons/BlueButton.tsx";
import Box from "../components/Box.tsx";
const clipUpload = () => { const clipUpload = () => {
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
@@ -19,7 +20,7 @@ const clipUpload = () => {
}); });
return ( return (
<div className={"flex flex-col justify-between gap-3"}> <Box className={"flex flex-col justify-between gap-3 p-5"}>
<input <input
type="file" type="file"
onChange={(e) => { onChange={(e) => {
@@ -30,14 +31,14 @@ const clipUpload = () => {
/> />
<BlueButton <BlueButton
onClick={press} onClick={press}>
>Upload</BlueButton> Upload
</BlueButton>
{noFileError && {noFileError &&
<label className={"text-center text-red-500"}>Please choose a file</label> <label className={"text-center text-red-500"}>Please choose a file</label>
} }
</Box>
</div>
) )
}; };