Skip to content

Commit

Permalink
feat: sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
xpadev-net committed Oct 7, 2023
1 parent 2f0a89c commit 8cb3358
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 24 deletions.
4 changes: 3 additions & 1 deletion electron/lib/cookies/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ const getAvailableChromiumProfiles = async (
name: value.name,
path: profilePath,
});
} catch (_) {}
} catch (_) {
console.log(_);
}
}
return profiles;
} catch (_) {
Expand Down
4 changes: 1 addition & 3 deletions src/controller/controller.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
}
}
.queue {
width: 10vw;
min-width: 350px;
height: 100%;
border-left: solid 1px white;
width: 50px;
overflow: hidden;
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/controller/controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import Button from "@mui/material/Button";
import { useAtom, useAtomValue } from "jotai";
import { useState } from "react";
import Styles from "./controller.module.scss";
import { Sidebar } from "@/controller/sidebar/sidebar";
import { DownloadingOutlined } from "@mui/icons-material";

const Controller = () => {
const [tab, setTab] = useState<number>(0);
Expand Down Expand Up @@ -49,7 +51,15 @@ const Controller = () => {
</div>
</div>
<div className={Styles.queue}>
<QueueDisplay />
<Sidebar
pages={[
{
id: "queue",
icon: DownloadingOutlined,
component: QueueDisplay,
},
]}
/>
</div>
</div>
<Dialog open={!!message} onClose={() => setMessage(undefined)}>
Expand Down
7 changes: 4 additions & 3 deletions src/controller/queue/CommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import Styles from "./ConvertItem.module.scss";

type props = {
queue: CommentQueue;
className: string;
};
const CommentItem = ({ queue }: props) => {
const CommentItem = ({ queue, className }: props) => {
return useMemo(() => {
const outputName = queue.path.split(/\/|\\/g).reverse()[0];
const url = queue.target;
if (queue.status !== "processing") {
return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>id: {url}</p>
<p>output: {outputName}</p>
<p>status: {queue.status}</p>
Expand All @@ -21,7 +22,7 @@ const CommentItem = ({ queue }: props) => {
}

return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>id: {url}</p>
<p>path: {outputName}</p>
<p>status: processing</p>
Expand Down
1 change: 0 additions & 1 deletion src/controller/queue/ConvertItem.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.queue {
border-bottom: solid 1px white;
padding: 10px;
.progressWrapper {
display: flex;
Expand Down
7 changes: 4 additions & 3 deletions src/controller/queue/ConvertItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import Styles from "./ConvertItem.module.scss";

type props = {
queue: ConvertQueue;
className: string;
};
const ConvertItem = ({ queue }: props) => {
const ConvertItem = ({ queue, className }: props) => {
return useMemo(() => {
const movieName = queue.movie.path.split(/\/|\\/g).reverse()[0];
const outputName = queue.output.path.split(/\/|\\/g).reverse()[0];
if (queue.status !== "processing") {
return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>input: {movieName}</p>
<p>output: {outputName}</p>
<p>status: {queue.status}</p>
Expand All @@ -22,7 +23,7 @@ const ConvertItem = ({ queue }: props) => {
const pg = queue.progress;

return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>input: {movieName}</p>
<p>output: {outputName}</p>
<p>status: processing</p>
Expand Down
7 changes: 4 additions & 3 deletions src/controller/queue/MovieItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import Styles from "./ConvertItem.module.scss";

type props = {
queue: MovieQueue;
className: string;
};
const MovieItem = ({ queue }: props) => {
const MovieItem = ({ queue, className }: props) => {
return useMemo(() => {
const outputName = queue.path.split(/\/|\\/g).reverse()[0];
const url = queue.url.split(/\/|\\/g).reverse()[0];
if (queue.status !== "processing") {
return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>id: {url}</p>
<p>video: {queue.format.video.slice(8)}</p>
<p>audio: {queue.format.audio.slice(8)}</p>
Expand All @@ -23,7 +24,7 @@ const MovieItem = ({ queue }: props) => {
}

return (
<div className={Styles.queue}>
<div className={`${Styles.queue} ${className}`}>
<p>id: {url}</p>
<p>video: {queue.format.video.slice(8)}</p>
<p>audio: {queue.format.audio.slice(8)}</p>
Expand Down
5 changes: 5 additions & 0 deletions src/controller/queue/queue.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
height: 100vh;
overflow-y: scroll;
padding: 10px;
.item {
&:not(:last-child) {
border-bottom: solid 1px white;
}
}
}
24 changes: 15 additions & 9 deletions src/controller/queue/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ const QueueDisplay = () => {
}, []);
return (
<div className={Styles.wrapper}>
{queue.map((item) =>
item.type === "convert" ? (
<ConvertItem key={item.id} queue={item} />
) : item.type === "movie" ? (
<MovieItem key={item.id} queue={item} />
) : (
<CommentItem key={item.id} queue={item} />
),
)}
{queue.map((item) => {
if (item.type === "convert") {
return (
<ConvertItem className={Styles.item} key={item.id} queue={item} />
);
}
if (item.type === "movie") {
return (
<MovieItem className={Styles.item} key={item.id} queue={item} />
);
}
return (
<CommentItem className={Styles.item} key={item.id} queue={item} />
);
})}
</div>
);
};
Expand Down
40 changes: 40 additions & 0 deletions src/controller/sidebar/sidebar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.wrapper {
display: flex;
flex-direction: column;
width: 50px;
.icon {
width: 50px;
height: 50px;
display: grid;
place-items: center;
&.active {
background: #253b40;
}
}
.overlay {
position: fixed;
right: 50px;
top: 0;
min-width: 300px;
max-width: calc(100vw - 50px);
width: 30vw;
z-index: 1;
display: none;
&.visible {
display: block;
}
&:before {
content: "";
position: absolute;
top: 0;
right: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
z-index: -1;
}
.container {
background: #0f181a;
}
}
}
54 changes: 54 additions & 0 deletions src/controller/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FC, useState } from "react";
import Styles from "./sidebar.module.scss";

type props = {
pages: {
id: string;
icon: FC;
component: FC;
}[];
};

const Sidebar = ({ pages }: props) => {
const [openingPage, setOpeningPage] = useState<string | undefined>(undefined);
const togglePage = (i: string) => {
if (i === openingPage) {
setOpeningPage(undefined);
} else {
setOpeningPage(i);
}
};
return (
<div className={Styles.wrapper}>
{pages.map((page) => {
return (
<div key={page.id}>
<div
onClick={() => togglePage(page.id)}
className={`${Styles.icon} ${
openingPage === page.id && Styles.active
}`}
>
<page.icon />
</div>
<div
className={`${Styles.overlay} ${
openingPage === "queue" && Styles.visible
}`}
onClick={() => setOpeningPage(undefined)}
>
<div
className={Styles.container}
onClick={(e) => e.stopPropagation()}
>
<page.component />
</div>
</div>
</div>
);
})}
</div>
);
};

export { Sidebar };

0 comments on commit 8cb3358

Please sign in to comment.