From 0d29d599376a02ac74941407c644918b5327f5e8 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 16:15:33 +0100 Subject: [PATCH 1/6] change oauth link --- README.md | 9 ++++++--- src/routes/dashboard/index.tsx | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dbab72d..ec869d0 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # stereo.cat frontend -written in typescript with qwik +written in typescript with qwik & bun -## running in dev env -``` +## development +https://bun.sh/docs/installation + +```bash git clone https://git.iwakura.rip/stereo.cat/frontend.git git submodule update --init --recursive bun install @@ -11,4 +13,5 @@ bun dev ``` ## disclaimer + All graphic assets belonging to stereo.cat may not be used in unofficial instances, forks or versions of our software. Please replace them if you are hosting our software yourself, they can be found in the ``public`` folder in this repository. More information (like the full license) can be found [here](https://git.iwakura.rip/stereo.cat/public) diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index 98a3864..c2572c9 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -6,13 +6,14 @@ import File from "~/components/dashboard/File"; import { SolarUploadLinear, SvgSpinnersBarsRotateFade } from "~/components/misc/Icons"; import { useNanostore$ } from "~/hooks/nanostores"; import { api } from "~/lib/api"; +import { OAUTH_LINK } from "~/lib/constants"; import { areFilesLoaded, dashboardFiles } from "~/lib/stores"; import { StereoFile } from "~/lib/types"; export const useAuthCheck = routeLoader$(({ cookie, redirect: r }) => { const jwt = cookie.get("jwt"); if (jwt) return {}; - throw r(302, "/"); + throw r(302, OAUTH_LINK); }); export default component$(() => { From f47a1b22262161de5f72a64c38983d3564add7b2 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 17:02:52 +0100 Subject: [PATCH 2/6] templating dashboard & add user route to api client --- src/components/dashboard/Controlbar.tsx | 88 ----------- src/components/dashboard/File.tsx | 199 ------------------------ src/components/dashboard/OSBar.tsx | 9 ++ src/components/dashboard/TitleBar.tsx | 9 ++ src/lib/api.ts | 1 + src/lib/stores.ts | 5 +- src/lib/types.ts | 8 + src/routes/dashboard/index.tsx | 57 +++---- src/routes/layout.tsx | 11 +- 9 files changed, 58 insertions(+), 329 deletions(-) delete mode 100644 src/components/dashboard/Controlbar.tsx delete mode 100644 src/components/dashboard/File.tsx create mode 100644 src/components/dashboard/OSBar.tsx create mode 100644 src/components/dashboard/TitleBar.tsx diff --git a/src/components/dashboard/Controlbar.tsx b/src/components/dashboard/Controlbar.tsx deleted file mode 100644 index 45310c1..0000000 --- a/src/components/dashboard/Controlbar.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { $, component$, noSerialize, NoSerialize, useSignal, useVisibleTask$ } from "@builder.io/qwik"; -import { useNanostore$ } from "~/hooks/nanostores"; -import { api } from "~/lib/api"; -import { areFilesLoaded, dashboardFiles } from "~/lib/stores"; -import { StereoFile } from "~/lib/types"; -import { SolarUploadLinear, SvgSpinnersBarsRotateFade } from "../misc/Icons"; -import StereoLogo from "../misc/StereoLogo"; - -export default component$(() => { - const loaded = useNanostore$(areFilesLoaded); - const files = useNanostore$(dashboardFiles); - const fileInputRef = useSignal(); - const uploadingFiles = useSignal | undefined>(); - const now = useSignal(new Date()); - - useVisibleTask$(() => { - const interval = setInterval(() => { - now.value = new Date(); - }, 500); - return () => clearInterval(interval); - }); - - const uploadFiles = $(async () => { - if (!uploadingFiles.value) { - console.error("No file(s) selected for upload."); - return; - } - - try { - const ufiles = uploadingFiles.value as File[]; - - for (const file of ufiles) { - const name = file.name.replace(/[^a-zA-Z0-9_.-]/g, "_"); - const f = new File([file], name, { type: file.type }); - - await api.upload(f); - } - - files.value = await api.list(); - } catch (error) { - console.error("Error uploading file:", error); - } - }) - return ( -
- { - uploadingFiles.value = noSerialize(Object.values((e.target as HTMLInputElement).files || {})); - await uploadFiles(); - }} - multiple - /> - -
- {/* TODO: replace this button with a modal with options like settings log out etc */} - - -

|

- - -
-

{now.value.toLocaleTimeString()}

-
- ) -}) \ No newline at end of file diff --git a/src/components/dashboard/File.tsx b/src/components/dashboard/File.tsx deleted file mode 100644 index 50c1e02..0000000 --- a/src/components/dashboard/File.tsx +++ /dev/null @@ -1,199 +0,0 @@ -import { $, component$, Signal, useSignal, useTask$ } from "@builder.io/qwik"; -import { useNanostore$ } from "~/hooks/nanostores"; -import { api } from "~/lib/api"; -import { dashboardFiles } from "~/lib/stores"; -import { StereoFile } from "~/lib/types"; -import { SolarClipboardAddBold, SolarDownloadMinimalisticBold, SolarTrashBin2Bold } from "../misc/Icons"; - -type FileProps = { - file: StereoFile; -} - -const formatSize = (bytes: number) => { - if (bytes < 1024) return `${bytes} B`; - if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; - if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; - return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`; -} - -export default component$(({ file }: FileProps) => { - const files = useNanostore$(dashboardFiles); - - const deleteFile = $(async (id: string) => { - if (!confirm("Are you sure you want to delete this file?")) return; - await api.delete(id); - files.value = await api.list(); - }); - - const addFileToClipboard = $(async () => { - const response = await api.file(file.Name); - const data = await response.blob(); - let mime = data.type || "application/octet-stream"; - let clip; - - if (navigator.clipboard && window.ClipboardItem) { - if (mime === "image/jpeg" || mime === "image/jpg") { - const img = document.createElement("img"); - img.src = URL.createObjectURL(data); - await new Promise((res) => (img.onload = res)); - const canvas = document.createElement("canvas"); - canvas.width = img.width; - canvas.height = img.height; - const ctx = canvas.getContext("2d"); - ctx?.drawImage(img, 0, 0); - const png = await new Promise((resolve) => - canvas.toBlob((b) => resolve(b!), "image/png") - ); - mime = "image/png"; - clip = new ClipboardItem({ [mime]: png }); - } else { - clip = new ClipboardItem({ [mime]: data }); - } - - try { - await navigator.clipboard.write([clip]); - alert("File added to clipboard successfully!"); - } catch (error) { - console.error("Failed to add file to clipboard:", error); - alert("Failed to add file to clipboard. Please try again."); - } - } else { - alert("Clipboard API not supported in this browser."); - } - }); - - return ( -
-
- -
- -
-
- - -
- -
-
-

- { file.Name || "Untitled" } -

-
- { formatSize(file.Size) } - - Uploaded on { new Date(file.CreatedAt).toLocaleDateString() } -
-
-
-
- ) -}) - -const FilePreview = component$(({ file }: FileProps) => { - type FileType = - | "image" - | "video" - | "audio" - | "other"; - - const type: Signal = useSignal("other"); - const extension = file.Name.split('.').pop()?.toLowerCase() || ""; - - useTask$(async () => { - if ( - ["png", "jpg", "jpeg", "gif"] - .includes(extension)) type.value = "image"; - - else if ( - ["mp4", "webm", "ogg", "avi", "mov", "mkv"] - .includes(extension)) type.value = "video"; - else if ( - ["mp3", "wav", "ogg", "flac", "aac"] - .includes(extension)) type.value = "audio"; - - else type.value = "other"; - }); - - switch (type.value) { - case "image": - return ( -
- {file.Name} -
- ); - case "video": - return ( -
- -
- ); - case "audio": - return ( -
- -
- ); - case "other": - default: - return ( -
-

- Preview not available -

-
- ); - } -}); \ No newline at end of file diff --git a/src/components/dashboard/OSBar.tsx b/src/components/dashboard/OSBar.tsx new file mode 100644 index 0000000..4607fcf --- /dev/null +++ b/src/components/dashboard/OSBar.tsx @@ -0,0 +1,9 @@ +import { component$ } from "@builder.io/qwik"; + +export default component$(() => { + return ( +
+ a +
+ ) +}) \ No newline at end of file diff --git a/src/components/dashboard/TitleBar.tsx b/src/components/dashboard/TitleBar.tsx new file mode 100644 index 0000000..8ae4d02 --- /dev/null +++ b/src/components/dashboard/TitleBar.tsx @@ -0,0 +1,9 @@ +import { component$ } from "@builder.io/qwik"; + +export default component$(() => { + return ( +
+

whats on the agenda today, @hexlocation?

+
+ ) +}) \ No newline at end of file diff --git a/src/lib/api.ts b/src/lib/api.ts index c75a9b8..bc5c2e6 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -15,4 +15,5 @@ export const api = { return await client.post('upload', { body: formData }); }, delete: async (uid: string) => await client.delete(uid).json(), + me: async () => (await client.get('auth/me').json() as any).user, } \ No newline at end of file diff --git a/src/lib/stores.ts b/src/lib/stores.ts index 444b668..8fa59e2 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -1,5 +1,6 @@ import { atom } from "nanostores"; -import { StereoFile } from "./types"; +import { StereoFile, StereoUser } from "./types"; export const areFilesLoaded = atom(false); -export const dashboardFiles = atom([]); \ No newline at end of file +export const dashboardFiles = atom([]); +export const userInfo = atom({} as StereoUser); \ No newline at end of file diff --git a/src/lib/types.ts b/src/lib/types.ts index 861bacc..72bec61 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -5,4 +5,12 @@ export type StereoFile = { Size: number; CreatedAt: string; Mime: string; +} + +export type StereoUser = { + id: string; + username: string; + blacklisted: boolean; + email: string; + created_at: string; } \ No newline at end of file diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index c2572c9..c2db24e 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -1,9 +1,8 @@ -import { component$, useVisibleTask$ } from "@builder.io/qwik"; +import { component$, Signal, useVisibleTask$ } from "@builder.io/qwik"; import { routeLoader$, type DocumentHead } from "@builder.io/qwik-city"; -import Controlbar from "~/components/dashboard/Controlbar"; +import OSBar from "~/components/dashboard/OSBar"; +import TitleBar from "~/components/dashboard/TitleBar"; // import Dropzone from "~/components/Dropzone"; -import File from "~/components/dashboard/File"; -import { SolarUploadLinear, SvgSpinnersBarsRotateFade } from "~/components/misc/Icons"; import { useNanostore$ } from "~/hooks/nanostores"; import { api } from "~/lib/api"; import { OAUTH_LINK } from "~/lib/constants"; @@ -23,50 +22,30 @@ export default component$(() => { useVisibleTask$(async () => { loaded.value = false; files.value = await api.list(); - console.log("Files loaded:", files.value); loaded.value = true; }); return ( <> - {/* */} - - {!loaded.value ? ( -
-

-

loading your files...

- please wait... -
- ) : ( - files.value.length === 0 ? ( -
-

{ - [ - "┻━┻︵ \\(°□°)/ ︵ ┻━┻", - "┻━┻︵ヽ(`Д´)ノ︵ ┻━┻", - "ʕノ•ᴥ•ʔノ ︵ ┻━┻", - "(╯°Д°)╯︵ /(.□ . \\)", - "┬─┬ ︵ /(.□. \\)", - "(/ .□.)\\ ︵╰(゜Д゜)╯︵ /(.□. \\)" - ].sort(() => Math.random() - 0.5)[0] - }

-

you haven't uploaded any files yet!

- click the button to get started -
- ) - : ( -
- {files.value.map((file) => ( - - ))} -
- ) - )} - + + + ); }); +const Files = component$<{ + files: Signal; + loaded: Signal; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +}>(({ files, loaded }) => { + return ( +
+ b +
+ ); +}); + export const head: DocumentHead = { title: "Welcome to Qwik", meta: [ diff --git a/src/routes/layout.tsx b/src/routes/layout.tsx index fe816c8..c7a9b0f 100644 --- a/src/routes/layout.tsx +++ b/src/routes/layout.tsx @@ -1,9 +1,18 @@ import { $, component$, Slot, useOnDocument } from '@builder.io/qwik'; import AOS from 'aos'; import 'aos/dist/aos.css'; +import { useNanostore$ } from '~/hooks/nanostores'; +import { api } from '~/lib/api'; +import { userInfo } from '~/lib/stores'; +import { StereoUser } from '~/lib/types'; export default component$(() => { - useOnDocument("DOMContentLoaded", $(() => { + const info = useNanostore$(userInfo); + + useOnDocument("DOMContentLoaded", $(async () => { + info.value = await api.me() + console.log(info.value); + AOS.init({ once: true, duration: 1000, From f16435101111c5dbd8f820c9d2e0d2ebc893ccb1 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 17:44:55 +0100 Subject: [PATCH 3/6] top bar --- src/components/dashboard/TitleBar.tsx | 36 +++++++++++++++++++++++++-- src/lib/stores.ts | 8 +++++- src/routes/dashboard/index.tsx | 4 +-- src/routes/layout.tsx | 1 - 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/components/dashboard/TitleBar.tsx b/src/components/dashboard/TitleBar.tsx index 8ae4d02..ba9caa5 100644 --- a/src/components/dashboard/TitleBar.tsx +++ b/src/components/dashboard/TitleBar.tsx @@ -1,9 +1,41 @@ import { component$ } from "@builder.io/qwik"; +import { useNanostore$ } from "~/hooks/nanostores"; +import { userInfo } from "~/lib/stores"; +import { StereoUser } from "~/lib/types"; export default component$(() => { + const greetings = [ + "what's on the agenda today, |?", + "what's on your mind, |?", + "what's the plan, |?", + "ready to rock, |?", + "what's brewing, |?", + "what's the latest, |?", + "how's your day going, |?", + "need some inspiration, |?", + "let's make some noise, |!", + "welcome back, |!", + "good to see you, |!", + "what are we making today, |?", + "time to make some magic, |!", + "let's get creative, |?", + "what's the vibe today, |?", + ] + + const greeting = greetings[Math.floor(Math.random() * greetings.length)]; + const user = useNanostore$(userInfo); + + const splits = greeting.split("|"); + return ( -
-

whats on the agenda today, @hexlocation?

+
+

+ {splits[0]} + + @{user.value?.username || "..."} + + {splits[1]} +

) }) \ No newline at end of file diff --git a/src/lib/stores.ts b/src/lib/stores.ts index 8fa59e2..ab97728 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -3,4 +3,10 @@ import { StereoFile, StereoUser } from "./types"; export const areFilesLoaded = atom(false); export const dashboardFiles = atom([]); -export const userInfo = atom({} as StereoUser); \ No newline at end of file +export const userInfo = atom({ + id: "1", + username: "user", + blacklisted: false, + email: "user@example.com", + created_at: Date.now().toString(), +}); \ No newline at end of file diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index c2db24e..10aa70b 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -26,11 +26,11 @@ export default component$(() => { }); return ( - <> +
- +
); }); diff --git a/src/routes/layout.tsx b/src/routes/layout.tsx index c7a9b0f..9ed7b73 100644 --- a/src/routes/layout.tsx +++ b/src/routes/layout.tsx @@ -11,7 +11,6 @@ export default component$(() => { useOnDocument("DOMContentLoaded", $(async () => { info.value = await api.me() - console.log(info.value); AOS.init({ once: true, From b36d3b76a124caa5a96a25320e47d518819aa15c Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 20:27:32 +0100 Subject: [PATCH 4/6] Enhance dashboard components with new icons, layout adjustments, and improved file display --- src/components/dashboard/OSBar.tsx | 40 +++++++++++- src/components/dashboard/TitleBar.tsx | 8 ++- src/components/landing/Footer.tsx | 4 +- src/components/landing/Navbar.tsx | 4 +- src/components/landing/Testimonials.tsx | 7 +- src/components/misc/Icons.tsx | 85 ++++++++++++++++++++++++- src/components/misc/StereoLogo.tsx | 9 --- src/routes/dashboard/index.tsx | 21 +++++- src/routes/layout.tsx | 7 +- 9 files changed, 159 insertions(+), 26 deletions(-) delete mode 100644 src/components/misc/StereoLogo.tsx diff --git a/src/components/dashboard/OSBar.tsx b/src/components/dashboard/OSBar.tsx index 4607fcf..44f6698 100644 --- a/src/components/dashboard/OSBar.tsx +++ b/src/components/dashboard/OSBar.tsx @@ -1,9 +1,45 @@ import { component$ } from "@builder.io/qwik"; +import { SolarLibraryLinear, SolarRoundedMagniferLinear, SolarSettingsLinear, SolarUploadMinimalisticLinear, StereoCircularProgress, StereoLogoLinear } from "../misc/Icons"; export default component$(() => { + const used = 3.8; + const total = 15; return ( -
- a +
+
+ +

{used} / {total} GB

+
+ +
+ + + + + +
+ +
+ ? +
) }) \ No newline at end of file diff --git a/src/components/dashboard/TitleBar.tsx b/src/components/dashboard/TitleBar.tsx index ba9caa5..c26af60 100644 --- a/src/components/dashboard/TitleBar.tsx +++ b/src/components/dashboard/TitleBar.tsx @@ -1,4 +1,4 @@ -import { component$ } from "@builder.io/qwik"; +import { component$, useTask$ } from "@builder.io/qwik"; import { useNanostore$ } from "~/hooks/nanostores"; import { userInfo } from "~/lib/stores"; import { StereoUser } from "~/lib/types"; @@ -26,9 +26,13 @@ export default component$(() => { const user = useNanostore$(userInfo); const splits = greeting.split("|"); + + useTask$(({ track }) => { + track(() => user.value); + }) return ( -
+

{splits[0]} diff --git a/src/components/landing/Footer.tsx b/src/components/landing/Footer.tsx index 16fef9d..363619f 100644 --- a/src/components/landing/Footer.tsx +++ b/src/components/landing/Footer.tsx @@ -1,5 +1,5 @@ import { component$ } from "@builder.io/qwik"; -import StereoLogo from "../misc/StereoLogo"; +import { StereoLogoBold } from "../misc/Icons"; export default component$(() => { return ( @@ -7,7 +7,7 @@ export default component$(() => {

- + stereo.cat diff --git a/src/components/landing/Navbar.tsx b/src/components/landing/Navbar.tsx index 85fb716..4e23a25 100644 --- a/src/components/landing/Navbar.tsx +++ b/src/components/landing/Navbar.tsx @@ -1,5 +1,5 @@ import { component$ } from "@builder.io/qwik"; -import StereoLogo from "../misc/StereoLogo"; +import { StereoLogoBold } from "../misc/Icons"; export default component$(() => { const items = [ @@ -17,7 +17,7 @@ export default component$(() => { data-aos-duration="1000" class="fixed flex items-center justify-start top-6 left-1/2 transform -translate-x-1/2 bg-neutral-950 p-8 h-10 rounded-full lg:w-2/3 md:w-4/5 w-4/5 z-[9999999] shadow-lg">
- +

diff --git a/src/components/misc/Icons.tsx b/src/components/misc/Icons.tsx index 5500ae1..73511c1 100644 --- a/src/components/misc/Icons.tsx +++ b/src/components/misc/Icons.tsx @@ -1,5 +1,7 @@ import { QwikIntrinsicElements } from "@builder.io/qwik"; +// Solar - https://icones.js.org/collection/solar + export function SolarUploadLinear(props: QwikIntrinsicElements['svg'], key: string) { return ( @@ -26,7 +28,6 @@ export function SolarLinkRoundBold(props: QwikIntrinsicElements['svg'], key: str ) } - export function SolarDownloadMinimalisticBold(props: QwikIntrinsicElements['svg'], key: string) { return ( @@ -36,4 +37,86 @@ export function SvgSpinnersBarsRotateFade(props: QwikIntrinsicElements['svg'], k return ( ) +} + +export function SolarLibraryLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + +export function SolarUploadMinimalisticLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + + +export function SolarRoundedMagniferLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + + +export function SolarSettingsLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + +// Stereo + +export function StereoLogoBold(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + +export function StereoLogoLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + +export function StereoCircularProgress( + { value, ...svgProps }: QwikIntrinsicElements['svg'] & { value: number }, + key: string +) { + const radius = 10; + const circumference = 2 * Math.PI * radius; + const dashOffset = circumference * (1 - value); + + return ( + + + + + ); } \ No newline at end of file diff --git a/src/components/misc/StereoLogo.tsx b/src/components/misc/StereoLogo.tsx deleted file mode 100644 index 892ea95..0000000 --- a/src/components/misc/StereoLogo.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { component$, QwikIntrinsicElements } from "@builder.io/qwik"; - -export default component$((props: QwikIntrinsicElements['svg']) => { - return ( - - - - ) -}) \ No newline at end of file diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index 10aa70b..5bd769c 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -26,7 +26,7 @@ export default component$(() => { }); return ( -

+
@@ -39,9 +39,24 @@ const Files = component$<{ loaded: Signal; // eslint-disable-next-line @typescript-eslint/no-unused-vars }>(({ files, loaded }) => { + + const File = component$(({ file }: { file: StereoFile }) => { + return ( +
+ {file.Name} +
+ ) + }) + return ( -
- b +
+
+ {files.value.map((file) => ( + Array.from({ length: 15 }).map((_, i) => ( + + )) + ))} +
); }); diff --git a/src/routes/layout.tsx b/src/routes/layout.tsx index 9ed7b73..0d156ac 100644 --- a/src/routes/layout.tsx +++ b/src/routes/layout.tsx @@ -1,4 +1,4 @@ -import { $, component$, Slot, useOnDocument } from '@builder.io/qwik'; +import { $, component$, Slot, useOnDocument, useVisibleTask$ } from '@builder.io/qwik'; import AOS from 'aos'; import 'aos/dist/aos.css'; import { useNanostore$ } from '~/hooks/nanostores'; @@ -9,8 +9,11 @@ import { StereoUser } from '~/lib/types'; export default component$(() => { const info = useNanostore$(userInfo); + useVisibleTask$(async () => { + info.value = await api.me(); + }) + useOnDocument("DOMContentLoaded", $(async () => { - info.value = await api.me() AOS.init({ once: true, From 3217373024ae14edd39f3667eebb0bc702bacc52 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:58:33 +0100 Subject: [PATCH 5/6] q icon to osbar --- src/components/dashboard/OSBar.tsx | 6 +++--- src/components/misc/Icons.tsx | 7 +++++++ src/routes/dashboard/index.tsx | 6 ++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/dashboard/OSBar.tsx b/src/components/dashboard/OSBar.tsx index 44f6698..47206ac 100644 --- a/src/components/dashboard/OSBar.tsx +++ b/src/components/dashboard/OSBar.tsx @@ -1,5 +1,5 @@ import { component$ } from "@builder.io/qwik"; -import { SolarLibraryLinear, SolarRoundedMagniferLinear, SolarSettingsLinear, SolarUploadMinimalisticLinear, StereoCircularProgress, StereoLogoLinear } from "../misc/Icons"; +import { SolarLibraryLinear, SolarQuestionCircleLinear, SolarRoundedMagniferLinear, SolarSettingsLinear, SolarUploadMinimalisticLinear, StereoCircularProgress, StereoLogoLinear } from "../misc/Icons"; export default component$(() => { const used = 3.8; @@ -37,8 +37,8 @@ export default component$(() => { background: "rgba(255, 38, 78, 0.15)", boxShadow: "0px 4px 20px 0px rgba(255, 38, 78, 0.08), 0px 8px 12px 0px rgba(0, 0, 0, 0.12), 0px 4px 4px 0px rgba(0, 0, 0, 0.06), 0px 2px 1px 0px rgba(0, 0, 0, 0.04), 0px 4px 8px 0px rgba(255, 38, 78, 0.12) inset, 0px 1px 3px 0px rgba(255, 38, 78, 0.24) inset", backdropFilter: "blur(12px)", - }} class="flex items-center justify-center px-6 py-4 gap-2 text-white text-xl"> - ? + }} class="flex items-center justify-center px-5 py-5 gap-2 text-white text-3xl h-full"> +
) diff --git a/src/components/misc/Icons.tsx b/src/components/misc/Icons.tsx index 73511c1..6718fbe 100644 --- a/src/components/misc/Icons.tsx +++ b/src/components/misc/Icons.tsx @@ -65,6 +65,13 @@ export function SolarSettingsLinear(props: QwikIntrinsicElements['svg'], key: st ) } + +export function SolarQuestionCircleLinear(props: QwikIntrinsicElements['svg'], key: string) { + return ( + + ) +} + // Stereo export function StereoLogoBold(props: QwikIntrinsicElements['svg'], key: string) { diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index 5bd769c..b6f48e8 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -49,12 +49,10 @@ const Files = component$<{ }) return ( -
+
{files.value.map((file) => ( - Array.from({ length: 15 }).map((_, i) => ( - - )) + ))}
From f843155394aebca6170a395e85841bbadafb9bb7 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sat, 21 Jun 2025 22:37:32 +0100 Subject: [PATCH 6/6] Add file preview component and enhance file size formatting in dashboard --- src/routes/dashboard/index.tsx | 93 ++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index b6f48e8..d2a0f3d 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -1,4 +1,4 @@ -import { component$, Signal, useVisibleTask$ } from "@builder.io/qwik"; +import { component$, Signal, useSignal, useTask$, useVisibleTask$ } from "@builder.io/qwik"; import { routeLoader$, type DocumentHead } from "@builder.io/qwik-city"; import OSBar from "~/components/dashboard/OSBar"; import TitleBar from "~/components/dashboard/TitleBar"; @@ -34,6 +34,13 @@ export default component$(() => { ); }); +const formatSize = (bytes: number) => { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; + return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`; +} + const Files = component$<{ files: Signal; loaded: Signal; @@ -41,9 +48,89 @@ const Files = component$<{ }>(({ files, loaded }) => { const File = component$(({ file }: { file: StereoFile }) => { + const Preview = component$(() => { + type FileType = + | "image" + | "video" + | "audio" + | "other"; + + const fileType: Signal = useSignal("other"); + const type = file.Mime.split("/")[1]; + + useTask$(async () => { + if ( + ["jpeg", "jpg", "png", "gif", "webp"] + .includes(type) + ) fileType.value = "image"; + + else if ( + ["mp4", "webm", "ogg", "avi", "mov"] + .includes(type) + ) fileType.value = "video"; + + else if ( + ["mp3", "wav", "flac", "aac"] + .includes(type) + ) fileType.value = "audio"; + + else fileType.value = "other"; + }); + + return ( +
+ {fileType.value === "image" && ( + {file.Name} + )} + + {fileType.value === "video" && ( +
+ ) + }) + return ( -
- {file.Name} +
+ + +
+

{file.Name}

+

+ {formatSize(file.Size)} + + Uploaded on {new Date(file.CreatedAt).toLocaleDateString()} +

+
) })