ADD sidebar and REFACTOR buttons

This commit is contained in:
2025-05-28 16:02:26 +02:00
parent 96574efcdc
commit 81bd7318bb
8 changed files with 88 additions and 24 deletions

View File

@@ -10,6 +10,7 @@ function App() {
<Router> <Router>
<Routes> <Routes>
<Route element={<MainLayout />}> <Route element={<MainLayout />}>
<Route path="/" element={<h1>Main Page</h1>} />
<Route path="/create" element={<ClipUpload />} /> <Route path="/create" element={<ClipUpload />} />
<Route path="/create/:id" element={<ClipEdit />} /> <Route path="/create/:id" element={<ClipEdit />} />
</Route> </Route>

View File

@@ -1,9 +1,22 @@
export default function Sidebar() { import { Link } from "react-router-dom";
import clsx from "clsx";
import MenuButton from "./buttons/MenuButton.tsx";
type props = {
className?: string
}
const Sidebar = ({className}: props) => {
return ( return (
<div> <div className={clsx("w-64 h-screen bg-white shadow-sm border-r px-4 py-6 flex flex-col gap-2", className)}>
<ul> <Link
<li>Create Clip</li> to="/create">
</ul> <MenuButton>
Create Clip
</MenuButton>
</Link>
</div> </div>
) );
} };
export default Sidebar;

View File

@@ -0,0 +1,19 @@
import { Menu, X} from 'lucide-react';
import MenuButton from "./buttons/MenuButton.tsx";
type props = {
sidebarToggled: boolean,
setSidebarToggled: Function
}
const Topbar = ({sidebarToggled, setSidebarToggled}: props) => {
return (
<div>
<MenuButton onClick={() => setSidebarToggled(!sidebarToggled)}>
{sidebarToggled ? <X size={24}/> : <Menu size={24}/>}
</MenuButton>
</div>
)
}
export default Topbar;

View File

@@ -0,0 +1,14 @@
import React from "react";
type Props = React.ButtonHTMLAttributes<HTMLButtonElement>;
const BlueButton: React.FC<Props> = ({ className = "", ...props }) => {
return (
<button
className={`bg-primary text-text p-2 rounded-lg hover:bg-primary-pressed transition-colors duration-100 h-10 ${className}`}
{...props}
/>
);
};
export default BlueButton;

View File

@@ -0,0 +1,14 @@
import React from "react";
type Props = React.ButtonHTMLAttributes<HTMLButtonElement>;
const MenuButton: React.FC<Props> = ({ className = "", ...props }) => {
return (
<button
className={`text-gray-800 text-base px-3 py-2 rounded-lg hover:bg-gray-100 hover:text-black transition-colors duration-200 ${className}`}
{...props}
/>
);
};
export default MenuButton;

View File

@@ -13,7 +13,7 @@
--color-text: oklch(0.17 0.01 270); /* Dark Slate (#111827) */ --color-text: oklch(0.17 0.01 270); /* Dark Slate (#111827) */
--color-background: oklch(0.98 0.005 250);/* Soft off-white (#F9FAFB) */ --color-background: oklch(0.98 0.005 250);/* Soft off-white (#F9FAFB) */
--color-primary-pressed: oklch(0.55 0.21 254 / 0.5); --color-primary-pressed: oklch(0.45 0.21 254);
/* Easing */ /* Easing */
--ease-fluid: cubic-bezier(0.3, 0, 0, 1); --ease-fluid: cubic-bezier(0.3, 0, 0, 1);

View File

@@ -1,14 +1,21 @@
// layout/MainLayout.jsx // layout/MainLayout.jsx
import Sidebar from '../components/Sidebar' import Sidebar from '../components/Sidebar'
import Topbar from '../components/Topbar'
import { Outlet } from 'react-router-dom'; import { Outlet } from 'react-router-dom';
import {useState} from "react";
const MainLayout = () => ( const MainLayout = () => {
<div className="flex"> const [sidebarToggled, setSidebarToggled] = useState(false);
<Sidebar />
<div className="flex-1 p-4"> return (
<Outlet /> {/* This renders the nested route content */} <div className="grid grid-cols-[1fr_5fr] min-h-screen">
<Sidebar className={`row-span-2 transition ${sidebarToggled ? 'hidden' : ''}`}/>
<Topbar sidebarToggled={sidebarToggled} setSidebarToggled={setSidebarToggled}/>
<div className="flex-1 p-4">
<Outlet/> {/* This renders the nested route content */}
</div>
</div> </div>
</div> )
); };
export default MainLayout; export default MainLayout;

View File

@@ -6,15 +6,14 @@ import ClipRangeSlider from "./../components/ClipRangeSlider";
import ClipConfig from "./../components/ClipConfig"; import ClipConfig from "./../components/ClipConfig";
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 BlueButton from "../components/buttons/BlueButton.tsx";
const ClipEdit = () => { const ClipEdit = () => {
const { id } = useParams(); const { id } = useParams();
const videoRef = useRef<HTMLVideoElement | null>(null); const videoRef = useRef<HTMLVideoElement | null>(null);
const videoUrl = `/api/v1/download/input/${id}` const videoUrl = `/api/v1/download/input/${id}`
const [metadata, setMetadata] = useState<VideoMetadata | null>(null); const [metadata, setMetadata] = useState<VideoMetadata | null>(null);
const [playbackValue, setPlaybackValue] = useState(0); const [playbackValue, setPlaybackValue] = useState(0);
const [outputMetadata, setOutputMetadata] = useState<VideoMetadata>({ const [outputMetadata, setOutputMetadata] = useState<VideoMetadata>({
// default values // default values
startPoint: 0, startPoint: 0,
@@ -24,7 +23,6 @@ const ClipEdit = () => {
fps: 30, fps: 30,
fileSize: 10000 fileSize: 10000
}); });
const [progress, setProgress] = useState(0); const [progress, setProgress] = useState(0);
const [downloadable, setDownloadable] = useState(false); const [downloadable, setDownloadable] = useState(false);
@@ -125,18 +123,16 @@ const ClipEdit = () => {
</div>} </div>}
<div className={"flex flex-col gap-2 w-4/5 m-auto"}> <div className={"flex flex-col gap-2 w-4/5 m-auto"}>
<button <BlueButton
className={"bg-primary text-text p-2 rounded-lg hover:bg-primary-pressed h-10"}
onClick={sendData}> onClick={sendData}>
Export Export
</button> </BlueButton>
{ downloadable ? { downloadable ?
(<button (<BlueButton
className={"bg-primary text-text p-2 rounded-lg hover:bg-primary-pressed h-10"}
onClick={() => handleDownload(id)}> onClick={() => handleDownload(id)}>
Download Download
</button>) </BlueButton>)
:( :(
<progress <progress
value={progress} value={progress}