diff --git a/src/front/App.tsx b/src/front/App.tsx index dc50617..76a6dff 100644 --- a/src/front/App.tsx +++ b/src/front/App.tsx @@ -1,40 +1,19 @@ import "mdui/components/layout"; import "mdui/components/layout-main"; -import Hyperate from "./components/Hyperate"; -import Lanyard from "./components/Lanyard"; import NavigationBar from "./components/NavigationBar"; import TopAppBar from "./components/TopAppBar"; +import About from "./components/pages/About"; + export default () => { return ( -
+ - - -
-

[seth@ipv4 ~]$ cat ./about.txt

-

- A Dedicated Backend Developer, -
- with a passion for high-fidelity audio, -
- gaming, and web development. -

- -

[seth@ipv4 ~]$ cat /tmp/discord-ipc

-

- -

- -

[seth@ipv4 ~]$ cat /tmp/heartrate

-

- -

-
-
-
+ + + -
+ ); }; diff --git a/src/front/components/Hyperate/index.tsx b/src/front/components/Hyperate/index.tsx index e50100e..ca59e65 100644 --- a/src/front/components/Hyperate/index.tsx +++ b/src/front/components/Hyperate/index.tsx @@ -7,13 +7,22 @@ export default () => { socket.addEventListener("hyperate", (event: Event) => { const heartRate = (event as CustomEvent).detail; + + if (heartRate === 0) { + document.body.style.setProperty("--hyperate-display", "none"); + } else { + document.body.style.removeProperty("--hyperate-display"); + } + + document.body.style.setProperty("--bpm", heartRate.toString()); + if (paragraph.current) { - paragraph.current.innerText = `${heartRate} BPM`; + paragraph.current.innerText = `❤️ ${heartRate} BPM`; } }); return (
-

0 BPM

+

❤️ 0 BPM

); }; diff --git a/src/front/components/Lanyard/index.tsx b/src/front/components/Lanyard/index.tsx index 001c734..67b7f79 100644 --- a/src/front/components/Lanyard/index.tsx +++ b/src/front/components/Lanyard/index.tsx @@ -1,7 +1,16 @@ import { highlightElement } from "@speed-highlight/core"; +import { artist } from "../../utilities/artist"; import { createRef } from "tsx-dom"; import socket from "../../utilities/socket"; +const colorMap = { + online: "#00ff00", + idle: "#ffff00", + dnd: "#ff0000", + offline: "", + streaming: "#ff00ff", +}; + const activityTypes: Record = { 0: "Playing", 1: "Streaming", @@ -17,10 +26,23 @@ export default () => { socket.addEventListener("lanyard", (event: Event) => { const lanyard = (event as CustomEvent).detail; + const streamingActivity = lanyard.activities.find((act) => act.type === 1); + if (streamingActivity) { + artist(colorMap.streaming); + } else { + artist(colorMap[lanyard.discord_status]); + } + + if (lanyard.activities.length === 0) { + document.body.style.setProperty("--lanyard-display", "none"); + } else { + document.body.style.removeProperty("--lanyard-display"); + } + + if (container.current) { container.current.textContent = JSON.stringify( { - status: lanyard.discord_status, activities: [ ...new Set( lanyard.activities.map((act) => { @@ -44,8 +66,8 @@ export default () => { }); return ( -
+ {"{}"} -
+ ); }; diff --git a/src/front/components/NavigationBar/index.tsx b/src/front/components/NavigationBar/index.tsx index 53958d7..3d67f2f 100644 --- a/src/front/components/NavigationBar/index.tsx +++ b/src/front/components/NavigationBar/index.tsx @@ -9,20 +9,11 @@ import "@mdui/icons/more-vert--rounded"; export default () => { return ( - - + + - Item 1 - - - Item 2 - - - Item 3 - - - Item 4 + About ); diff --git a/src/front/components/TopAppBar/index.tsx b/src/front/components/TopAppBar/index.tsx index ae1590c..2f02785 100644 --- a/src/front/components/TopAppBar/index.tsx +++ b/src/front/components/TopAppBar/index.tsx @@ -4,8 +4,9 @@ import "mdui/components/button-icon"; export default () => { return ( + // @ts-ignore // variant is not in the types for some reason? - Seth @ IPv4.ARMY + IPv4.ARMY ); }; diff --git a/src/front/components/pages/About/index.tsx b/src/front/components/pages/About/index.tsx new file mode 100644 index 0000000..f4d6181 --- /dev/null +++ b/src/front/components/pages/About/index.tsx @@ -0,0 +1,99 @@ +import 'mdui/components/card'; +import 'mdui/components/avatar'; + +import 'mdui/components/segmented-button-group'; +import 'mdui/components/segmented-button'; + +import { getColorFromImage } from 'mdui/functions/getColorFromImage'; +import { artist } from '../../../utilities/artist'; +import Lanyard from '../../Lanyard'; +import Hyperate from '../../Hyperate'; + +const Abyssinian = new Image(); +Abyssinian.src = "/public/Abyssinian/default.png"; +Abyssinian.onload = async () => { + const profilePicture = document.getElementById("profilePicture") as HTMLElement; + + artist(await getColorFromImage(Abyssinian), profilePicture); + + profilePicture.setAttribute("src", Abyssinian.src); + profilePicture.innerText = ""; +}; + +export default () => { + return ( +
+ + S +

Seth

+ {/* make important text bold */} +

+ A Dedicated Backend Developer, with many passions. +
+
+ + high-fidelity audio + gaming + development + +

+
+ +
+ + + + + +
+ + + + +
+ ); +}; diff --git a/src/front/index.css b/src/front/index.css index 9ff6048..282d7f0 100644 --- a/src/front/index.css +++ b/src/front/index.css @@ -3,6 +3,15 @@ @import "../../node_modules/mdui/mdui.css"; +:not(:defined) { + visibility: hidden; +} + +html, +body { + height: 100vh; +} + body { margin: 0; padding: 0; @@ -40,12 +49,12 @@ body { background: #bdf5; } -[class*="shj-lang-"] > div { +[class*="shj-lang-"]>div { display: flex; overflow: auto; } -[class*="shj-lang-"] > div :last-child { +[class*="shj-lang-"]>div :last-child { outline: none; flex: 1; } @@ -165,3 +174,31 @@ body { .shj-syn-str { color: #4dacfa; } + +.heartbeat { + display: inline-block; + animation: pulse calc(60s / var(--bpm)) infinite ease-in-out; + transform-origin: center; +} + +@keyframes pulse { + 0% { + transform: scale(1); + } + + 25% { + transform: scale(1.1); + } + + 50% { + transform: scale(1); + } + + 75% { + transform: scale(1.1); + } + + 100% { + transform: scale(1); + } +} \ No newline at end of file diff --git a/src/front/index.tsx b/src/front/index.tsx index eaf9dd5..293dc5f 100644 --- a/src/front/index.tsx +++ b/src/front/index.tsx @@ -1,9 +1,12 @@ import "tsx-dom"; +import { artist } from "./utilities/artist"; import "./utilities/clicker"; import App from "./App"; +artist(); + document.body.appendChild(); // You're garbage, let me collect you. diff --git a/src/front/utilities/artist/index.ts b/src/front/utilities/artist/index.ts new file mode 100644 index 0000000..c922c54 --- /dev/null +++ b/src/front/utilities/artist/index.ts @@ -0,0 +1,13 @@ +import { setColorScheme } from "mdui/functions/setColorScheme"; + +export const artist = (color?: string, element?: HTMLElement) => { + if (color?.startsWith("#")) { + setColorScheme(color, { + target: element || document.documentElement, + }); + } else { + setColorScheme("#FFF"); + } + + document.body.style.setProperty("--status-color", getComputedStyle(document.documentElement).getPropertyValue("--mdui-color-primary")); +}; diff --git a/src/front/utilities/clicker/index.ts b/src/front/utilities/clicker/index.ts index 90a88bb..3926628 100644 --- a/src/front/utilities/clicker/index.ts +++ b/src/front/utilities/clicker/index.ts @@ -2,20 +2,21 @@ const effectTick = new Audio("https://no.ipv4.army/u/Effect_Tick.ogg"); effectTick.volume = 0.1; -const whitelistedTags = ["mdui-button", "mdui-icon"]; +const whitelistedTags = ["button", "icon", "item"]; document.onclick = (event: MouseEvent) => { - const target = event.target as HTMLElement; + const target = event.target as HTMLElement; - if (!target) return; + if (!target) return; - const tagName = target.tagName.toLowerCase(); - const isWhitelisted = whitelistedTags.some((tag) => tagName.startsWith(tag)); + const tagName = target.tagName.toLowerCase(); + const isWhitelisted = whitelistedTags.some((tag) => tagName.includes(tag)); - console.log(tagName, isWhitelisted); + console.log(tagName, isWhitelisted); - if (!isWhitelisted) return; + if (!isWhitelisted) return; - effectTick.currentTime = 0; - effectTick.play(); + ("vibrate" in navigator && navigator.vibrate(1)); + effectTick.currentTime = 0; + effectTick.play(); };